无法在VideoView中播放.mov文件

时间:2011-03-30 05:25:54

标签: android android-emulator

我正在开发一个应用程序,我必须从Internet播放视频。我正在使用videoview播放视频。

缓冲完成后,我的模拟器会向我显示一条错误,指出它无法播放视频。

我不知道错误是什么。

3 个答案:

答案 0 :(得分:6)

答案 1 :(得分:1)

我设法使用Vitamio库播放MOV文件和许多其他格式 - http://www.vitamio.org/en/,它实际上是几个视频解码器的包装器。

答案 2 :(得分:0)

Android不支持MOV格式,因此您可以使用此库。

我在项目中使用了这个库,它运行正常。

This library用于播放MOV格式的视频。

repositories {
jcenter()
}

dependencies {
implementation 'com.devbrackets.android:exomedia:4.3.0'
}

ExoMedia VideoView可以像其他任何Android视图一样添加到布局文件中。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

<com.devbrackets.android.exomedia.ui.widget.VideoView
    android:id="@+id/video_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:useDefaultControls="true"/>

</RelativeLayout>

在“活动”或“片段”中,您将其视为标准的Android VideoView

   private VideoView videoView;

    private void setupVideoView() {
    // Make sure to use the correct VideoView import
    videoView = (VideoView)findViewById(R.id.video_view);
    videoView.setOnPreparedListener(this);

    //For now we just picked an arbitrary item to play
 videoView.setVideoURI(Uri.parse("https://archive.org/download/Popeye_forPresident/Popeye_forPresident_512kb.mp4"));

@Override
public void onPrepared() {
    //Starts the video playback as soon as it is ready
    videoView.start();
}
相关问题