Here are the examples of the java api class com.google.android.exoplayer.util.PlayerControl taken from open source projects.
1. PlaybackControlLayer#updatePlayPauseButton()
Project: google-media-framework-android
File: PlaybackControlLayer.java
File: PlaybackControlLayer.java
/** * Change the icon of the play/pause button to indicate play or pause based on the state of the * video player. */ public void updatePlayPauseButton() { PlayerControl playerControl = getLayerManager().getControl(); if (view == null || pausePlayButton == null || playerControl == null) { return; } if (playerControl.isPlaying()) { pausePlayButton.setImageResource(R.drawable.ic_action_pause_large); } else { pausePlayButton.setImageResource(R.drawable.ic_action_play_large); } }
2. PlaybackControlLayer#setPlayPause()
Project: google-media-framework-android
File: PlaybackControlLayer.java
File: PlaybackControlLayer.java
/** * Play or pause the player. * @param shouldPlay If true, then the player starts playing. If false, the player pauses. */ public void setPlayPause(boolean shouldPlay) { PlayerControl playerControl = getLayerManager().getControl(); if (playerControl == null) { return; } if (shouldPlay) { playerControl.start(); } else { playerControl.pause(); } updatePlayPauseButton(); }
3. PlaybackControlLayer#updateProgress()
Project: google-media-framework-android
File: PlaybackControlLayer.java
File: PlaybackControlLayer.java
/** * Adjust the position of the action bar to reflect the progress of the video. */ public int updateProgress() { PlayerControl playerControl = getLayerManager().getControl(); if (playerControl == null || isSeekbarDragging) { return 0; } int position = playerControl.getCurrentPosition(); int duration = playerControl.getDuration(); if (seekBar != null) { if (duration > 0) { long pos = 1000L * position / duration; seekBar.setProgress((int) pos); } int percent = playerControl.getBufferPercentage(); seekBar.setSecondaryProgress(percent * 10); } if (endTime != null) { endTime.setText(stringForTime(duration)); } if (currentTime != null) { currentTime.setText(stringForTime(position)); } return position; }
4. PlaybackControlLayer#doToggleFullscreen()
Project: google-media-framework-android
File: PlaybackControlLayer.java
File: PlaybackControlLayer.java
/** * Fullscreen mode will rotate to landscape mode, hide the action bar, hide the navigation bar, * hide the system tray, and make the video player take up the full size of the display. * The developer who is using this function must ensure the following: * * <p>1) Inside the android manifest, the activity that uses the video player has the attribute * android:configChanges="orientation". * * <p>2) Other views in the activity (or fragment) are * hidden (or made visible) when this method is called. */ public void doToggleFullscreen() { // If there is no callback for handling fullscreen, don't do anything. if (fullscreenCallback == null) { return; } PlayerControl playerControl = getLayerManager().getControl(); if (playerControl == null) { return; } Activity activity = getLayerManager().getActivity(); FrameLayout container = getLayerManager().getContainer(); if (isFullscreen) { fullscreenCallback.onReturnFromFullscreen(); activity.setRequestedOrientation(savedOrientation); // Make the status bar and navigation bar visible again. activity.getWindow().getDecorView().setSystemUiVisibility(0); container.setLayoutParams(originalContainerLayoutParams); fullscreenButton.setImageResource(R.drawable.ic_action_full_screen); isFullscreen = false; } else { fullscreenCallback.onGoToFullscreen(); savedOrientation = activity.getResources().getConfiguration().orientation; activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN); // Whenever the status bar and navigation bar appear, we want the playback controls to // appear as well. activity.getWindow().getDecorView().setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() { @Override public void onSystemUiVisibilityChange(int i) { // this is the case, then we show the playback controls as well (by calling show()). if ((i & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) { show(); } } }); container.setLayoutParams(Util.getLayoutParamsBasedOnParent(container, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); fullscreenButton.setImageResource(R.drawable.ic_action_return_from_full_screen); isFullscreen = true; } }