I’m using video player controller to play video .I’m getting video URL from API and then I’m initializing that using video player controller . When I upload video from my app after uploading i’m getting url that is playing in my app .but when i’m using video url that is uploaded from admin(angular) its not playing in my app.
error
E/ExoPlayerImplInternal(13211): Playback error
E/ExoPlayerImplInternal(13211): com.google.android.exoplayer2.ExoPlaybackException: Source error
E/ExoPlayerImplInternal(13211): at com.google.android.exoplayer2.ExoPlayerImplInternal.handleIoException(ExoPlayerImplInternal.java:644)
E/ExoPlayerImplInternal(13211): at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:614)
E/ExoPlayerImplInternal(13211): at android.os.Handler.dispatchMessage(Handler.java:102)
E/ExoPlayerImplInternal(13211): at android.os.Looper.loop(Looper.java:257)
E/ExoPlayerImplInternal(13211): at android.os.HandlerThread.run(HandlerThread.java:67)
E/ExoPlayerImplInternal(13211): Caused by: com.google.android.exoplayer2.ParserException: Missing CodecPrivate for codec V_MPEG4/ISO/AVC
E/ExoPlayerImplInternal(13211): at com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor$Track.getCodecPrivate(MatroskaExtractor.java:2548)
E/ExoPlayerImplInternal(13211): at com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor$Track.initializeOutput(MatroskaExtractor.java:2074)
E/ExoPlayerImplInternal(13211): at com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor.endMasterElement(MatroskaExtractor.java:812)
E/ExoPlayerImplInternal(13211): at com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor$InnerEbmlProcessor.endMasterElement(MatroskaExtractor.java:1947)
E/ExoPlayerImplInternal(13211): at com.google.android.exoplayer2.extractor.mkv.DefaultEbmlReader.read(DefaultEbmlReader.java:88)
E/ExoPlayerImplInternal(13211): at com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor.read(MatroskaExtractor.java:512)
E/ExoPlayerImplInternal(13211): at com.google.android.exoplayer2.source.BundledExtractorsAdapter.read(BundledExtractorsAdapter.java:127)
E/ExoPlayerImplInternal(13211): at com.google.android.exoplayer2.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:1039)
E/ExoPlayerImplInternal(13211): at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:412)
E/ExoPlayerImplInternal(13211): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/ExoPlayerImplInternal(13211): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/ExoPlayerImplInternal(13211): at java.lang.Thread.run(Thread.java:923)
I/flutter (13211): Error initializing video player: PlatformException(VideoError, Video player had error com.google.android.exoplayer2.ExoPlaybackException: Source error, null, null)
`your text`my code
void initializeVideoPlayer(String url) {
kycController.videoPlayerController = VideoPlayerController.networkUrl(
Uri.parse(url),
videoPlayerOptions: VideoPlayerOptions(mixWithOthers: false,allowBackgroundPlayback:false),
)
..initialize().then(
(_) async {
if (mounted) {
setState(() {
kycController.videoPlayerController!.play();
});
kycController.videoPlayerController!.addListener(
() {
if (kycController.videoPlayerController!.value.position == kycController.videoPlayerController!.value.duration) {
setState(() {
kycController.videoPlayerController!.pause();
kycController.videoPlayerController!.seekTo(const Duration(seconds: 0));
});
}
},
);
}
},
onError: (error) {
// Handle initialization error
debugPrint("Error initializing video player: $error");
},
);
}
2
Answers
your code look good
try this
}
change Uri.parse(url) to pass only url
You can use the internet so check internet Permission
Use this plugin :
video_player 2.8.2