Example usage for android.media.tv TvTrackInfo TYPE_AUDIO

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

Introduction

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

Prototype

int TYPE_AUDIO

To view the source code for android.media.tv TvTrackInfo TYPE_AUDIO.

Click Source Link

Document

The type value for audio tracks.

Usage

From source file:com.android.tv.menu.TvOptionsRowAdapter.java

@VisibleForTesting
boolean updateMultiAudioAction() {
    List<TvTrackInfo> audioTracks = getMainActivity().getTracks(TvTrackInfo.TYPE_AUDIO);
    boolean oldEnabled = MenuAction.SELECT_AUDIO_LANGUAGE_ACTION.isEnabled();
    boolean newEnabled = audioTracks != null && audioTracks.size() > 1;
    if (oldEnabled != newEnabled) {
        MenuAction.SELECT_AUDIO_LANGUAGE_ACTION.setEnabled(newEnabled);
        return true;
    }/*from   w  w  w . j a  v  a  2s .  com*/
    return false;
}

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  w  ww  .j av  a2  s.co  m*/
    }

    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);
}

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//w  ww  .j ava 2  s  . co  m
                .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 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  om*/
        }
    }
    TvSettings.setMultiAudioId(this, null);
    TvSettings.setMultiAudioLanguage(this, null);
    TvSettings.setMultiAudioChannelCount(this, 0);
}