Play video stream using Vitamio library in android?

时光怂恿深爱的人放手 提交于 2019-12-01 04:03:16

问题


I'm using the library Vitamio to play rtsp live stream. I tried to run the demo videoview class play rtsp link as follows:

http://117.103.224.75:1935/live/definst/VTCHD3/VTCHD3_840x480_1200kbps.stream/playlist.m3u8

==> Result : it run but quality very bad, load videos very low and picture in video are not sharp and sound are not heard. I don't know what to do to make it run smooth and picture is sharp. Please help me this problem ! Thank very much !

this is my code :

private String path="http://117.103.224.75:1935/live/_definst_/VTCHD3/VTCHD3_840x480_1200kbps.stream/playlist.m3u8";

private ProgressDialog prodlg;
private VideoView mVideoView;

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    if (!LibsChecker.checkVitamioLibs(this))
        return;
    setContentView(R.layout.videoview);
    prodlg=new ProgressDialog(this);
    prodlg.setIcon(R.drawable.ic_launcher);
    prodlg.setMessage("wating...");
    prodlg.show();

    mVideoView = (VideoView) findViewById(R.id.surface_view);

    if (path == "") {
        // Tell the user to provide a media file URL/path.
        Toast.makeText(VideoViewDemo.this, "Please edit VideoViewDemo Activity, and set path" + " variable to your media file URL/path", Toast.LENGTH_LONG).show();
        return;
    } else {
        /*
         * Alternatively,for streaming media you can use
         * mVideoView.setVideoURI(Uri.parse(URLstring));
         */
        mVideoView.setVideoPath(path);
        mVideoView.setVideoQuality(MediaPlayer.VIDEOQUALITY_HIGH);
        mVideoView.setBufferSize(2048);
        mVideoView.requestFocus();
        mVideoView.start();
        mVideoView.setMediaController(new MediaController(this));

        mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
            @Override
            public void onPrepared(MediaPlayer mediaPlayer) {
                // optional need Vitamio 4.0
                prodlg.dismiss();
                mediaPlayer.setPlaybackSpeed(1.0f);
            }
        });
    }

}

I use android platforms 4.0 api 14 play demo : this is my screen picture demo


回答1:


If you want to use Vitamio library for displaying video etc, then first of all download Vitamio Library from here Free download Vitamio Library. then include both "ZI" and "InitActivtiy" (which is inside the Vitamio lib) Library in your current project (right click project-->include library-->), then write this line of code

 if (!io.vov.vitamio.LibsChecker.checkVitamioLibs(this))
        return;

after Oncreate Method() like in my project.

 @Override
protected void onCreate(Bundle savedInstanceState) 
 {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    if (!io.vov.vitamio.LibsChecker.checkVitamioLibs(this)) //it will check the include library of Vitamio
        return;

after that put this line of code in Androidmanifest.xml file

  <!-- (((((( Vitamio Library including in manifest file )))))) -->
   <activity android:name="io.vov.vitamio.activity.InitActivity" 
       android:configChanges="orientation|screenSize|smallestScreenSize|keyboard|keyboardHidden"
       android:launchMode="singleTop"
        android:theme="@android:style/Theme.NoTitleBar"
        android:windowSoftInputMode="stateAlwaysHidden"/>     

Now its a time to display your video using VideoView etc.



来源:https://stackoverflow.com/questions/22551033/play-video-stream-using-vitamio-library-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!