MediaPlayer setDisplay - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for MediaPlayer setDisplay method.

This code example shows how to use the following methods: setDisplay
        mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
    } 
 
    @Override 
    public void setDisplay(SurfaceHolder holder) {
        mMediaPlayer.setDisplay(holder);
        if (holder != null)
            holder.addCallback(mSurfaceCallback);
    } 
 
    private SurfaceHolder.Callback mSurfaceCallback = new Callback() {
        public void surfaceChanged(SurfaceHolder holder, int format, int width, 
                int height) { 
        } 
 
        public void surfaceCreated(SurfaceHolder holder) { 
        } 
 
        public void surfaceDestroyed(SurfaceHolder holder) { 
            if (mMediaPlayer != null) { 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: prepare, setDataSource, setDisplay, start
	@Override 
	public void surfaceCreated(SurfaceHolder holder) {
		// TODO Auto-generated method stub 
		 
		try { 
			mMediaPlayer = new MediaPlayer();
			mMediaPlayer.setDataSource(videoPath);
			mMediaPlayer.setDisplay(holder);
			mMediaPlayer.prepare();
			mMediaPlayer.start();
		} catch (IllegalArgumentException e) {
			// TODO Auto-generated catch block 
			e.printStackTrace();
		} catch (SecurityException e) {
			// TODO Auto-generated catch block 
			e.printStackTrace();
		} catch (IllegalStateException e) {
			// TODO Auto-generated catch block 
			e.printStackTrace();
		} catch (IOException e) {
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: prepareAsync, setAudioStreamType, setDataSource, setDisplay, setOnPreparedListener
		Log.d(TAG, "Play video on full, path: " + path);
		File videoFile = new File(path);
        FileInputStream fis;
		try { 
			fis = new FileInputStream(videoFile);
	        mMediaPlayer.setDataSource(fis.getFD());
	        mMediaPlayer.setDisplay(sHolder);
	         
	        mMediaPlayer.prepareAsync();
	         
	        mMediaPlayer.setOnPreparedListener(new OnPreparedListener() {
				@Override 
				public void onPrepared(MediaPlayer mp) {
					onCancel(); 
					mMediaPlayer.start();
					setSurfaceViewScale(); 
					mMediaPlayer.seekTo(position);
					mc.setMediaPlayer(getMediaPlayerControl());
					mc.setAnchorView(video);
					 

7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: isPlaying, prepare, reset, setAudioStreamType, setDataSource
		 
 
		buttonPlayVideo.setOnClickListener(new Button.OnClickListener() {
			public void onClick(View arg0) {
				pausing = false;
				if (mediaPlayer.isPlaying()) {
					mediaPlayer.reset();
				} 
				mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
				mediaPlayer.setDisplay(holderVideo);
				try { 
					mediaPlayer.setDataSource("/sdcard/video/movie1080.mp4");
					mediaPlayer.prepare();
 
					// mediaPlayer.prepareAsync(); 
				} catch (IllegalArgumentException e) {
					e.printStackTrace();
				} catch (IllegalStateException e) {
					e.printStackTrace();
				} catch (IOException e) {

6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: prepare, setAudioStreamType, setDataSource, setDisplay, setOnBufferingUpdateListener

Related MediaPlayer setDisplay Questions & Answers:

setDisplay Method Overview
Sets the SurfaceHolder to use for displaying the video portion of the media.
See Code Examples for other Android MediaPlayer Methods: