Android 如何从原始文件夹在videoview中显示mp4视频
我正在尝试显示原始文件夹中的mp4视频。当应用程序打开时,视频应该自动在视频视图中播放。我希望视频在活动启动后立即开始(这是launcher活动)。我还希望视频循环,没有声音。下面是我的xmlAndroid 如何从原始文件夹在videoview中显示mp4视频,android,video,Android,Video,我正在尝试显示原始文件夹中的mp4视频。当应用程序打开时,视频应该自动在视频视图中播放。我希望视频在活动启动后立即开始(这是launcher活动)。我还希望视频循环,没有声音。下面是我的xml <VideoView android:id="@+id/launcherVideo" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_abo
<VideoView
android:id="@+id/launcherVideo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/linearLayout" />
}
这段代码目前除了在我运行应用程序时显示一个空白屏幕之外什么都不做,我不知道为什么。有人能帮忙吗?我看不到您使用这个变量,也看不到您如何定义
启动器
变量
String fileName = "android.resource://"+ getPackageName()+"/raw/launchervideo";
要从原始文件夹打开视频文件,您可以通过以下方式进行操作:
Uri uri = Uri.parse(fileName);
mvideo.setVideoURI(uri);
mvideo.start()
我希望它能帮助解决你的问题谢谢大家的帮助,我找到了答案
VideoView videoView = (VideoView) findViewById(R.id.launcherVideo);
Uri src = Uri.parse("android.resource://com.package/raw/video_name");
videoView.setVideoURI(src);
//videoView.setMediaController(new MediaController(this));
videoView.start();
这对我很有用。你应该在视图绑定之后调用它(在这行代码之后)
VideoView mvideo=(VideoView)findViewById(R.id.launchvideo)代码>
VideoView videoView = (VideoView) findViewById(R.id.launcherVideo);
Uri src = Uri.parse("android.resource://com.package/raw/video_name");
videoView.setVideoURI(src);
//videoView.setMediaController(new MediaController(this));
videoView.start();