Java Code Examples for android.widget.MediaController#setEnabled()
The following examples show how to use
android.widget.MediaController#setEnabled() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VideoViewActivity.java From MediaPlayer-Extended with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_videoview); Utils.setActionBarSubtitleEllipsizeMiddle(this); mVideoView = (VideoView) findViewById(R.id.vv); mProgress = (ProgressBar) findViewById(R.id.progress); mMediaPlayerControl = mVideoView; //new MediaPlayerDummyControl(); mMediaController = new MediaController(this); mMediaController.setAnchorView(findViewById(R.id.container)); mMediaController.setMediaPlayer(mMediaPlayerControl); mMediaController.setEnabled(false); mProgress.setVisibility(View.VISIBLE); // Init video playback state (will eventually be overwritten by saved instance state) mVideoUri = getIntent().getData(); mVideoPosition = 0; mVideoPlaybackSpeed = 1; mVideoPlaying = false; }
Example 2
Source File: SpectaculumDemoBaseActivity.java From Spectaculum with Apache License 2.0 | 5 votes |
/** * Creates a media controller and attaches it to the activity. * This method is for activities that contain a video player. * @param mediaPlayerControl the control interface, e.g. a video view */ public void initMediaController(MediaController.MediaPlayerControl mediaPlayerControl) { mMediaController = new MediaController(this); mMediaController.setAnchorView(findViewById(R.id.container)); mMediaController.setMediaPlayer(mediaPlayerControl); mMediaController.setEnabled(false); }
Example 3
Source File: PlayerActivity.java From android-tv-leanback with Apache License 2.0 | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_player); View root = findViewById(R.id.root); mediaController = new MediaController(this); //overscan safe on 1980 * 1080 TV mediaController.setPadding(48, 27, 48, 27); mediaController.setAnchorView(root); shutterView = findViewById(R.id.shutter); surfaceView = (VideoSurfaceView) findViewById(R.id.surface_view); surfaceView.getHolder().addCallback(this); SampleSource sampleSource = new FrameworkSampleSource(this, Uri.parse(url), /* headers */ null, RENDERER_COUNT); // Build the track renderers videoRenderer = new MediaCodecVideoTrackRenderer(sampleSource, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT); TrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource); // Setup the player player = ExoPlayer.Factory.newInstance(RENDERER_COUNT, 1000, 5000); player.addListener(this); // Build the player controls mediaController.setMediaPlayer(new PlayerControl(player)); mediaController.setEnabled(true); player.prepare(videoRenderer, audioRenderer); }
Example 4
Source File: PlayerActivity.java From android-tv-leanback with Apache License 2.0 | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_player); View root = findViewById(R.id.root); mediaController = new MediaController(this); //overscan safe on 1980 * 1080 TV mediaController.setPadding(48, 27, 48, 27); mediaController.setAnchorView(root); shutterView = findViewById(R.id.shutter); surfaceView = (VideoSurfaceView) findViewById(R.id.surface_view); surfaceView.getHolder().addCallback(this); SampleSource sampleSource = new FrameworkSampleSource(this, Uri.parse(url), /* headers */ null, RENDERER_COUNT); // Build the track renderers videoRenderer = new MediaCodecVideoTrackRenderer(sampleSource, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT); TrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource); // Setup the player player = ExoPlayer.Factory.newInstance(RENDERER_COUNT, 1000, 5000); player.addListener(this); // Build the player controls mediaController.setMediaPlayer(new PlayerControl(player)); mediaController.setEnabled(true); player.prepare(videoRenderer, audioRenderer); }
Example 5
Source File: AudioVideoVideoPlayActivity.java From coursera-android with MIT License | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // Get a reference to the VideoView mVideoView = (VideoView) findViewById(R.id.videoViewer); // Add a Media controller to allow forward/reverse/pause/resume final MediaController mMediaController = new MediaController( AudioVideoVideoPlayActivity.this, true); mMediaController.setEnabled(false); mVideoView.setMediaController(mMediaController); mVideoView .setVideoURI(Uri .parse("android.resource://course.examples.AudioVideo.VideoPlay/raw/moon")); // Add an OnPreparedListener to enable the MediaController once the video is ready mVideoView.setOnPreparedListener(new OnPreparedListener() { @Override public void onPrepared(MediaPlayer mp) { mMediaController.setEnabled(true); } }); }
Example 6
Source File: AudioVideoVideoPlayActivity.java From coursera-android with MIT License | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // Get a reference to the VideoView mVideoView = findViewById(R.id.videoViewer); // Add a Media controller to allow forward/reverse/pause/resume final MediaController mMediaController = new MediaController( AudioVideoVideoPlayActivity.this, true); mMediaController.setEnabled(false); mVideoView.setMediaController(mMediaController); mVideoView .setVideoURI(Uri .parse("android.resource://" + getPackageName() + "/raw/moon")); // Add an OnPreparedListener to enable the MediaController once the video is ready mVideoView.setOnPreparedListener(new OnPreparedListener() { @Override public void onPrepared(MediaPlayer mp) { mMediaController.setEnabled(true); } }); }
Example 7
Source File: VitamioMedia.java From Vitamio-Cordova-Plugin with MIT License | 4 votes |
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); if (!io.vov.vitamio.LibsChecker.checkVitamioLibs(this)) return; requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); extras = getIntent().getExtras(); // handle extras if (extras == null) { wrapItUp(RESULT_CANCELED, "Error: No options provided"); } else { if (extras.containsKey("isStreaming")) { isStreaming = extras.getBoolean("isStreaming"); } if (extras.containsKey("shouldAutoClose")) { mShouldAutoClose = extras.getBoolean("shouldAutoClose"); } mMediaType = extras.getString("type"); if (mMediaType == null) mMediaType = MEDIA_TYPE_VIDEO; mMediaPlayer = new MediaPlayer(this); mMediaController = new MediaController(this, !isStreaming); mMediaController.setMediaPlayer(this); mMediaPlayer.setOnBufferingUpdateListener(this); mMediaPlayer.setOnCompletionListener(this); mMediaPlayer.setOnErrorListener(this); mMediaPlayer.setOnPreparedListener(this); mMediaPlayer.setOnVideoSizeChangedListener(this); setVolumeControlStream(AudioManager.STREAM_MUSIC); RelativeLayout relLayout = new RelativeLayout(this); if (extras.containsKey("bgColor")) { try { bgColor = Color.parseColor(extras.getString("bgColor")); } catch (Exception e) { Log.v(TAG, "Error parsing color"); Log.e(TAG, e.toString()); bgColor = DEFAULT_BG_COLOR; } } relLayout.setBackgroundColor(bgColor); RelativeLayout.LayoutParams relLayoutParam = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT); relLayoutParam.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); mMediaView = new SurfaceView(this); mMediaView.setLayoutParams(relLayoutParam); relLayout.addView(mMediaView); mProgressBar = new ProgressBar(this); mProgressBar.setIndeterminate(true); mProgressBar.setVisibility(View.VISIBLE); RelativeLayout.LayoutParams pblp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); pblp.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); mProgressBar.setLayoutParams(pblp); relLayout.addView(mProgressBar); mProgressBar.bringToFront(); mMediaController.setAnchorView(relLayout); mMediaController.setEnabled(true); if (mMediaType.equalsIgnoreCase(MEDIA_TYPE_AUDIO)) { mMediaView.setBackgroundColor(bgColor); if (extras.containsKey("bgImage")) { if (extras.containsKey("bgImageScaleType")) { String scaleType = extras.getString("bgImageScaleType"); if (scaleType.equalsIgnoreCase("fit")) { bgImageScaleType = ImageView.ScaleType.FIT_CENTER; } else if (scaleType.equalsIgnoreCase("stretch")) { bgImageScaleType = ImageView.ScaleType.FIT_XY; } else { bgImageScaleType = ImageView.ScaleType.CENTER; } } bgImage = new ImageView(this); new ImageLoadTask(extras.getString("bgImage"), this).execute(null, null); RelativeLayout.LayoutParams bgImageLayoutParam = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT); bgImageLayoutParam.addRule(RelativeLayout.CENTER_IN_PARENT); bgImage.setLayoutParams(bgImageLayoutParam); bgImage.setScaleType(bgImageScaleType); relLayout.addView(bgImage); } } setContentView(relLayout, relLayoutParam); holder = mMediaView.getHolder(); holder.addCallback(this); holder.setFormat(PixelFormat.RGBA_8888); } }
Example 8
Source File: VideoPlayerActivity.java From AndroidDemoProjects with Apache License 2.0 | 4 votes |
protected void setupMediaController() { mMediaController = new MediaController( this ); mMediaController.setEnabled(true); mMediaController.show(); mMediaController.setMediaPlayer( mVideoView ); }