android.media.MediaPlayer.OnPreparedListener Java Examples

The following examples show how to use android.media.MediaPlayer.OnPreparedListener. 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: ChatActivity.java    From BotLibre with Eclipse Public License 1.0 6 votes vote down vote up
public void playVideo(String video, boolean loop) {
	if (loop) {
		videoView.setOnPreparedListener(new OnPreparedListener() {
			@Override
			public void onPrepared(MediaPlayer mp) {
				mp.setLooping(true);
			}
		});
	}
	try {
		Uri videoUri = HttpGetVideoAction.fetchVideo(this, video);
		if (videoUri == null) {
			if (MainActivity.online) {
				videoUri = Uri.parse(MainActivity.connection.fetchImage(video).toURI().toString());
			}
		}
		videoView.setVideoURI(videoUri);
		videoView.start();
	} catch (Exception exception) {
		Log.wtf(exception.toString(), exception);
	}
}
 
Example #2
Source File: ChatActivity.java    From BotLibre with Eclipse Public License 1.0 6 votes vote down vote up
public void playVideo(String video, boolean loop) {
		if(!isPlaying){
			if (loop) {
				videoView.setOnPreparedListener(new OnPreparedListener() {
					@Override
					public void onPrepared(MediaPlayer mp) {
						mp.setLooping(true);
					}
				});
			}
			try {
				Uri videoUri = HttpGetVideoAction.fetchVideo(this, video);
				if (videoUri == null) {
					if(MainActivity.online){videoUri = Uri.parse(MainActivity.connection.fetchImage(video).toURI().toString());}
				}
				videoView.setVideoURI(videoUri);
				videoView.start();
			} catch (Exception exception) {
				Log.wtf(exception.toString(), exception);
			}
			isPlaying = true;//to Play this video only once.
		}
}
 
Example #3
Source File: MusicService.java    From Android-Basics-Codes with Artistic License 2.0 6 votes vote down vote up
public void play(){
		//�������״̬
		player.reset();
		try {
			//����Ҫ���ŵ�����
			player.setDataSource("sdcard/zxmzf.mp3");
//			player.setDataSource("http://192.168.1.100:8080/bzj.mp3");
			//ͬ��׼��
//			player.prepare();
			//�첽׼��
			player.prepareAsync();
			player.setOnPreparedListener(new OnPreparedListener() {
				
				//�첽׼�����ʱ���˷�������
				@Override
				public void onPrepared(MediaPlayer mp) {
					player.start();
					addTimer();
				}
			});
//			player.start();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} 
	}
 
Example #4
Source File: AvatarTestActivity.java    From BotLibre with Eclipse Public License 1.0 6 votes vote down vote up
public void playVideo(String video, boolean loop) {
	System.out.println("playVideo:" + video);
	if (loop) {
		videoView.setOnPreparedListener(new OnPreparedListener() {
			@Override
			public void onPrepared(MediaPlayer mp) {
				mp.setLooping(true);
			}
		});
	}
	try {
		Uri videoUri = HttpGetVideoAction.fetchVideo(this, video);
		System.out.println("videoUri:" + videoUri);
		if (videoUri == null) {
			videoUri = Uri.parse(MainActivity.connection.fetchImage(video).toURI().toString());
			System.out.println("null videoUri:" + videoUri);
		}
		videoView.setVideoURI(videoUri);
		videoView.start();
	} catch (Exception exception) {
		Log.wtf(exception.toString(), exception);
	}
}
 
Example #5
Source File: AvatarMediaActivity.java    From BotLibre with Eclipse Public License 1.0 6 votes vote down vote up
public void playVideo(String video, boolean loop) {
	if (loop) {
		videoView.setOnPreparedListener(new OnPreparedListener() {
			@Override
			public void onPrepared(MediaPlayer mp) {
				mp.setLooping(true);
			}
		});
	}
	try {
		Uri videoUri = HttpGetVideoAction.fetchVideo(this, video);
		if (videoUri == null) {
			videoUri = Uri.parse(MainActivity.connection.fetchImage(video).toURI().toString());
		}
		videoView.setVideoURI(videoUri);
		videoView.start();
	} catch (Exception exception) {
		Log.wtf(exception.toString(), exception);
	}
}
 
Example #6
Source File: ChatActivity.java    From BotLibre with Eclipse Public License 1.0 6 votes vote down vote up
public void playVideo(String video, boolean loop) {
	if (loop) {
		videoView.setOnPreparedListener(new OnPreparedListener() {
			@Override
			public void onPrepared(MediaPlayer mp) {
				mp.setLooping(true);
			}
		});
	}
	try {
		Uri videoUri = HttpGetVideoAction.fetchVideo(this, video);
		if (videoUri == null) {
			videoUri = Uri.parse(MainActivity.connection.fetchImage(video).toURI().toString());
		}
		videoView.setVideoURI(videoUri);
		videoView.start();
	} catch (Exception exception) {
		Log.wtf(exception.toString(), exception);
	}
}
 
Example #7
Source File: ChatActivity.java    From BotLibre with Eclipse Public License 1.0 6 votes vote down vote up
public void playVideo(String video, boolean loop) {
	if (loop) {
		videoView.setOnPreparedListener(new OnPreparedListener() {
			@Override
			public void onPrepared(MediaPlayer mp) {
				mp.setLooping(true);
			}
		});
	}
	try {
		Uri videoUri = HttpGetVideoAction.fetchVideo(this, video);
		if (videoUri == null) {
			if (MainActivity.online) {
				videoUri = Uri.parse(MainActivity.connection.fetchImage(video).toURI().toString());
			}
		}
		videoView.setVideoURI(videoUri);
		videoView.start();
	} catch (Exception exception) {
		Log.wtf(exception.toString(), exception);
	}
}
 
Example #8
Source File: AvatarTestActivity.java    From BotLibre with Eclipse Public License 1.0 6 votes vote down vote up
public void playVideo(String video, boolean loop) {
	System.out.println("playVideo:" + video);
	if (loop) {
		videoView.setOnPreparedListener(new OnPreparedListener() {
			@Override
			public void onPrepared(MediaPlayer mp) {
				mp.setLooping(true);
			}
		});
	}
	try {
		Uri videoUri = HttpGetVideoAction.fetchVideo(this, video);
		System.out.println("videoUri:" + videoUri);
		if (videoUri == null) {
			videoUri = Uri.parse(MainActivity.connection.fetchImage(video).toURI().toString());
			System.out.println("videoUri:" + videoUri);
		}
		videoView.setVideoURI(videoUri);
		videoView.start();
	} catch (Exception exception) {
		Log.wtf(exception.toString(), exception);
	}
}
 
Example #9
Source File: AvatarMediaActivity.java    From BotLibre with Eclipse Public License 1.0 6 votes vote down vote up
public void playVideo(String video, boolean loop) {
	if (loop) {
		videoView.setOnPreparedListener(new OnPreparedListener() {
			@Override
			public void onPrepared(MediaPlayer mp) {
				mp.setLooping(true);
			}
		});
	}
	try {
		Uri videoUri = HttpGetVideoAction.fetchVideo(this, video);
		if (videoUri == null) {
			videoUri = Uri.parse(MainActivity.connection.fetchImage(video).toURI().toString());
		}
		videoView.setVideoURI(videoUri);
		videoView.start();
	} catch (Exception exception) {
		Log.wtf(exception.toString(), exception);
	}
}
 
Example #10
Source File: GraphicMediaActivity.java    From BotLibre with Eclipse Public License 1.0 6 votes vote down vote up
public void playVideo(String video, boolean loop) {
	if (loop) {
		videoView.setOnPreparedListener(new OnPreparedListener() {
			@Override
			public void onPrepared(MediaPlayer mp) {
				mp.setLooping(true);
			}
		});
	}
	try {
		Uri videoUri = HttpGetVideoAction.fetchVideo(this, video);
		if (videoUri == null) {
			videoUri = Uri.parse(MainActivity.connection.fetchImage(video).toURI().toString());
		}
		videoView.setVideoURI(videoUri);
		videoView.start();
	} catch (Exception exception) {
		Log.wtf(exception.toString(), exception);
	}
}
 
Example #11
Source File: AvatarTestActivity.java    From BotLibre with Eclipse Public License 1.0 6 votes vote down vote up
public void playVideo(String video, boolean loop) {
	System.out.println("playVideo:" + video);
	if (loop) {
		videoView.setOnPreparedListener(new OnPreparedListener() {
			@Override
			public void onPrepared(MediaPlayer mp) {
				mp.setLooping(true);
			}
		});
	}
	try {
		Uri videoUri = HttpGetVideoAction.fetchVideo(this, video);
		System.out.println("videoUri:" + videoUri);
		if (videoUri == null) {
			videoUri = Uri.parse(MainActivity.connection.fetchImage(video).toURI().toString());
			System.out.println("videoUri:" + videoUri);
		}
		videoView.setVideoURI(videoUri);
		videoView.start();
	} catch (Exception exception) {
		Log.wtf(exception.toString(), exception);
	}
}
 
Example #12
Source File: AvatarMediaActivity.java    From BotLibre with Eclipse Public License 1.0 6 votes vote down vote up
public void playVideo(String video, boolean loop) {
	if (loop) {
		videoView.setOnPreparedListener(new OnPreparedListener() {
			@Override
			public void onPrepared(MediaPlayer mp) {
				mp.setLooping(true);
			}
		});
	}
	try {
		Uri videoUri = HttpGetVideoAction.fetchVideo(this, video);
		if (videoUri == null) {
			videoUri = Uri.parse(MainActivity.connection.fetchImage(video).toURI().toString());
		}
		videoView.setVideoURI(videoUri);
		videoView.start();
	} catch (Exception exception) {
		Log.wtf(exception.toString(), exception);
	}
}
 
Example #13
Source File: GraphicMediaActivity.java    From BotLibre with Eclipse Public License 1.0 6 votes vote down vote up
public void playVideo(String video, boolean loop) {
	if (loop) {
		videoView.setOnPreparedListener(new OnPreparedListener() {
			@Override
			public void onPrepared(MediaPlayer mp) {
				mp.setLooping(true);
			}
		});
	}
	try {
		Uri videoUri = HttpGetVideoAction.fetchVideo(this, video);
		if (videoUri == null) {
			videoUri = Uri.parse(MainActivity.connection.fetchImage(video).toURI().toString());
		}
		videoView.setVideoURI(videoUri);
		videoView.start();
	} catch (Exception exception) {
		Log.wtf(exception.toString(), exception);
	}
}
 
Example #14
Source File: ChatActivity.java    From BotLibre with Eclipse Public License 1.0 6 votes vote down vote up
public void playVideo(String video, boolean loop) {
	if (loop) {
		videoView.setOnPreparedListener(new OnPreparedListener() {
			@Override
			public void onPrepared(MediaPlayer mp) {
				mp.setLooping(true);
			}
		});
	}
	try {
		Uri videoUri = HttpGetVideoAction.fetchVideo(this, video);
		if (videoUri == null) {
			videoUri = Uri.parse(MainActivity.connection.fetchImage(video).toURI().toString());
		}
		videoView.setVideoURI(videoUri);
		videoView.start();
	} catch (Exception exception) {
		Log.wtf(exception.toString(), exception);
	}
}
 
Example #15
Source File: AvatarTestActivity.java    From BotLibre with Eclipse Public License 1.0 6 votes vote down vote up
public void playVideo(String video, boolean loop) {
	System.out.println("playVideo:" + video);
	if (loop) {
		videoView.setOnPreparedListener(new OnPreparedListener() {
			@Override
			public void onPrepared(MediaPlayer mp) {
				mp.setLooping(true);
			}
		});
	}
	try {
		Uri videoUri = HttpGetVideoAction.fetchVideo(this, video);
		System.out.println("videoUri:" + videoUri);
		if (videoUri == null) {
			videoUri = Uri.parse(MainActivity.connection.fetchImage(video).toURI().toString());
			System.out.println("videoUri:" + videoUri);
		}
		videoView.setVideoURI(videoUri);
		videoView.start();
	} catch (Exception exception) {
		Log.wtf(exception.toString(), exception);
	}
}
 
Example #16
Source File: AvatarMediaActivity.java    From BotLibre with Eclipse Public License 1.0 6 votes vote down vote up
public void playVideo(String video, boolean loop) {
	if (loop) {
		videoView.setOnPreparedListener(new OnPreparedListener() {
			@Override
			public void onPrepared(MediaPlayer mp) {
				mp.setLooping(true);
			}
		});
	}
	try {
		Uri videoUri = HttpGetVideoAction.fetchVideo(this, video);
		if (videoUri == null) {
			videoUri = Uri.parse(MainActivity.connection.fetchImage(video).toURI().toString());
		}
		videoView.setVideoURI(videoUri);
		videoView.start();
	} catch (Exception exception) {
		Log.wtf(exception.toString(), exception);
	}
}
 
Example #17
Source File: GraphicMediaActivity.java    From BotLibre with Eclipse Public License 1.0 6 votes vote down vote up
public void playVideo(String video, boolean loop) {
	if (loop) {
		videoView.setOnPreparedListener(new OnPreparedListener() {
			@Override
			public void onPrepared(MediaPlayer mp) {
				mp.setLooping(true);
			}
		});
	}
	try {
		Uri videoUri = HttpGetVideoAction.fetchVideo(this, video);
		if (videoUri == null) {
			videoUri = Uri.parse(MainActivity.connection.fetchImage(video).toURI().toString());
		}
		videoView.setVideoURI(videoUri);
		videoView.start();
	} catch (Exception exception) {
		Log.wtf(exception.toString(), exception);
	}
}
 
Example #18
Source File: AudioVideoVideoPlayActivity.java    From coursera-android with MIT License 5 votes vote down vote up
@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 #19
Source File: AudioVideoVideoPlayActivity.java    From coursera-android with MIT License 5 votes vote down vote up
@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 #20
Source File: FullscreenVideoView.java    From FullscreenVideoView with Apache License 2.0 4 votes vote down vote up
public void setOnPreparedListener(OnPreparedListener l) {
    if (mediaPlayer != null)
        this.preparedListener = l;
    else throw new RuntimeException("Media Player is not initialized");
}
 
Example #21
Source File: VideoView.java    From BotLibre with Eclipse Public License 1.0 4 votes vote down vote up
public void setOnPreparedListener(OnPreparedListener listener) {
	System.out.println("OnPreparedListe...");
}
 
Example #22
Source File: VideoView.java    From BotLibre with Eclipse Public License 1.0 4 votes vote down vote up
public void setOnPreparedListener(OnPreparedListener listener) {
	System.out.println("OnPreparedListe...");
}
 
Example #23
Source File: VideoViewH264mp4_4D.java    From letv with Apache License 2.0 4 votes vote down vote up
public void setOnPreparedListener(OnPreparedListener l) {
    this.mOnPreparedListener = l;
}
 
Example #24
Source File: VideoViewH264m3u8.java    From letv with Apache License 2.0 4 votes vote down vote up
public void setOnPreparedListener(OnPreparedListener l) {
    this.mOnPreparedListener = l;
}
 
Example #25
Source File: VideoViewH264LeMobile.java    From letv with Apache License 2.0 4 votes vote down vote up
public void setOnPreparedListener(OnPreparedListener l) {
    this.mOnPreparedListener = l;
}
 
Example #26
Source File: VideoViewH264m3u8Hw.java    From letv with Apache License 2.0 4 votes vote down vote up
public void setOnPreparedListener(OnPreparedListener l) {
    this.mOnPreparedListener = l;
}
 
Example #27
Source File: VideoViewH264m3u8HwLeMobile.java    From letv with Apache License 2.0 4 votes vote down vote up
public void setOnPreparedListener(OnPreparedListener l) {
    this.mOnPreparedListener = l;
}
 
Example #28
Source File: VideoViewH264mp4.java    From letv with Apache License 2.0 4 votes vote down vote up
public void setOnPreparedListener(OnPreparedListener l) {
    this.mOnPreparedListener = l;
}
 
Example #29
Source File: VideoViewTV.java    From letv with Apache License 2.0 4 votes vote down vote up
public void setOnPreparedListener(OnPreparedListener l) {
    this.mOnPreparedListener = l;
}
 
Example #30
Source File: VideoViewH264m3u8_4D.java    From letv with Apache License 2.0 4 votes vote down vote up
public void setOnPreparedListener(OnPreparedListener l) {
    this.mOnPreparedListener = l;
}