Example usage for android.view.accessibility CaptioningManager addCaptioningChangeListener

List of usage examples for android.view.accessibility CaptioningManager addCaptioningChangeListener

Introduction

In this page you can find the example usage for android.view.accessibility CaptioningManager addCaptioningChangeListener.

Prototype

public void addCaptioningChangeListener(@NonNull CaptioningChangeListener listener) 

Source Link

Document

Adds a listener for changes in the user's preferred captioning enabled state and visual properties.

Usage

From source file:com.google.android.libraries.cast.companionlibrary.cast.VideoCastManager.java

@SuppressLint("NewApi")
private void registerCaptionListener(final Context context) {
    if (Utils.IS_KITKAT_OR_ABOVE) {
        CaptioningManager captioningManager = (CaptioningManager) context
                .getSystemService(Context.CAPTIONING_SERVICE);
        captioningManager.addCaptioningChangeListener(new CaptioningManager.CaptioningChangeListener() {
            @Override/*from  w  ww .  ja  v  a 2s .com*/
            public void onEnabledChanged(boolean enabled) {
                onTextTrackEnabledChanged(enabled);
            }

            @Override
            public void onUserStyleChanged(CaptioningManager.CaptionStyle userStyle) {
                onTextTrackStyleChanged(mTrackManager.getTextTrackStyle());
            }

            @Override
            public void onFontScaleChanged(float fontScale) {
                onTextTrackStyleChanged(mTrackManager.getTextTrackStyle());
            }

            @Override
            public void onLocaleChanged(Locale locale) {
                onTextTrackLocaleChanged(locale);
            }
        });
    }
}