Example usage for android.widget MediaController show

List of usage examples for android.widget MediaController show

Introduction

In this page you can find the example usage for android.widget MediaController show.

Prototype

public void show() 

Source Link

Document

Show the controller on screen.

Usage

From source file:jupiter.broadcasting.live.holo.JBPlayer.java

public void StartPlay(String path) {
    Progress(true);//from w  w  w.  j a  v a 2 s  .  c o  m
    if (mVideoCastManager.isConnected()) {
        //casting
        String[] tit_ep;
        tit_ep = title.split("[|]");
        MediaMetadata mMediaMetadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MOVIE);
        mMediaMetadata.putString(MediaMetadata.KEY_TITLE, live ? title : tit_ep[0]);
        mMediaMetadata.putString(MediaMetadata.KEY_SUBTITLE, live ? "streaming" : tit_ep[1]);
        mMediaMetadata.putString(MediaMetadata.KEY_STUDIO, "Jupiter Broadcasting");
        mMediaMetadata.addImage(new WebImage(
                Uri.parse("http://jb4.cdn.scaleengine.net/wp-content/themes/jb2014/images/logo.png")));
        mMediaMetadata.addImage(new WebImage(Uri.parse(pic)));
        MediaInfo mSelectedMedia = new MediaInfo.Builder(path)
                .setContentType(live ? "application/x-mpegURL" : "video")
                .setStreamType(live ? MediaInfo.STREAM_TYPE_LIVE : MediaInfo.STREAM_TYPE_BUFFERED)
                .setMetadata(mMediaMetadata).build();
        Progress(false);
        mVideoCastManager.startCastControllerActivity(this, mSelectedMedia, 0, true);
    } else {
        //local playback
        videoView = (VideoView) findViewById(R.id.videoView);
        videoView.setVideoPath(path);
        MediaController mediaController = new MediaController(this);
        mediaController.setAnchorView(videoView);
        videoView.setMediaController(mediaController);
        start = true;

        play.setEnabled(false);
        videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
            @Override
            public void onPrepared(MediaPlayer player) {

                Toast.makeText(getBaseContext(), "Started", Toast.LENGTH_LONG).show();
                Progress(false);
                int duration = videoView.getDuration();
                iView.setVisibility(View.GONE);
                videoView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                        LinearLayout.LayoutParams.WRAP_CONTENT));
            }
        });
        videoView.start();
        mediaController.show();
    }
}