Example usage for android.media.tv TvInputManager VIDEO_UNAVAILABLE_REASON_BUFFERING

List of usage examples for android.media.tv TvInputManager VIDEO_UNAVAILABLE_REASON_BUFFERING

Introduction

In this page you can find the example usage for android.media.tv TvInputManager VIDEO_UNAVAILABLE_REASON_BUFFERING.

Prototype

int VIDEO_UNAVAILABLE_REASON_BUFFERING

To view the source code for android.media.tv TvInputManager VIDEO_UNAVAILABLE_REASON_BUFFERING.

Click Source Link

Document

Reason for TvInputService.Session#notifyVideoUnavailable(int) and TvView.TvInputCallback#onVideoUnavailable(String,int) : Video is unavailable because the corresponding TV input has stopped playback temporarily to buffer more data.

Usage

From source file:com.android.tv.ui.TunableTvView.java

@UiThread
private void hideScreenByVideoAvailability(int reason) {
    mVideoAvailable = false;//from  w ww.j  ava2 s.com
    mVideoUnavailableReason = reason;
    if (mInternetCheckTask != null) {
        mInternetCheckTask.cancel(true);
        mInternetCheckTask = null;
    }
    switch (reason) {
    case TvInputManager.VIDEO_UNAVAILABLE_REASON_AUDIO_ONLY:
        mHideScreenView.setVisibility(VISIBLE);
        mHideScreenView.setImageVisibility(false);
        mHideScreenView.setText(R.string.tvview_msg_audio_only);
        mBufferingSpinnerView.setVisibility(GONE);
        unmuteIfPossible();
        break;
    case TvInputManager.VIDEO_UNAVAILABLE_REASON_BUFFERING:
        mBufferingSpinnerView.setVisibility(VISIBLE);
        mute();
        break;
    case TvInputManager.VIDEO_UNAVAILABLE_REASON_WEAK_SIGNAL:
        mHideScreenView.setVisibility(VISIBLE);
        mHideScreenView.setText(R.string.tvview_msg_weak_signal);
        mBufferingSpinnerView.setVisibility(GONE);
        mute();
        break;
    case TvInputManager.VIDEO_UNAVAILABLE_REASON_TUNING:
    case VIDEO_UNAVAILABLE_REASON_NOT_TUNED:
        mHideScreenView.setVisibility(VISIBLE);
        mHideScreenView.setImageVisibility(false);
        mHideScreenView.setText(null);
        mBufferingSpinnerView.setVisibility(GONE);
        mute();
        break;
    case TvInputManager.VIDEO_UNAVAILABLE_REASON_UNKNOWN:
    default:
        mHideScreenView.setVisibility(VISIBLE);
        mHideScreenView.setImageVisibility(false);
        mHideScreenView.setText(null);
        mBufferingSpinnerView.setVisibility(GONE);
        mute();
        if (mCurrentChannel != null && !mCurrentChannel.isPhysicalTunerChannel()) {
            mInternetCheckTask = new InternetCheckTask();
            mInternetCheckTask.execute();
        }
        break;
    }
}

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

private void updateAvailabilityToast(StreamInfo info) {
    if (info.isVideoAvailable()) {
        return;//ww w.  j  ava2  s . c om
    }

    int stringId;
    switch (info.getVideoUnavailableReason()) {
    case TunableTvView.VIDEO_UNAVAILABLE_REASON_NOT_TUNED:
    case TvInputManager.VIDEO_UNAVAILABLE_REASON_TUNING:
    case TvInputManager.VIDEO_UNAVAILABLE_REASON_BUFFERING:
    case TvInputManager.VIDEO_UNAVAILABLE_REASON_AUDIO_ONLY:
    case TvInputManager.VIDEO_UNAVAILABLE_REASON_WEAK_SIGNAL:
        return;
    case TvInputManager.VIDEO_UNAVAILABLE_REASON_UNKNOWN:
    default:
        stringId = R.string.msg_channel_unavailable_unknown;
        break;
    }

    Toast.makeText(this, stringId, Toast.LENGTH_SHORT).show();
}