开发者

Can't play .mov file in VideoView

I am developing an application in which I have to play video from Internet. I'm using videoview to play Video.

When buffering is complet开发者_如何学Pythoned, my emulator shows me an error which says that it can't play video.

I don't know what is the error.


I've managed to play MOV files and a lot of other formats using the Vitamio library - http://www.vitamio.org/en/, which is essentially a wrapper for several video decoders.


Android does not support MOV format so you can use this library.

I use this library in my project it is working fine.

This library for play MOV format videos.

repositories {
jcenter()
}

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

The ExoMedia VideoView can be added in your layout files like any other Android view.

<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>

While in your Activity or Fragment you treat it like a standard 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();
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜