gpt4 book ai didi

android - VideoView 意外错误 : the video is not playing

转载 作者:行者123 更新时间:2023-11-29 00:45:11 26 4
gpt4 key购买 nike

我有一个主要 Activity 将字符串传递给下一个 Activity ,下一个 Activity 使用该字符串作为打开视频的 URL。但是,视频不会播放。

这是我的代码示例:

Bundle extras = getIntent().getExtras();
String MovieLink = (String) extras.get("video");
System.out.println(MovieLink);
VideoView videoView = (VideoView) findViewById(R.id.video);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
Uri video = Uri.parse(MovieLink);
videoView.setMediaController(mediaController);
videoView.setVideoURI(video);
videoView.start();

给出的错误:

07-19 15:31:21.857: INFO/StagefrightPlayer(85): setDataSource('landscape_1003_1_m601')
07-19 15:31:21.867: ERROR/MediaPlayer(10132): error (1, -2147483648)
07-19 15:31:21.907: ERROR/MediaPlayer(10132): Error (1,-2147483648)
07-19 15:31:21.907: DEBUG/VideoView(10132): Error: 1,-2147483648
07-19 15:31:22.347: INFO/ActivityManager(126): Displayed com.?.?/.VideoPlayer: +540ms

最佳答案

终于解决了我的问题!!

这是我的结果代码:)

super.onCreate(savedInstanceState);
setContentView(R.layout.video);

Resources res = getResources();

Bundle extras = getIntent().getExtras();
String MovieLink = (String) extras.get("video");
VideoView vd = (VideoView) findViewById(R.id.video);
String tmp = MovieLink.replace(".mp4", "");
int movieID = res.getIdentifier(tmp, "raw", getPackageName());
Uri uri = Uri.parse("android.resource://" + getPackageName() + "/"
+ movieID);
MediaController mc = new MediaController(this);
vd.setMediaController(mc);

vd.setVideoURI(uri);
vd.start();

关于android - VideoView 意外错误 : the video is not playing,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6748063/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com