Example usage for android.media.tv TvTrackInfo getId

List of usage examples for android.media.tv TvTrackInfo getId

Introduction

In this page you can find the example usage for android.media.tv TvTrackInfo getId.

Prototype

public final String getId() 

Source Link

Document

Returns the ID of the track.

Usage

From source file:com.android.tv.MainActivity.java

private void saveMultiAudioSetting(String trackId) {
    List<TvTrackInfo> tracks = getTracks(TvTrackInfo.TYPE_AUDIO);
    if (tracks != null) {
        for (TvTrackInfo track : tracks) {
            if (track.getId().equals(trackId)) {
                TvSettings.setMultiAudioId(this, track.getId());
                TvSettings.setMultiAudioLanguage(this, track.getLanguage());
                TvSettings.setMultiAudioChannelCount(this, track.getAudioChannelCount());
                return;
            }/*from w w  w .  j a  v a 2 s.  c o m*/
        }
    }
    TvSettings.setMultiAudioId(this, null);
    TvSettings.setMultiAudioLanguage(this, null);
    TvSettings.setMultiAudioChannelCount(this, 0);
}

From source file:com.android.tv.MainActivity.java

private void saveClosedCaptionSetting(int option, String trackId) {
    mCaptionSettings.setEnableOption(option);
    if (option == CaptionSettings.OPTION_ON) {
        List<TvTrackInfo> tracks = getTracks(TvTrackInfo.TYPE_SUBTITLE);
        if (tracks != null) {
            for (TvTrackInfo track : tracks) {
                if (track.getId().equals(trackId)) {
                    mCaptionSettings.setLanguage(track.getLanguage());
                    mCaptionSettings.setTrackId(trackId);
                    return;
                }/*from w ww . j av a  2  s  .com*/
            }
        }
    }
}

From source file:com.android.tv.MainActivity.java

public void selectTrack(int type, TvTrackInfo track) {
    mTvView.selectTrack(type, track == null ? null : track.getId());
    if (type == TvTrackInfo.TYPE_AUDIO) {
        mTvOptionsManager//from   w ww  . j  a  v  a 2  s.c om
                .onMultiAudioChanged(track == null ? null : Utils.getMultiAudioString(this, track, false));
    } else if (type == TvTrackInfo.TYPE_SUBTITLE) {
        mTvOptionsManager.onClosedCaptionsChanged(track);
    }
}

From source file:com.android.tv.MainActivity.java

private void applyClosedCaption() {
    List<TvTrackInfo> tracks = getTracks(TvTrackInfo.TYPE_SUBTITLE);
    if (tracks == null) {
        mTvOptionsManager.onClosedCaptionsChanged(null);
        return;//from   ww  w . j  a va 2s.  c om
    }

    boolean enabled = mCaptionSettings.isEnabled();
    mTvView.setClosedCaptionEnabled(enabled);

    String selectedTrackId = getSelectedTrack(TvTrackInfo.TYPE_SUBTITLE);
    TvTrackInfo alternativeTrack = null;
    if (enabled) {
        String language = mCaptionSettings.getLanguage();
        String trackId = mCaptionSettings.getTrackId();
        for (TvTrackInfo track : tracks) {
            if (Utils.isEqualLanguage(track.getLanguage(), language)) {
                if (track.getId().equals(trackId)) {
                    if (!track.getId().equals(selectedTrackId)) {
                        selectTrack(TvTrackInfo.TYPE_SUBTITLE, track);
                    } else {
                        // Already selected. Update the option string only.
                        mTvOptionsManager.onClosedCaptionsChanged(track);
                    }
                    if (DEBUG) {
                        Log.d(TAG, "Subtitle Track Selected {id=" + track.getId() + ", language="
                                + track.getLanguage() + "}");
                    }
                    return;
                } else if (alternativeTrack == null) {
                    alternativeTrack = track;
                }
            }
        }
        if (alternativeTrack != null) {
            if (!alternativeTrack.getId().equals(selectedTrackId)) {
                selectTrack(TvTrackInfo.TYPE_SUBTITLE, alternativeTrack);
            } else {
                mTvOptionsManager.onClosedCaptionsChanged(alternativeTrack);
            }
            if (DEBUG) {
                Log.d(TAG, "Subtitle Track Selected {id=" + alternativeTrack.getId() + ", language="
                        + alternativeTrack.getLanguage() + "}");
            }
            return;
        }
    }
    if (selectedTrackId != null) {
        selectTrack(TvTrackInfo.TYPE_SUBTITLE, null);
        if (DEBUG)
            Log.d(TAG, "Subtitle Track Unselected");
        return;
    }
    mTvOptionsManager.onClosedCaptionsChanged(null);
}

From source file:com.android.tv.MainActivity.java

private void applyMultiAudio() {
    List<TvTrackInfo> tracks = getTracks(TvTrackInfo.TYPE_AUDIO);
    if (tracks == null) {
        mTvOptionsManager.onMultiAudioChanged(null);
        return;/*from ww w.jav a 2 s. com*/
    }

    String id = TvSettings.getMultiAudioId(this);
    String language = TvSettings.getMultiAudioLanguage(this);
    int channelCount = TvSettings.getMultiAudioChannelCount(this);
    TvTrackInfo bestTrack = TvTrackInfoUtils.getBestTrackInfo(tracks, id, language, channelCount);
    if (bestTrack != null) {
        String selectedTrack = getSelectedTrack(TvTrackInfo.TYPE_AUDIO);
        if (!bestTrack.getId().equals(selectedTrack)) {
            selectTrack(TvTrackInfo.TYPE_AUDIO, bestTrack);
        } else {
            mTvOptionsManager.onMultiAudioChanged(Utils.getMultiAudioString(this, bestTrack, false));
        }
        return;
    }
    mTvOptionsManager.onMultiAudioChanged(null);
}