简体   繁体   中英

Android VideoView cannot play video

I am trying to play video in Android. My widget is Kindle Fire so Android version is 2.3.4. Here is my code:

super.onCreate(savedInstanceState);
setContentView(R.layout.video);
Uri uri = Uri.parse(getIntent().getExtras().getString(VIDEO_URI));
MediaController mediaController = new MediaController(this);
VideoView videoView = (VideoView) findViewById(R.id.videoView);
videoView.setMediaController(mediaController);
videoView.setVideoURI(uri);
videoView.requestFocus();
videoView.start();

It shows dialog box with title

"Cannot play video"

and message

"An error occured while trying to play your video. The video may have been interrupted or is an unsupported format. Please try again."

The error message speaks for itself, the video format isn't supported by VideoView

Check the supported formats here: http://developer.android.com/guide/appendix/media-formats.html

You can try converting the video to the appropriate format using a video converter tool.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM