我创建了一个播放视频的小部件,并在contoroler中放置了视频文件和视频网络,但是播放3个视频时出现此错误
hint: [{
match: /:([\-+\w]+)$/,
search: function (keyword, callback) {
callback($.grep(emojis, function (item) {
return item.indexOf(keyword) === 0;
}));
},
template: function (item) {
var content = emojiUrls[item];
return '<img src="' + content + '" width="20" /> :' + item + ':';
},
content: function (item) {
var url = emojiUrls[item];
if (url) {
return $('<img />').attr('src', url).css('width', 20)[0];
}
return '';
}
},
{
mentions: ['jayden', 'sam', 'alvin', 'david'],
match: /\B@(\w*)$/,
search: function (keyword, callback) {
callback($.grep(this.mentions, function (item) {
return item.indexOf(keyword) == 0;
}));
},
content: function (item) {
return '@' + item;
}
}]
这是我在其他页面中使用它的小部件
Playback error.
E/ExoPlayerImplInternal(24720): com.google.android.exoplayer2.ExoPlaybackException
E/ExoPlayerImplInternal(24720): at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.throwDecoderInitError(MediaCodecRenderer.jav a:441)
E/ExoPlayerImplInternal(24720): at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodec(MediaCodecRenderer.java:428)
E/ExoPlayerImplInternal(24720): at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.onInputFormatChanged(MediaCodecRenderer.java:920)
E/ExoPlayerImplInternal(24720): at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.onInputFormatChanged(MediaCodecVideoRenderer.java:503)
E/ExoPlayerImplInternal(24720): at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:557)
E/ExoPlayerImplInternal(24720): at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:518)
E/ExoPlayerImplInternal(24720): at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:301)
E/ExoPlayerImplInternal(24720): at android.os.Handler.dispatchMessage(Handler.java:98)
E/ExoPlayerImplInternal(24720): at android.os.Looper.loop(Looper.java:154)
E/ExoPlayerImplInternal(24720): at android.os.HandlerThread.run(HandlerThread.java:61)
E/ExoPlayerImplInternal(24720): Caused by: com.google.android.exoplayer2.mediacodec.MediaCodecRenderer$DecoderInitializationException: Decoder init failed: OMX.qcom.video.decoder.avc, Format(1, null, video/avc, -1, null, [1280, 720, -1.0], [-1, -1])
E/ExoPlayerImplInternal(24720): ... 9 more
E/ExoPlayerImplInternal(24720): Caused by: android.media.MediaCodec$CodecException: Error 0xffffec77
E/ExoPlayerImplInternal(24720): at android.media.MediaCodec.native_configure(Native Method)
E/ExoPlayerImplInternal(24720): at android.media.MediaCodec.configure(MediaCodec.java:1884)
E/ExoPlayerImplInternal(24720): at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.configureCodec(MediaCodecVideoRenderer.java:450)
E/ExoPlayerImplInternal(24720): at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodec(MediaCodecRenderer.java:418)
E/ExoPlayerImplInternal(24720): ... 8 more
如何解决此错误,我在三个视频尝试后将视频文件和视频网络分配给它,我如何正确使用处理方法呢? 播放了三个视频,但我最多使用chewie软件包
答案 0 :(得分:1)
有点晚了,但这是解决方案。我拉了很多毛,终于得出结论。
“ pub.dev”中的“ video_player”库无法按预期管理资源。
如果在不处置控制器本身的情况下初始化新视频,则它会分配新资源,并且如果继续初始化3个以上视频,则手机的平台特定播放器(在这种情况下,“ exoplayer2”无法注销正确的错误消息)>
确保每次播放不同的视频时都已处置控制器并创建了新控制器。
编辑:
Future<void> playVideo() async{
VideoPlayerController _old = videoPlayerController;
if(mounted)
setState(() {
videoPlayerController = null;
});
videoPlayerController = VideoPlayerController.file(widget.videoFiles[itemIndex]);
await videoPlayerController.initialize();
if(mounted)
setState(() {duration = videoPlayerController.value.duration;});
await videoPlayerController.play();
Future.delayed(Duration(seconds: 1),(){
_old?.dispose();
});
}
答案 1 :(得分:0)
使用低于框架宽度和高度。 宽度 1280 和高度 720 我在flutter开发中使用了这帧视频并正确显示。