Java Code Examples for android.media.MediaPlayer.OnPreparedListener

The following examples show how to use android.media.MediaPlayer.OnPreparedListener. These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: Android-Basics-Codes   Source File: MusicService.java    License: 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 2
Source Project: BotLibre   Source File: ChatActivity.java    License: 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 Project: BotLibre   Source File: AvatarTestActivity.java    License: 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 4
Source Project: BotLibre   Source File: AvatarMediaActivity.java    License: 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 5
Source Project: BotLibre   Source File: ChatActivity.java    License: 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 Project: BotLibre   Source File: ChatActivity.java    License: 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 7
Source Project: BotLibre   Source File: AvatarTestActivity.java    License: 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 8
Source Project: BotLibre   Source File: AvatarMediaActivity.java    License: 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 9
Source Project: BotLibre   Source File: GraphicMediaActivity.java    License: 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 Project: BotLibre   Source File: ChatActivity.java    License: 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 11
Source Project: BotLibre   Source File: AvatarTestActivity.java    License: 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 Project: BotLibre   Source File: AvatarMediaActivity.java    License: 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 Project: BotLibre   Source File: GraphicMediaActivity.java    License: 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 Project: BotLibre   Source File: ChatActivity.java    License: 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 Project: BotLibre   Source File: AvatarTestActivity.java    License: 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 Project: BotLibre   Source File: AvatarMediaActivity.java    License: 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 Project: BotLibre   Source File: GraphicMediaActivity.java    License: 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 Project: coursera-android   Source File: AudioVideoVideoPlayActivity.java    License: 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 Project: coursera-android   Source File: AudioVideoVideoPlayActivity.java    License: 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
public void setOnPreparedListener(OnPreparedListener l) {
}
 
Example 21
Source Project: letv   Source File: VideoViewH264m3u8.java    License: Apache License 2.0 4 votes vote down vote up
public void setOnPreparedListener(OnPreparedListener l) {
    this.mOnPreparedListener = l;
}
 
Example 22
Source Project: letv   Source File: VideoViewH264LeMobile.java    License: Apache License 2.0 4 votes vote down vote up
public void setOnPreparedListener(OnPreparedListener l) {
    this.mOnPreparedListener = l;
}
 
Example 23
Source Project: letv   Source File: VideoViewH264m3u8Hw.java    License: Apache License 2.0 4 votes vote down vote up
public void setOnPreparedListener(OnPreparedListener l) {
    this.mOnPreparedListener = l;
}
 
Example 24
Source Project: letv   Source File: VideoViewH264m3u8HwLeMobile.java    License: Apache License 2.0 4 votes vote down vote up
public void setOnPreparedListener(OnPreparedListener l) {
    this.mOnPreparedListener = l;
}
 
Example 25
Source Project: letv   Source File: VideoViewH264mp4.java    License: Apache License 2.0 4 votes vote down vote up
public void setOnPreparedListener(OnPreparedListener l) {
    this.mOnPreparedListener = l;
}
 
Example 26
Source Project: letv   Source File: VideoViewTV.java    License: Apache License 2.0 4 votes vote down vote up
public void setOnPreparedListener(OnPreparedListener l) {
    this.mOnPreparedListener = l;
}
 
Example 27
Source Project: letv   Source File: VideoViewH264m3u8_4D.java    License: Apache License 2.0 4 votes vote down vote up
public void setOnPreparedListener(OnPreparedListener l) {
    this.mOnPreparedListener = l;
}
 
Example 28
Source Project: letv   Source File: VideoViewH264LeMobile_4D.java    License: Apache License 2.0 4 votes vote down vote up
public void setOnPreparedListener(OnPreparedListener l) {
    this.mOnPreparedListener = l;
}
 
Example 29
Source Project: letv   Source File: VideoViewH264mp4_4D.java    License: Apache License 2.0 4 votes vote down vote up
public void setOnPreparedListener(OnPreparedListener l) {
    this.mOnPreparedListener = l;
}
 
Example 30
Source Project: letv   Source File: VideoViewH264m3u8Hw_4D.java    License: Apache License 2.0 4 votes vote down vote up
public void setOnPreparedListener(OnPreparedListener l) {
    this.mOnPreparedListener = l;
}