Code example for MediaPlayer: Playing audio and video

Methods: preparesetDataSourcestart

0
	} 
	 
	 
	public void play(FileInputStream file) throws IllegalArgumentException, IllegalStateException, IOException
	{ 
		player.setDataSource(file.getFD());
		player.prepare();
		player.start();
	} 
	 
	public void stop() 
	{ 
		if (player.isPlaying()) {
			player.stop();
			for (Listener listener : listeners)
				listener.onStop();
		} 
	} 
 
	public void onCompletion(MediaPlayer mp) {
		stop();