简体   繁体   English

在Android VideoView中显示mp4视频

[英]Display a mp4 video in Android VideoView

I have to show a MP4 video in a Android View. 我必须在Android视图中显示MP4视频。 So, in my layout I added this: 所以,在我的布局中我添加了这个:

<VideoView
        android:scrollbars="none"
        android:clickable="false"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:fitsSystemWindows="true"
        android:id="@+id/VideoView">
    </VideoView>

and in my activity I have: 在我的活动中,我有:

VideoView videoView = (VideoView) findViewById(R.id.VideoView);
String uriPath = "android.resource://"+getPackageName()+"/"+R.raw.cloud;
android.net.Uri uri = android.net.Uri.parse(uriPath);
videoView.setVideoURI(uri);
videoView.start();

But I always get an alert message: can't play this video and In the log message I see: E/MediaPlayer﹕ error (1, -38) 但我总是收到一条警告信息:无法播放此视频,在日志消息中我看到: E/MediaPlayer﹕ error (1, -38)

Some suggestions? 一些建议?

可能是您尝试的mp4视频的格式不支持结束。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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