我想播放原始文件夹中的视频文件作为启动。但它不起作用。任何人都可以帮我解决这个问题。
这是我的代码
public class SplashActivity extends Activity implements OnCompletionListener{
private MediaController mc;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
VideoView vd = (VideoView) findViewById(R.id.VideoView);
Uri uri = Uri.parse("android.resource://" + getPackageName() + "/"+R.raw.sea);
//mc = new MediaController(this);
//vd.setMediaController(mc);
vd.requestFocus();
vd.setVideoURI(uri);
vd.start();
// vd.setOnCompletionListener(this);
}
public void onCompletion(MediaPlayer mp) {
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
finish();
}
我的布局是:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:gravity="center">
<VideoView android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:id="@+id/VideoView">
</VideoView>
< /LinearLayout>