当您在android studio中放置任何视频链接时,它只会提示“无法播放此视频错误”
这是我的代码-
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
VideoView view=findViewById(R.id.videoView);
view.setVideoPath("android.resource//"+getPackageName()+"/"+ R.raw.demo);
MediaController control=new MediaController(this);
control.setAnchorView(view);
view.setMediaController(control);
view.start();
}
}
答案 0 :(得分:0)
VideoView vd = (VideoView) findViewById(R.id.videoView);
Uri uri = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.demo);
mc = new MediaController(this);
vd.setMediaController(mc);
vd.setVideoURI(uri);
vd.start();
您需要转换为Uri,然后尝试以下代码并分享您的反馈或分享错误日志(如果有的话)