【问题标题】:How to run video from raw folder using vitamio?如何使用 vitamio 从原始文件夹运行视频?
【发布时间】:2013-07-16 07:09:21
【问题描述】:

我正在尝试从原始文件夹播放 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();

【问题讨论】:

  • 你为什么对 vitamio player 这么具体?
  • 因为我现在用的是vitamio播放器。那里有什么好的图书馆而不是本地图书馆?
  • 什么类型的错误?请发布您的视频查看代码,因为我对 vitamio 库有很好的了解...谢谢
  • @MaheshKavathiya 我刚刚添加了这段代码。请帮帮我。

标签: android android-videoview vitamio


【解决方案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>

【讨论】:

  • @Sharifur Ra​​hman 请尝试此代码并重播这是否有效。?
【解决方案2】:

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

【讨论】:

    【解决方案3】:

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

    【讨论】:

      猜你喜欢
      • 2012-06-26
      • 1970-01-01
      • 1970-01-01
      • 2011-03-03
      • 1970-01-01
      • 1970-01-01
      • 2018-04-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多