1

我正在尝试从原始文件夹播放 mp4 视频。它在本机视频播放器中运行良好,但是当我尝试使用 vitamio 播放它时,它对我不起作用。有没有办法使用 vitamio 库从 android 的 raw 文件夹中运行 mp4 视频?

我使用此代码从原始文件夹运行视频。

VideoView view = (VideoView)findViewById(R.id.videoView);
String path = "android.resource://" + getPackageName() + "/" + R.raw.video_file;
view.setVideoURI(Uri.parse(path));
view.start();
4

3 回答 3

1

请尝试此代码。

mVideoView.setVideoPath("your path");
            mVideoView.setMediaController(new MediaController(
                    LibraryVideo.this));
            mVideoView.requestFocus();

            mVideoView
                    .setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
                        @Override
                        public void onPrepared(MediaPlayer mediaPlayer) {
                            Log.e("StartVideo", "OnPrepare");
                            mVideoView.start();
                        }
                    });

video_view.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<io.vov.vitamio.widget.CenterLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <io.vov.vitamio.widget.VideoView
        android:id="@+id/video_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true" />
</io.vov.vitamio.widget.CenterLayout>

</LinearLayout>
于 2013-07-16T09:20:43.467 回答
1

Vitamio 不支持从原始文件夹播放视频。他们正在使用它,并希望在下一个版本中修复这个错误。我们可以解决这个问题,只需将视频从 raw 复制到 sd 卡。

于 2013-09-05T06:08:00.337 回答
1

我没有使用这个 vitamio 库。项目,但直到今天,我可以肯定地告诉你,vitamio 不支持原始数据,你必须将数据转换为某种有效的格式才能播放视频。支持的格式有:rtsp,rtmp,http,ftp,https,,希望大家理解。

于 2014-07-10T17:19:25.523 回答