Code example for MediaPlayer: Playing audio and video

Methods: prepareresetsetDataSourcestart

0
public class MDService extends Service {
	private MediaPlayer mp = new MediaPlayer();
	private MDSInterface.Stub coreRemoteServiceStub = new MDSInterface.Stub() {
		public void playSong(String file) throws RemoteException { 
			try{ 
				mp.reset(); 
				mp.setDataSource(file); 
				mp.prepare(); 
				mp.start(); 
			}catch(Exception e){ 
				System.out.println(e.toString()); 
			} 
		} 
		public void stopSong() throws RemoteException { 
			try{ 
				mp.stop(); 
			}catch(Exception e){ 
				System.out.println(e.toString()); 
			} 
		}