Closed gusk9999 closed 3 months ago
Hi @gusk9999, does this error occurs on each run or only after the first run? The first run is when the video is directly used from the network, from the second run if cache is available and not expired, the video is played from cache.
Also, can you try this with just the video_player plugin? So we may know if the plugin itself supports the video you are trying to play.
The error occurs on each run, and with video_player: ^2.8.6 the result is good but no cache storage support. This video is the build with video player: https://youtube.com/shorts/BvhukpfWlpk
Used code:
@override void initState() { super.initState(); videoPlayerController = VideoPlayerController.networkUrl(Uri.parse(widget.videoUrl)); videoPlayerController.addListener(() { setState(() {}); }); videoPlayerController.setLooping(true); videoPlayerController.initialize().then((_) => setState(() {})); }
@override void dispose() { videoPlayerController.dispose(); isPlayingNotifier.dispose(); super.dispose(); }
I suppose the format cache video HLS is not supported in cached_video_player_plus. This issue is not present in cached_video_player 2.0.4 from lazyarts, but is an old package.
Can you try with skipCache
set to true
in VideoPlayerController.networkUrl
constructor and tell me what happens?
Working fine with skipCache = true, but not cache support. https://youtube.com/shorts/v5eNbZghFqA
Used code:
@override void initState() { super.initState(); videoPlayerController = CachedVideoPlayerPlusController.networkUrl( Uri.parse(widget.videoUrl), skipCache: true); videoPlayerController.addListener(() { setState(() {}); }); videoPlayerController.setLooping(true); videoPlayerController.initialize().then((_) => setState(() {})); }
@override void dispose() { videoPlayerController.dispose(); isPlayingNotifier.dispose(); super.dispose(); }
Does this only happens on Android? Can you try it on iOS or macOS too?
In IOS Simulator with skipCache disabled, show this error: https://youtu.be/Gm9lhaw78lU (My PC hardware is slow and lag the simulator)
flutter: Cached video of [https://customer-450a4llvkacagmt7.cloudflarestream.com/e496ec3af37b43e5810dad1bd41db6ba/manifest/video.m3u8] is: null flutter: Cached video [https://customer-450a4llvkacagmt7.cloudflarestream.com/e496ec3af37b43e5810dad1bd41db6ba/manifest/video.m3u8] successfully. flutter: Cached video of [https://customer-450a4llvkacagmt7.cloudflarestream.com/f8e65a9e7c8742b4a8b4882bd1d3b57e/manifest/video.m3u8] is: null flutter: Cached video [https://customer-450a4llvkacagmt7.cloudflarestream.com/f8e65a9e7c8742b4a8b4882bd1d3b57e/manifest/video.m3u8] successfully. flutter: Cached video of [https://customer-450a4llvkacagmt7.cloudflarestream.com/8b584f53f897485488c515697369f027/manifest/video.m3u8] is: /Users/gustavo/Library/Developer/CoreSimulator/Devices/737A3D7C-73C8-4107-A9F9-6E8D5BFFB095/data/Containers/Data/Application/1F1A630E-DEAE-4E5A-9A91-30B8C664DCD9/Library/Caches/libCachedVideoPlayerPlusData/bc589c90-12f4-1002-86cb-51b1d16ab380.x-mpegurl flutter: Cache for [https://customer-450a4llvkacagmt7.cloudflarestream.com/8b584f53f897485488c515697369f027/manifest/video.m3u8] valid till: 2024-06-30 22:55:43.436 [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(VideoError, Failed to load video: Cannot Open, null, null) flutter: Cached video of [https://customer-450a4llvkacagmt7.cloudflarestream.com/52a5a24a258244f291780cb4ba098592/manifest/video.m3u8] is: /Users/gustavo/Library/Developer/CoreSimulator/Devices/737A3D7C-73C8-4107-A9F9-6E8D5BFFB095/data/Containers/Data/Application/1F1A630E-DEAE-4E5A-9A91-30B8C664DCD9/Library/Caches/libCachedVideoPlayerPlusData/fbd1d940-12f4-1002-86cb-51b1d16ab380.x-mpegurl flutter: Cache for [https://customer-450a4llvkacagmt7.cloudflarestream.com/52a5a24a258244f291780cb4ba098592/manifest/video.m3u8] valid till: 2024-06-30 22:55:43.557
The cache video file is video.m3u8, but rewrite every change video, the error occurs when I return to previous video but video.m3u8 is not the same. Maybe solution will be created video.m3u8 cache files for every different videos (Sorry for my English).
Used code:
@override void initState() { super.initState(); videoPlayerController = CachedVideoPlayerPlusController.networkUrl( Uri.parse(widget.videoUrl),); videoPlayerController.addListener(() { setState(() {}); }); videoPlayerController.setLooping(true); videoPlayerController.initialize().then((_) => setState(() {})); }
@override void dispose() { videoPlayerController.dispose(); isPlayingNotifier.dispose(); super.dispose(); }
@gusk9999 I think I finally found the error.
When I tried running your url from error logs in the example app, it ran first successfully and cached the file https://customer-450a4llvkacagmt7.cloudflarestream.com/e496ec3af37b43e5810dad1bd41db6ba/manifest/video.m3u8
, but this file also mentions another file to play the video from. But that video isn't cached as it's not the same url.
Hence on the second run I get this error:
E/ExoPlayerImplInternal( 6121): Caused by: java.io.FileNotFoundException: /data/user/0/rocks.outdatedguy.cached_video_player_plus_example/cache/libCachedVideoPlayerPlusData/stream_tc12bf97b1e31bc840f1f8c7939a002aa_r514705248.m3u8: open failed: ENOENT (No such file or directory)
So the actual video is from the url https://customer-450a4llvkacagmt7.cloudflarestream.com/e496ec3af37b43e5810dad1bd41db6ba/manifest/stream_tc12bf97b1e31bc840f1f8c7939a002aa_r514705248.m3u8
.
But due to video.m3u8
is cached locally, this stream_tc12bf97b1e31bc840f1f8c7939a002aa_r514705248.m3u8
is also being searched locally from the device, but it isn't cached.
Yes, Cloudflare streams all videos as video.m3u8. Maybe the solution will be to change the cache file name if the URL is different. I suppose :/.
can you share your code on how you are managing this feed? it will be really helpful
Yes, Cloudflare streams all videos as video.m3u8. Maybe the solution will be to change the cache file name if the URL is different. I suppose :/.
@gusk9999 I think you misunderstood my comment. Each video is cached with a completely different name even if the ending name is same.
The issue is that, the cached file defines another file in its content to play the video from which is not cached. Hence this issue is occurring.
Hope this clarifies the issue.
I am getting the same issue, and unable to find any workaround.
@jitendrapurohit12, as I said this package does not support HLS or any stream videos as those videos are stored in multiple separate files instead of just one.
If you want to use HLS videos, you have to skip caching the videos using the skipCache
property.
This error was result for me using HLS videos in TikTok similar app:
E/ExoPlayerImplInternal(19936): Playback error E/ExoPlayerImplInternal(19936): com.google.android.exoplayer2.ExoPlaybackException: Source error E/ExoPlayerImplInternal(19936): at com.google.android.exoplayer2.ExoPlayerImplInternal.handleIoException(ExoPlayerImplInternal.java:644) E/ExoPlayerImplInternal(19936): at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:614) E/ExoPlayerImplInternal(19936): at android.os.Handler.dispatchMessage(Handler.java:102) E/ExoPlayerImplInternal(19936): at android.os.Looper.loopOnce(Looper.java:211) E/ExoPlayerImplInternal(19936): at android.os.Looper.loop(Looper.java:300) E/ExoPlayerImplInternal(19936): at android.os.HandlerThread.run(HandlerThread.java:67) E/ExoPlayerImplInternal(19936): Caused by: com.google.android.exoplayer2.source.UnrecognizedInputFormatException: None of the available extractors (FlvExtractor, FlacExtractor, WavExtractor, FragmentedMp4Extractor, Mp4Extractor, AmrExtractor, PsExtractor, OggExtractor, TsExtractor, MatroskaExtractor, AdtsExtractor, Ac3Extractor, Ac4Extractor, Mp3Extractor, AviExtractor, JpegExtractor) could read the stream. E/ExoPlayerImplInternal(19936): at com.google.android.exoplayer2.source.BundledExtractorsAdapter.init(BundledExtractorsAdapter.java:92) E/ExoPlayerImplInternal(19936): at com.google.android.exoplayer2.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:1017) E/ExoPlayerImplInternal(19936): at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:412) E/ExoPlayerImplInternal(19936): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137) E/ExoPlayerImplInternal(19936): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637) E/ExoPlayerImplInternal(19936): at java.lang.Thread.run(Thread.java:1012) E/gralloc4(19936): Empty SMPTE 2094-40 data E/flutter (19936): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(VideoError, Video player had error com.google.android.exoplayer2.ExoPlaybackException: Source error, null, null)
I suppose exoplayer don't read cache video.. Video with error: https://youtube.com/shorts/xHj2QXq-WJs
My videocontroller code:
@override void initState() { super.initState(); videoPlayerController = CachedVideoPlayerPlusController.networkUrl( Uri.parse(widget.videoUrl), invalidateCacheIfOlderThan: const Duration(days: 2)) ..initialize().then((value) async { await videoPlayerController.setLooping(true); setState(() {}); }); }
@override void dispose() { videoPlayerController.dispose(); isPlayingNotifier.dispose(); super.dispose(); }