সিস্টেম ক্যাপশন সেটিংস গ্রহণ করুন

অ্যান্ড্রয়েড টিভিতে, ব্যবহারকারীদের নিজস্ব ক্যাপশন শৈলী সংজ্ঞায়িত করার জন্য সেটিংস প্রদান করা হয়। এই নির্দেশিকাটি প্রদর্শন করে যে কীভাবে একটি অ্যাপ সিস্টেম-প্রদত্ত ক্যাপশন শৈলী পেতে এবং প্রয়োগ করতে পারে।

ক্যাপশন বিকল্পগুলি সেটিংস > সিস্টেম > অ্যাক্সেসিবিলিটি > ক্যাপশনের অধীনে পাওয়া যাবে:

ATV_ক্যাপশন_সেটিংস

ক্যাপশনিং ম্যানেজার পান

একটি কার্যকলাপ থেকে, আপনি CaptioningManager ব্যবহার করে এর Context থেকে ক্যাপশন পরিষেবা পেতে পারেন:

CaptioningManager captioningManager = (CaptioningManager)context.getSystemService(Context.CAPTIONING_SERVICE);

ক্যাপশন শৈলী পরিবর্তন হ্যান্ডেল

তারপরে আপনি CaptioningChangeListener প্রয়োগ করে ক্যাপশন শৈলী পরিবর্তনগুলি পরিচালনা করতে পারেন:

if (captioningManager != null) {
 
// Define a class to store the CaptionStyle details.
 
CurrentCaptionStyle currentCaptionStyle = new CurrentCaptionStyle;
 
// Define the listeners.
  captioningManager
.addCaptioningChangeListener(new CaptioningChangeListener() {

   
@Override
   
public void onEnabledChanged(boolean enabled) {
     
super.onEnabledChanged(enabled);
     
Log.d(TAG, "onEnabledChanged");
      currentCaptionStyle
.isEnabled = enabled;
   
}

   
@Override
   
public void onLocaleChanged(@Nullable Locale locale) {
     
super.onLocaleChanged(locale);
     
Log.d(TAG, "onLocaleChanged");
      currentCaptionStyle
.locale = locale;
   
}

   
@Override
   
public void onFontScaleChanged(float fontScale) {
     
super.onFontScaleChanged(fontScale);
     
Log.d(TAG, "onFontScaleChanged");
      currentCaptionStyle
.fontScale = fontScale;
   
}

   
@Override
   
public void onUserStyleChanged(@NonNull CaptionStyle userStyle) {
     
super.onUserStyleChanged(userStyle);
     
Log.d(TAG, "onUserStyleChanged");
      currentCaptionStyle
.hasBackgroundColor = userStyle.hasBackgroundColor();
      currentCaptionStyle
.backgroundColor = userStyle.backgroundColor;
      currentCaptionStyle
.backgroundOpcity = userStyle.backgroundColor >>> 24;
      currentCaptionStyle
.hasForegroundColor = userStyle.hasForegroundColor();
      currentCaptionStyle
.foregroundColor = userStyle.foregroundColor;
      currentCaptionStyle
.foregroundOpacity = userStyle.foregroundColor >>> 24;
      currentCaptionStyle
.hasWindowColor = userStyle.hasWindowColor();
      currentCaptionStyle
.windowColor = userStyle.windowColor;
      currentCaptionStyle
.windowOpcity = userStyle.windowColor >>> 24;
      currentCaptionStyle
.hasEdgeColor = userStyle.hasEdgeColor();
      currentCaptionStyle
.edgeColor = userStyle.edgeColor;
      currentCaptionStyle
.hasEdgeType = userStyle.hasEdgeType();
      currentCaptionStyle
.edgeType = userStyle.edgeType;
      currentCaptionStyle
.typeFace = userStyle.getTypeface();
   
}

 
});

CaptionStyle সিস্টেম পেতে, আপনি getUserStyle() সরাসরি কল করতে পারেন:

CaptionStyle systemCaptionStyle = captioningManager.getUserStyle();