Android MediaController - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android MediaController class.

This code example shows how to use the following methods:setAnchorView, setEnabled, setMediaPlayer, show
        } 
 
        private void attachMediaController() { 
            if (mMediaController != null) {
                if (!mMediaControllerAttached) {
                    mMediaController.setMediaPlayer(this);
                    View anchorView = this.getParent() instanceof View ?
                            (View)this.getParent() : this;
                    mMediaController.setAnchorView(anchorView);
                    mMediaController.setEnabled(true);
                    mMediaControllerAttached = true;
                    mTimer.scheduleAtFixedRate(mImageTask, 0, 1000 / mFrameRate);
                } 
                mMediaController.show();
            } 
        } 
 
        @Override 
        public boolean onTouchEvent(MotionEvent event) {
            attachMediaController(); 
8
CodeRank
This code example shows how to use the following methods:
        mVideoView.onResume();
    } 
 
    private View createView() {
        mVideoView = new VideoDumpView(this);
        mVideoView.setMediaController(new MediaController(context));
 
        LinearLayout mainLayout = new LinearLayout(this);
        mainLayout.addView(mVideoView, new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.MATCH_PARENT));
 
        return mainLayout;
    } 
 
    protected void onStop() { 
        if (mVideoView != null) {
            if (mVideoView.isPlaying()) {
                mVideoView.stopPlayback();
            } 
7
CodeRank
This code example shows how to use the following methods:setAnchorView, setEnabled, setMediaPlayer, show
 
    // MediaPlayer.OnPreparedListener 
    public void onPrepared(MediaPlayer mp)
    { 
        Log.i(TAG, "CallPlayer onPrepared about to construct MediaController object");
        controller = new MediaController(this, true); // enble fast forward
        //controller = new MyMediaController(this, true); // enble fast forward 
        //controller = new MediaController(getApplicationContext()); // why is useing 'this' different than 'getApplicationContext()' ? 
 
        controller.setMediaPlayer(aplayer);
        controller.setAnchorView(anchor);
        controller.setEnabled(true);
        controller.show(0); //aplayer.getDuration());
         
        // controller disappears after 3 seconds no matter what... set timer to handle re-showing it? 
    } 
 
    public boolean onInfo(MediaPlayer mp, int what, int extra)
    { 
        Log.i(TAG, "CallPlayer onInfo with what " + what + " extra " + extra);
7
CodeRank
This code example shows how to use the following methods:setBackgroundColor, setAnchorView, setEnabled, setMediaPlayer, show
This code example shows how to use the following methods:isShowing, show
	} 
 
	@Override 
	public void onWindowFocusChanged(boolean hasFocus) {
		super.onWindowFocusChanged(hasFocus);
		if(hasFocus && begin && !controller.isShowing()) {
			begin = false;
			controller.show(0);
			mediaplayer.start();
		} 
	} 
 
	@Override 
	public void onDestroy() { 
		super.onDestroy(); 
		mediaplayer.release();
	} 
 
	///////////////////// 
	// Set up the view // 
6
CodeRank
This code example shows how to use the following methods:
        mVideoView.onResume();
    } 
 
    private View createView() {
        mVideoView = new VideoDumpView(this);
        mVideoView.setMediaController(new MediaController(context));
 
        LinearLayout mainLayout = new LinearLayout(this);
        mainLayout.addView(mVideoView, new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.MATCH_PARENT));
 
        return mainLayout;
    } 
 
    protected void onStop() { 
        if (mVideoView != null) {
            if (mVideoView.isPlaying()) {
                mVideoView.stopPlayback();
            } 
7
CodeRank
This code example shows how to use the following methods:setAnchorView, setEnabled, setMediaPlayer
        attachMediaController(); 
    } 
 
    private void attachMediaController() { 
        if (mMediaController != null) {
            mMediaController.setMediaPlayer(this);
            mMediaController.setAnchorView(mVideoSurfaceView);
            mMediaController.setEnabled(false);
        } 
    } 
 
    @CalledByNative 
    public void openVideo() { 
        if (mSurfaceHolder != null) {
            mCurrentState = STATE_IDLE;
            setMediaController(new MediaController(getChromeActivity()));
            if (mNativeContentVideoView != 0) {
                nativeUpdateMediaMetadata(mNativeContentVideoView);
            } 
            mCurrentBufferPercentage = 0;
            if (mNativeContentVideoView != 0) {
6
CodeRank
This code example shows how to use the following methods:show
		setupVideoView(); 
	} 
 
	@Override 
	public boolean onTouchEvent(MotionEvent event) {
		if(mediacontroller != null) mediacontroller.show(0);
		return super.onTouchEvent(event);
	} 
 
	private void setupVideoView() { 
		VideoView videoview = (VideoView) findViewById(R.id.videoview);
		videoview.setKeepScreenOn(true);
		if(videouri != null) videoview.setVideoURI(videouri);
		else videoview.setVideoPath(videopath);
		mediacontroller = new MediaController(this);
		mediacontroller.setAnchorView(videoview);
		videoview.setMediaController(mediacontroller);
		if (videoview.canSeekForward())
			videoview.seekTo(videoview.getDuration()/2);
		videoview.start();
6
CodeRank
This code example shows how to use the following methods:hide, isShowing
		mediaPlayer.start();
	} 
 
	@Override 
	public boolean onTouchEvent(MotionEvent ev) {
		if (controller.isShowing()) {
			controller.hide();
		} else { 
			controller.show();
		} 
		return false; 
	} 
} 
5
CodeRank
This code example shows how to use the following methods:show
		setupVideoView(); 
	} 
 
	@Override 
	public boolean onTouchEvent(MotionEvent event) {
		if(mediacontroller != null) mediacontroller.show(0);
		return super.onTouchEvent(event);
	} 
 
	private void setupVideoView() { 
		VideoView videoview = (VideoView) findViewById(R.id.videoview);
		videoview.setKeepScreenOn(true);
		if(videouri != null) videoview.setVideoURI(videouri);
		else videoview.setVideoPath(videopath);
		mediacontroller = new MediaController(this);
		mediacontroller.setAnchorView(videoview);
		videoview.setMediaController(mediacontroller);
		if (videoview.canSeekForward())
			videoview.seekTo(videoview.getDuration()/2);
		videoview.start();
6
CodeRank

Related Android MediaController Questions & Answers:

See Code Examples for Android MediaController Methods: