Krishna Krishna - 1 month ago 14
Android Question

I am not able to play video from https link

I'm using Media Player in my Android application. The videos from http link is playing in all versions of android, but the https link is playing only in Android 4.1.2, but in lower versions it is not playing. Showing following error..

java.io.IOException: Prepare failed.: status=0x1 Error(1,-18).


I'm using the following code

MediaPlayerplayer = new MediaPlayer();
player.setOnPreparedListener(this);
player.setOnCompletionListener(this);
player.setOnBufferingUpdateListener(this);
player.setOnSeekCompleteListener(this);
player.setScreenOnWhilePlaying(true);
player.setDisplay(holder);

try {
String videoUrl = getIntent().getExtras().get("url").toString();
File mediaFile = new File(fileName);
if (mediaFile.exists()) {
FileInputStream fi = new FileInputStream(mediaFile);
player.setDataSource(fi.getFD());
}
else{
player.setDataSource(videoUrl);
}

Answer

Android versions above 3.1 only supports HTTPS media files. See the official link.