user1206335
user1206335

Reputation: 1

not able to run video file in emulator

Blockquote

can anyone suggest me how to give the path for playing a video, which video file is placed in locally and how to give the path for the video file which is stored in a website.here is the code below i tried but it is not working .

Blockquote

Upvotes: 0

Views: 193

Answers (1)

CoSeeWolf
CoSeeWolf

Reputation: 701

Alas, I could not see your code, but this is usually done using the setDataSource()-method of class MediaPlayer:

import android.media.MediaPlayer;
import java.io.File;
import java.io.FileInputStream;

MediaPlyer mediaPlayer = new MediaPlayer();
if (PLAY_FROM_FILE) {
  File mediaFile = new File("SOME_MEDIA_FILE");
  FileInputStream fis = new FileInputStream(mediaFile);
  mediaPlayer.setDataSource(fis.getFD());
}
else {
  //playing from the Web:
  mediaPlayer.setDataSource("http://exmaple.com/someVideo.mp4"); //works also for rtsp
}
mediaPlayer.start();

Upvotes: 1

Related Questions