我不知道为什么无法在VideoView
中播放视频。
我收到的消息是:
我也为模拟器创建了SD卡。我需要将SD卡放在SDK的特定文件夹中吗?请给出意见。
这是布局:
<?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:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="videoplayer.oxbir.com.videplayer.ActivityMain">
<VideoView
android:id="@+id/videoView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.9"/>
<LinearLayout/>
代码如下:
package videoplayer.oxbir.com.videplayer;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.VideoView;
import android.net.Uri;
public class ActivityMain extends AppCompatActivity {
ImageView btnPause, btnStop, btnPlay;
SeekBar seekBar;
VideoView videoView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
videoView = (VideoView)findViewById(R.id.videoView);
//String Buffer = "android.resource://com.gsm_developers.videoview_gsm/"+R.raw.dirin;
String Buffer = "android.resource://com.android.AndroidVideoPlayer/"+R.raw.dirin;
Uri uri = Uri.parse(Buffer);
videoView.setVideoURI(uri);
videoView.start();
}
}
答案 0 :(得分:1)
尝试使用以下代码替换您的VideoView
:
<VideoView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/videoView"
android:layout_gravity="center" />