Android 播放raw目录下的视频
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了Android 播放raw目录下的视频,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1894字,纯文字阅读大概需要3分钟。
内容图文
![Android 播放raw目录下的视频](/upload/InfoBanner/zyjiaocheng/1032/2f2c1dbf5c3d4901893fadad4c6161f1.jpg)
1、布局文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".bank_4.SP_01Activity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#0099CC"
android:gravity="center"
android:padding="5dp"
android:text="视频播放"
android:textColor="@android:color/black"
android:textSize="20dp" />
<ImageView
android:id="@+id/back_fh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/back" />
</RelativeLayout>
<VideoView
android:id="@+id/video"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
2、Activity文件
public class SP_01Activity extends AppCompatActivity {
private ImageView backFh;
private VideoView video;
private int[] lj = {R.raw.mv3, R.raw.mv3, R.raw.mv3, R.raw.mv3, R.raw.mv3};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_s_p_01);
init();
backFh.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SP_01Activity.this.finish();
}
});
Intent it = getIntent();
int id = it.getIntExtra("id", 0);
video.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + lj[id]));
MediaController controller = new MediaController(SP_01Activity.this);
video.setMediaController(controller);
video.start();
}
private void init() {
backFh = (ImageView) findViewById(R.id.back_fh);
video = (VideoView) findViewById(R.id.video);
}
}
3、注意
一、不加MediaController时
二、加MediaController时
可以暂停视频,查看进度条
内容总结
以上是互联网集市为您收集整理的Android 播放raw目录下的视频全部内容,希望文章能够帮你解决Android 播放raw目录下的视频所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。