开发者

How to add Uri in VideoView in android?

开发者 https://www.devze.com 2023-04-02 10:24 出处:网络
I am making simple videoview app from this link http://www.androidpeople.com/android-videoview-example

I am making simple videoview app from this link http://www.androidpeople.com/android-videoview-example

Now what should be the Uri here, i mean should i write path like: "C开发者_StackOverflow中文版:\Folder 1\file.mp4"

I am usin mp4 file from : http://www.mp4mobi.com/mp41315287045/Swept_Away_Bride.htm


see this example code

package com.video.tab;

import android.app.Activity;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.VideoView;

public class VideoPlayActivity extends Activity {

public void onCreate(Bundle bundle){
    super.onCreate(bundle);
    setContentView(R.layout.video);
    VideoView videoView = (VideoView)this.findViewById(R.id.videoView);
    final MediaController mc = new MediaController(this);
    videoView.setMediaController(new MediaController(this){
        /*public void hide()
        {
            mc.show();
        }*/
    });
   //videoView.setVideoURI(Uri.parse("http://www.androidbook.com/akc/filestorage/android/documentfiles/3389/movie.mp4"));
 videoView.setVideoPath("/sdcard/rabbit-and-snail.3gp");
   videoView.requestFocus();
   videoView.start();


}

}

in this ,uri locates the path of the ur video file.


Add the video file to your sdcard. Use: Uri.parse("file:/sdcard/videofilename")

Should work.


You can't Add File From your PC you have to put that .MP4 file to Raw folder or in your asset Folder.... 1st you Create Folder in Application's resource with Name = raw.

After That put file in raw folder... And than use this Code...

VideoView videoHolder = (VideoView) findViewById(R.id.web_Video);
    Uri videoUri = Uri.parse("android.resource://" + getPackageName() + "/"
            + R.raw.data);
0

精彩评论

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