Open AbhinaiVatsal opened 3 years ago
Any suggestions to fix this issue !!
See if you can visit the url in the browser and try to play in the browser. The package def works so check your url, if that url works then copy paste the example exactly and hardcode your url and see if that works then work from there to make it do what you need.
@jeremiahlukus Tried playing in the browser, it is playing without any issue and also tried hard coding the URL in app and check, it is still giving the same error.
Any update on this issue? It seems related to multiple players on screen? I am able to load the url if it is hard coded. But unable to if im selecting from a list of videos
any update on this?
Any updates?
@AbhinaiVatsal first of all, the code that you posted is not properly formatted. Please do so before I can assist you further.
Second, you should not create the ChewieController
within your build
method. Controller initialization belongs in either initState
or didUpdateWidget
in order to reinitialize the player if the URL changed during rebuilds.
Third, I would need a standalone example for me to purse this further, since the code that you posted isn't usable from a technical support perspective.
Please reach out again once you do. Thanks.
I am trying to play a video using the URL, I am getting the following error while playing.
E/MediaCodecVideoRenderer( 4831): Video codec error E/MediaCodecVideoRenderer( 4831): java.lang.IllegalStateException E/MediaCodecVideoRenderer( 4831): at android.media.MediaCodec.native_dequeueInputBuffer(Native Method) E/MediaCodecVideoRenderer( 4831): at android.media.MediaCodec.dequeueInputBuffer(MediaCodec.java:2855) E/MediaCodecVideoRenderer( 4831): at com.google.android.exoplayer2.mediacodec.SynchronousMediaCodecAdapter.dequeueInputBufferIndex(SynchronousMediaCodecAdapter.java:93) E/MediaCodecVideoRenderer( 4831): at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.feedInputBuffer(MediaCodecRenderer.java:1209) E/MediaCodecVideoRenderer( 4831): at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:845) E/MediaCodecVideoRenderer( 4831): at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:945) E/MediaCodecVideoRenderer( 4831): at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:478) E/MediaCodecVideoRenderer( 4831): at android.os.Handler.dispatchMessage(Handler.java:102) E/MediaCodecVideoRenderer( 4831): at android.os.Looper.loop(Looper.java:223) E/MediaCodecVideoRenderer( 4831): at android.os.HandlerThread.run(HandlerThread.java:67) E/ExoPlayerImplInternal( 4831): Playback error E/ExoPlayerImplInternal( 4831): com.google.android.exoplayer2.ExoPlaybackException: MediaCodecVideoRenderer error, index=0, format=Format(2, null, null, video/avc, avc1.64002A, -1, null, [1920, 1080, 60.0], [-1, -1]), format_supported=YES E/ExoPlayerImplInternal( 4831): at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:555) E/ExoPlayerImplInternal( 4831): at android.os.Handler.dispatchMessage(Handler.java:102) E/ExoPlayerImplInternal( 4831): at android.os.Looper.loop(Looper.java:223) E/ExoPlayerImplInternal( 4831): at android.os.HandlerThread.run(HandlerThread.java:67) E/ExoPlayerImplInternal( 4831): Caused by: com.google.android.exoplayer2.video.MediaCodecVideoDecoderException: Decoder failed: c2.android.avc.decoder E/ExoPlayerImplInternal( 4831): at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.createDecoderException(MediaCodecVideoRenderer.java:1410) E/ExoPlayerImplInternal( 4831): at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:864) E/ExoPlayerImplInternal( 4831): at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:945) E/ExoPlayerImplInternal( 4831): at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:478) E/ExoPlayerImplInternal( 4831): ... 3 more E/ExoPlayerImplInternal( 4831): Caused by: java.lang.IllegalStateException E/ExoPlayerImplInternal( 4831): at android.media.MediaCodec.native_dequeueInputBuffer(Native Method) E/ExoPlayerImplInternal( 4831): at android.media.MediaCodec.dequeueInputBuffer(MediaCodec.java:2855) E/ExoPlayerImplInternal( 4831): at com.google.android.exoplayer2.mediacodec.SynchronousMediaCodecAdapter.dequeueInputBufferIndex(SynchronousMediaCodecAdapter.java:93) E/ExoPlayerImplInternal( 4831): at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.feedInputBuffer(MediaCodecRenderer.java:1209) E/ExoPlayerImplInternal( 4831): at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:845) E/ExoPlayerImplInternal( 4831): ... 5 more E/ExoPlayerImplInternal( 4831): Disable failed. E/ExoPlayerImplInternal( 4831): java.lang.IllegalStateException E/ExoPlayerImplInternal( 4831): at android.media.MediaCodec.native_flush(Native Method) E/ExoPlayerImplInternal( 4831): at android.media.MediaCodec.flush(MediaCodec.java:2298) E/ExoPlayerImplInternal( 4831): at com.google.android.exoplayer2.mediacodec.SynchronousMediaCodecAdapter.flush(SynchronousMediaCodecAdapter.java:160) E/ExoPlayerImplInternal( 4831): at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.flushCodec(MediaCodecRenderer.java:912) E/ExoPlayerImplInternal( 4831): at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.flushOrReleaseCodec(MediaCodecRenderer.java:905) E/ExoPlayerImplInternal( 4831): at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.onDisabled(MediaCodecRenderer.java:761) E/ExoPlayerImplInternal( 4831): at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.onDisabled(MediaCodecVideoRenderer.java:483) E/ExoPlayerImplInternal( 4831): at com.google.android.exoplayer2.BaseRenderer.disable(BaseRenderer.java:176) E/ExoPlayerImplInternal( 4831): at com.google.android.exoplayer2.ExoPlayerImplInternal.disableRenderer(ExoPlayerImplInternal.java:1609) E/ExoPlayerImplInternal( 4831): at com.google.android.exoplayer2.ExoPlayerImplInternal.resetInternal(ExoPlayerImplInternal.java:1351) E/ExoPlayerImplInternal( 4831): at com.google.android.exoplayer2.ExoPlayerImplInternal.stopInternal(ExoPlayerImplInternal.java:1314) E/ExoPlayerImplInternal( 4831): at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:571) E/ExoPlayerImplInternal( 4831): at android.os.Handler.dispatchMessage(Handler.java:102) E/ExoPlayerImplInternal( 4831): at android.os.Looper.loop(Looper.java:223) E/ExoPlayerImplInternal( 4831): at android.os.HandlerThread.run(HandlerThread.java:67)
Here is my code :
import 'dart:io'; import 'package:chewie/chewie.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:video_player/video_player.dart';
const ASPECT_RATIO = 3 / 2;
class VideoPlayerWidget extends StatefulWidget { const VideoPlayerWidget({this.url});
final String url;
@override _VideoPlayerWidgetState createState() => _VideoPlayerWidgetState(); }
class _VideoPlayerWidgetState extends State {
ChewieController _chewieController;
VideoPlayerController _controller;
@override
void initState() {
_controller = VideoPlayerController.network(widget.url);
super.initState();
}
@override Widget build(BuildContext context) { if (_controller != null) { _chewieController = ChewieController( showControlsOnInitialize: false, videoPlayerController: _controller, aspectRatio: ASPECT_RATIO, autoInitialize: true, showOptions: false, autoPlay: true, deviceOrientationsAfterFullScreen: [DeviceOrientation.portraitUp], materialProgressColors: ChewieProgressColors( playedColor: Colors.blue, handleColor: Colors.blue, backgroundColor: Colors.white, bufferedColor: Colors.blue[100], ), placeholder: const StatusHandlerWidget(FETCHING_DATA), ); } return Scaffold( appBar: AppBar(), backgroundColor: Colors.white, body: Center( child: Chewie( controller: _chewieController, ), ), ); }
@override void dispose() { _controller.dispose(); _chewieController.dispose(); super.dispose(); } }
It won't give the error if I download the same video file and play using
_controller = VideoPlayerController.file(file);