android.widget.MediaController Java Examples
The following examples show how to use
android.widget.MediaController.
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: SimpleVideoStream.java From cordova-plugin-streaming-media with MIT License | 8 votes |
private void play() { mProgressBar.setVisibility(View.VISIBLE); Uri videoUri = Uri.parse(mVideoUrl); try { mVideoView.setOnCompletionListener(this); mVideoView.setOnPreparedListener(this); mVideoView.setOnErrorListener(this); mVideoView.setVideoURI(videoUri); mMediaController = new MediaController(this); mMediaController.setAnchorView(mVideoView); mMediaController.setMediaPlayer(mVideoView); if (!mControls) { mMediaController.setVisibility(View.GONE); } mVideoView.setMediaController(mMediaController); } catch (Throwable t) { Log.d(TAG, t.toString()); } }
Example #2
Source File: VideoViewDemo.java From codeexamples-android with Eclipse Public License 1.0 | 6 votes |
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.videoview); mVideoView = (VideoView) findViewById(R.id.surface_view); if (path == "") { // Tell the user to provide a media file URL/path. Toast.makeText( VideoViewDemo.this, "Please edit VideoViewDemo Activity, and set path" + " variable to your media file URL/path", Toast.LENGTH_LONG).show(); } else { /* * Alternatively,for streaming media you can use * mVideoView.setVideoURI(Uri.parse(URLstring)); */ mVideoView.setVideoPath(path); mVideoView.setMediaController(new MediaController(this)); mVideoView.requestFocus(); } }
Example #3
Source File: PreviewFragment.java From kolabnotes-android with GNU Lesser General Public License v3.0 | 6 votes |
void displayAudio(ActiveAccount account, String noteUID,Attachment attachment){ musicView.setVisibility(View.VISIBLE); try { nowPlayingView.setText(attachment.getFileName()); mediaPlayer = new MediaPlayer(); mediaPlayer.setOnPreparedListener(this); mediaController = new MediaController(getActivity()); mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); mediaPlayer.setDataSource(getActivity(), attachmentRepository.getUriFromAttachment(account.getAccount(), account.getRootFolder(), noteUID, attachment)); mediaPlayer.prepare(); mediaController.show(0); }catch (IOException e){ Toast.makeText(getActivity(), R.string.attachment_not_previewable, Toast.LENGTH_LONG).show(); } }
Example #4
Source File: PlayerActivity.java From 4pdaClient-plus with Apache License 2.0 | 6 votes |
private void playVideo(VideoItem parseResult, Uri pResult) { try { createActionMenu(parseResult); mSeekTo = mVideoView.getCurrentPosition(); mVideoView.setVideoURI(pResult); mVideoView.setMediaController(new MediaController(this)); mVideoView.setKeepScreenOn(true); mVideoView.requestFocus(); mVideoView.start(); } catch (Throwable ex) { AppLog.toastE(getContext(), ex); } }
Example #5
Source File: PlayerActivity.java From android-tv-leanback with Apache License 2.0 | 6 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_player); mVideo = (Video)getIntent().getSerializableExtra(Video.INTENT_EXTRA_VIDEO); 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); preparePlayer(); }
Example #6
Source File: PlayerActivity.java From android-tv-leanback with Apache License 2.0 | 6 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_player); mVideo = (Video) getIntent().getSerializableExtra(Video.INTENT_EXTRA_VIDEO); 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); preparePlayer(); }
Example #7
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 #8
Source File: VideoPlayer.java From appinventor-extensions with Apache License 2.0 | 6 votes |
/** * Creates a new VideoPlayer component. * * @param container */ public VideoPlayer(ComponentContainer container) { super(container); container.$form().registerForOnDestroy(this); videoView = new ResizableVideoView(container.$context()); videoView.setMediaController(new MediaController(container.$context())); videoView.setOnCompletionListener(this); videoView.setOnErrorListener(this); videoView.setOnPreparedListener(this); // add the component to the designated container container.$add(this); // set a default size container.setChildWidth(this, ComponentConstants.VIDEOPLAYER_PREFERRED_WIDTH); container.setChildHeight(this, ComponentConstants.VIDEOPLAYER_PREFERRED_HEIGHT); // Make volume buttons control media, not ringer. container.$form().setVolumeControlStream(AudioManager.STREAM_MUSIC); sourcePath = ""; }
Example #9
Source File: ViewVideoActivity.java From ResearchStack with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); super.setContentView(R.layout.rsb_activity_video_viewer); videoView = (AssetVideoView) findViewById(R.id.videoView); MediaController mediaController = new MediaController(this, false); mediaController.setAnchorView(videoView); videoView.setMediaController(mediaController); try { String videoPath = getIntent().getStringExtra(KEY_RELATIVE_PATH); AssetFileDescriptor afd = getAssets().openFd(videoPath); videoView.setVideoDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength()); videoView.start(); } catch (IOException e) { throw new RuntimeException(e); } }
Example #10
Source File: VideoPlayerActivity.java From ScrollGalleryView with MIT License | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); String url = getIntent().getExtras().getString(Constants.URL); setContentView(R.layout.video_fragment); final VideoView videoView = (VideoView) findViewById(R.id.videoView); videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { @Override public void onPrepared(MediaPlayer mp) { View progress = findViewById(R.id.videoProgress); progress.setVisibility(View.GONE); videoView.requestFocus(); MediaController vidControl = new MediaController(VideoPlayerActivity.this); vidControl.setAnchorView(videoView); videoView.setMediaController(vidControl); videoView.start(); } }); videoView.setVideoURI(Uri.parse(url)); }
Example #11
Source File: LiveStuff.java From goprohero with MIT License | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_live_stuff); myVideoView = (VideoView)this.findViewById(R.id.videoView); MediaController mc = new MediaController(this); myVideoView.setMediaController(mc); urlStream = "http://10.5.5.9:8080/live/amba.m3u8"; runOnUiThread(new Runnable() { @Override public void run() { myVideoView.setVideoURI(Uri.parse(urlStream)); myVideoView.start(); } }); }
Example #12
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 #13
Source File: WXVideoView.java From ucar-weex-core with Apache License 2.0 | 5 votes |
private synchronized void createVideoView() { if(mVideoView != null){ return; } Context context = getContext(); WXVideoView video = new WXVideoView(context); FrameLayout.LayoutParams videoLayoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT); videoLayoutParams.gravity = Gravity.CENTER; video.setLayoutParams(videoLayoutParams); addView(video, 0);//first child video.setOnErrorListener(mOnErrorListener); video.setOnPreparedListener(mOnPreparedListener); video.setOnCompletionListener(mOnCompletionListener); video.setOnVideoPauseListener(mVideoPlayListener); MediaController controller = new MediaController(context); controller.setAnchorView(this); video.setMediaController(controller); controller.setMediaPlayer(video); mMediaController = controller; mVideoView = video; if(mUri != null) { setVideoURI(mUri); } }
Example #14
Source File: VideoViewH264LeMobile_4D.java From letv with Apache License 2.0 | 5 votes |
public void setMediaController(MediaController controller) { if (this.mMediaController != null) { this.mMediaController.hide(); } this.mMediaController = controller; attachMediaController(); }
Example #15
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 #16
Source File: PictureVideoPlayActivity.java From PictureSelector with Apache License 2.0 | 5 votes |
@Override protected void initWidgets() { super.initWidgets(); videoPath = getIntent().getStringExtra(PictureConfig.EXTRA_VIDEO_PATH); boolean isExternalPreview = getIntent().getBooleanExtra (PictureConfig.EXTRA_PREVIEW_VIDEO, false); if (TextUtils.isEmpty(videoPath)) { LocalMedia media = getIntent().getParcelableExtra(PictureConfig.EXTRA_MEDIA_KEY); if (media == null || TextUtils.isEmpty(media.getPath())) { finish(); return; } videoPath = media.getPath(); } if (TextUtils.isEmpty(videoPath)) { closeActivity(); return; } ibLeftBack = findViewById(R.id.pictureLeftBack); mVideoView = findViewById(R.id.video_view); tvConfirm = findViewById(R.id.tv_confirm); mVideoView.setBackgroundColor(Color.BLACK); iv_play = findViewById(R.id.iv_play); mMediaController = new MediaController(this); mVideoView.setOnCompletionListener(this); mVideoView.setOnPreparedListener(this); mVideoView.setMediaController(mMediaController); ibLeftBack.setOnClickListener(this); iv_play.setOnClickListener(this); tvConfirm.setOnClickListener(this); tvConfirm.setVisibility(config.selectionMode == PictureConfig.SINGLE && config.enPreviewVideo && !isExternalPreview ? View.VISIBLE : View.GONE); }
Example #17
Source File: VideoActivity.java From ml-authentication with Apache License 2.0 | 5 votes |
@Override protected void onStart() { Log.i(getClass().getName(), "onStart"); super.onStart(); Bundle extras = getIntent().getExtras(); long videoId = extras.getLong(EXTRA_KEY_VIDEO_ID); Log.i(getClass().getName(), "videoId: " + videoId); Video video = videoDao.load(videoId); File videoFile = MultimediaHelper.getFile(video); Log.i(getClass().getName(), "videoFile: " + videoFile); videoView.setVideoPath(videoFile.getAbsolutePath()); videoView.setMediaController(new MediaController(this)); videoView.start(); videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { @Override public void onCompletion(MediaPlayer mediaPlayer) { Log.i(getClass().getName(), "onCompletion"); // TODO: track VideoCompletedEvent Intent loadingIntent = new Intent(getApplicationContext(), LoadingActivity.class); // String letter = "a"; // TODO: fetch dynamically // loadingIntent.putExtra(LoadingActivity.EXTRA_KEY_LETTER, letter); startActivity(loadingIntent); finish(); } }); }
Example #18
Source File: VideoViewH264m3u8_4D.java From letv with Apache License 2.0 | 5 votes |
public void setMediaController(MediaController controller) { if (this.mMediaController != null) { this.mMediaController.hide(); } this.mMediaController = controller; attachMediaController(); }
Example #19
Source File: VideoPlayer.java From fitness_Android with Apache License 2.0 | 5 votes |
private void loadVideo() { // String path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/movie.mp4"; String uri = "android.resource://" + getPackageName() + "/"; switch (tag) { case 1: duration = "8"; uri += R.raw.base; break; case 2: duration = "9"; uri += R.raw.enhance; break; case 3: duration = "11"; uri += R.raw.acme; break; } // 本地视频 // videoView.setVideoPath(path); // 网络视频 // videoView.setVideoURI(Uri.parse("http://www.runoob.com/try/demo_source/movie.mp4")); videoView.setVideoURI(Uri.parse(uri)); mediaController = new MediaController(this); videoView.setMediaController(mediaController); mediaController.setMediaPlayer(videoView); videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { @Override public void onCompletion(MediaPlayer mp) { videoStop = true; saveTrainRecord(); } }); videoView.start(); }
Example #20
Source File: VideoPlayer.java From deltachat-android with GNU General Public License v3.0 | 5 votes |
private void initializeVideoViewControls(@NonNull VideoView videoView) { MediaController mediaController = new MediaController(getContext()); mediaController.setAnchorView(videoView); mediaController.setMediaPlayer(videoView); videoView.setMediaController(mediaController); }
Example #21
Source File: TextureVideoView.java From texturevideoview with Apache License 2.0 | 5 votes |
public void setMediaController(MediaController controller) { if (mMediaController != null) { mMediaController.hide(); } mMediaController = controller; attachMediaController(); }
Example #22
Source File: VideoView.java From GifAssistant with Apache License 2.0 | 5 votes |
public void setMediaController(MediaController controller) { if (mMediaController != null) { mMediaController.hide(); } mMediaController = controller; attachMediaController(); }
Example #23
Source File: PlayerActivity.java From android-tv-leanback with Apache License 2.0 | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.d(TAG, "onCreate()"); setContentView(R.layout.activity_player); mVideo = (Video) getIntent().getSerializableExtra(Video.INTENT_EXTRA_VIDEO); // We will use the PlaybackOverlayFragment when running on TV. mIsOnTv = MyUtil.isRunningInTvMode(this); if (mIsOnTv) { // On TV we will use the resource in layout-televsion mPlaybackOverlayFragment = (PlaybackOverlayFragment) getFragmentManager().findFragmentById(R.id.playback_controls_fragment); } else { shutterView = findViewById(R.id.shutter); 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); } surfaceView = (VideoSurfaceView) findViewById(R.id.surface_view); surfaceView.getHolder().addCallback(this); preparePlayer(); }
Example #24
Source File: MainActivity.java From texturevideoview with Apache License 2.0 | 5 votes |
private void initVideoView() { mVideoView.setVideoPath(getVideoPath()); mVideoView.setMediaController(new MediaController(this)); mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { @Override public void onPrepared(final MediaPlayer mp) { startVideoPlayback(); startVideoAnimation(); } }); }
Example #25
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 #26
Source File: AssetVideoView.java From ResearchStack with Apache License 2.0 | 5 votes |
public void setMediaController(MediaController controller) { if (mMediaController != null) { mMediaController.hide(); } mMediaController = controller; attachMediaController(); }
Example #27
Source File: VideoPlayer.java From Silence with GNU General Public License v3.0 | 5 votes |
private void initializeVideoViewControls(@NonNull VideoView videoView) { MediaController mediaController = new MediaController(getContext()); mediaController.setAnchorView(videoView); mediaController.setMediaPlayer(videoView); videoView.setMediaController(mediaController); }
Example #28
Source File: VideoView.java From Alite with GNU General Public License v3.0 | 5 votes |
public void setMediaController(MediaController controller) { if (mMediaController != null) { mMediaController.hide(); } mMediaController = controller; attachMediaController(); }
Example #29
Source File: VideoActivity.java From ml-authentication with Apache License 2.0 | 5 votes |
@Override protected void onStart() { Log.i(getClass().getName(), "onStart"); super.onStart(); Bundle extras = getIntent().getExtras(); long videoId = extras.getLong(EXTRA_KEY_VIDEO_ID); Log.i(getClass().getName(), "videoId: " + videoId); Video video = videoDao.load(videoId); File videoFile = MultimediaHelper.getFile(video); Log.i(getClass().getName(), "videoFile: " + videoFile); videoView.setVideoPath(videoFile.getAbsolutePath()); videoView.setMediaController(new MediaController(this)); videoView.start(); videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { @Override public void onCompletion(MediaPlayer mediaPlayer) { Log.i(getClass().getName(), "onCompletion"); // TODO: track VideoCompletedEvent Intent loadingIntent = new Intent(getApplicationContext(), LoadingActivity.class); // String letter = "a"; // TODO: fetch dynamically // loadingIntent.putExtra(LoadingActivity.EXTRA_KEY_LETTER, letter); startActivity(loadingIntent); finish(); } }); }
Example #30
Source File: AudioPlaybackManager.java From AndroidRecording with Apache License 2.0 | 5 votes |
public AudioPlaybackManager(Context ctx, VisualizerView visualizerView, PlaybackHandler playbackHandler) { this.playerManager = new MediaPlayerManager(); this.playerManager.getPlayer().setOnPreparedListener(this); this.playerManager.getPlayer().setOnCompletionListener(this); this.visualizerView = visualizerView; this.visualizerView.link(this.playerManager.getPlayer()); this.visualizerView.getViewTreeObserver().addOnGlobalLayoutListener(this); this.controller = new MediaController(ctx); this.controller.setMediaPlayer(this); this.controller.setAnchorView(visualizerView); this.playbackHandler = playbackHandler; }