use of com.google.android.libraries.cast.companionlibrary.widgets.MiniController in project Shuttle by timusus.
the class VideoCastControllerActivity method loadAndSetupViews.
private void loadAndSetupViews() {
mPauseDrawable = getResources().getDrawable(R.drawable.ic_pause_circle_white_80dp);
mPlayDrawable = getResources().getDrawable(R.drawable.ic_play_circle_white_80dp);
mStopDrawable = getResources().getDrawable(R.drawable.ic_stop_circle_white_80dp);
mPageView = findViewById(R.id.pageview);
mPlayPause = (ImageButton) findViewById(R.id.play_pause_toggle);
mLiveText = (TextView) findViewById(R.id.live_text);
mStart = (TextView) findViewById(R.id.start_text);
mEnd = (TextView) findViewById(R.id.end_text);
mSeekbar = (SeekBar) findViewById(R.id.seekbar);
mLine2 = (TextView) findViewById(R.id.textview2);
mLoading = (ProgressBar) findViewById(R.id.progressbar1);
mControllers = findViewById(R.id.controllers);
mClosedCaptionIcon = (ImageButton) findViewById(R.id.cc);
mSkipNext = (ImageButton) findViewById(R.id.next);
mSkipPrevious = (ImageButton) findViewById(R.id.previous);
mPlaybackControls = findViewById(R.id.playback_controls);
((MiniController) findViewById(R.id.miniController1)).setCurrentVisibility(false);
setClosedCaptionState(CC_DISABLED);
mPlayPause.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
try {
mListener.onPlayPauseClicked(v);
} catch (TransientNetworkDisconnectionException e) {
LOGE(TAG, "Failed to toggle playback due to temporary network issue", e);
Utils.showToast(VideoCastControllerActivity.this, R.string.ccl_failed_no_connection_trans);
} catch (NoConnectionException e) {
LOGE(TAG, "Failed to toggle playback due to network issues", e);
Utils.showToast(VideoCastControllerActivity.this, R.string.ccl_failed_no_connection);
} catch (Exception e) {
LOGE(TAG, "Failed to toggle playback due to other issues", e);
Utils.showToast(VideoCastControllerActivity.this, R.string.ccl_failed_perform_action);
}
}
});
mSeekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
try {
if (mListener != null) {
mListener.onStopTrackingTouch(seekBar);
}
} catch (Exception e) {
LOGE(TAG, "Failed to complete seek", e);
finish();
}
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
try {
if (mListener != null) {
mListener.onStartTrackingTouch(seekBar);
}
} catch (Exception e) {
LOGE(TAG, "Failed to start seek", e);
finish();
}
}
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
mStart.setText(Utils.formatMillis(progress));
try {
if (mListener != null) {
mListener.onProgressChanged(seekBar, progress, fromUser);
}
} catch (Exception e) {
LOGE(TAG, "Failed to set the progress result", e);
}
}
});
mClosedCaptionIcon.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
try {
showTracksChooserDialog();
} catch (TransientNetworkDisconnectionException | NoConnectionException e) {
LOGE(TAG, "Failed to get the media", e);
}
}
});
mSkipNext.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
try {
mListener.onSkipNextClicked(v);
} catch (TransientNetworkDisconnectionException | NoConnectionException e) {
LOGE(TAG, "Failed to move to the next item in the queue", e);
}
}
});
mSkipPrevious.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
try {
mListener.onSkipPreviousClicked(v);
} catch (TransientNetworkDisconnectionException | NoConnectionException e) {
LOGE(TAG, "Failed to move to the previous item in the queue", e);
}
}
});
}
Aggregations