Вопрос

I'm trying to play mp4 video from raw folder. It is working fine in native video player but when I tried to play it using vitamio then it did not work for me. Are there any way to run mp4 video from raw folder in android using vitamio library??

I used this code to run video from raw folder.

VideoView view = (VideoView)findViewById(R.id.videoView);
String path = "android.resource://" + getPackageName() + "/" + R.raw.video_file;
view.setVideoURI(Uri.parse(path));
view.start();
Это было полезно?

Решение 2

Vitamio does not support to play video from raw folder. They are working with it and hope in next release they will fix the bug. We can solve this problem just copying the video from raw to sd card.

Другие советы

Please try this code.

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>

I had use this vitamio library for no. of projects, but till today, i can asure tell you that vitamio is not supported raw data, you have to converted the data to some valid format to play the video. supported format are : rtsp,rtmp,http,ftp,https, , hope you will understand.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top