I didn't use a real device, I was working on emulator. (Problem Solved)
I am developing a live stream video application. I have so many live stream URLs which have *.m3u8 postfix.
When I start the app, I can hear only sound but no video displaying. Video display area is always dark.
I am waiting for your helpful suggestions to solve my problem.
Regards.
Some of my code:
public class MainActivity extends Activity {
private static ProgressDialog progressDialog;
String videourl = "URL/playlist.m3u8";
VideoView videoView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
videoView = (VideoView) findViewById(R.id.video_View);
progressDialog = ProgressDialog.show(MainActivity.this, "", "Buffering video...", true);
progressDialog.setCancelable(false);
PlayVideo();
}
private void PlayVideo() {
try {
getWindow().setFormat(PixelFormat.TRANSLUCENT);
MediaController mediaController = new MediaController(MainActivity.this);
mediaController.setAnchorView(videoView);
Uri video = Uri.parse(videourl);
videoView.setMediaController(mediaController);
videoView.setVideoURI(video);
videoView.requestFocus();
videoView.setVisibility(View.VISIBLE);
videoView.setOnPreparedListener(new OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {
progressDialog.dismiss();
videoView.start();
}
});
} catch (Exception e) {
progressDialog.dismiss();
System.out.println("Video Play Error :" + e.toString());
finish();
}
}
}
layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<VideoView
android:id="@+id/video_View"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
</VideoView>
</LinearLayout>