英文:
video_player package not able to play mp4-files on iOS but android
问题
I am downloading mp4 file from Firestore.
Then I sure it in the Cache with the ChaceManager. Like:
dev.log(name: 'Resource_Explorer', 'Trying to chace Video: $videoName');
final storageRef = _firebaseStorage.ref(path);
final fileData = await storageRef.getData();
return ExplorerFileInfo(await cacheinstance.putFile(path, fileData!, key: path), FileState.downloaded);
Then I provide the Video to my Video Player as:
final videoFile = (await resourceExplorer.getVideoFile(videoPath)).value;
Everything works fine on Android. But on iOS I'm getting the error:
[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(VideoError, Failed to load video: Cannot Open, null, null)
I searched for the error 'Failed to load video: Cannot Open' and found a GitHub issue which is still open. But only one person had the same 'Cannot Open' as me. They are getting an error like: 'Failed to load video: Operation Stopped'. And this issue is still unsolved. And seems to be an HTTP error.
I am able to play the same video from my assets. And I am able to do the same steps to display an image on iOS and on Android.
I would be grateful for any help. Thanks in advance!
Update:
After I downloaded the file with the Duo package instead of .getData(), I was able to deliver the file as a desired mp4 and play it with the video_player.
But if I save the data in the cache with the cache manager, I will get the data as .file and video_player is not able to play .file files on iOS.
英文:
I am downloading mp4 file from Firestore.
Then I sure it in the Cache with the ChaceManager. Like:
dev.log(name: 'Resource_Explorer', 'Trying to chace Video: $videoName');
final storageRef = _firebaseStorage.ref(path);
final fileData = await storageRef.getData();
return ExplorerFileInfo(await cacheinstance.putFile(path, fileData!, key: path), FileState.downloaded);
Then I provide the Video to my Video Player as:
final videoFile = (await resourceExplorer.getVideoFile(videoPath)).value;
Everything works fine on Android. But on IOS im getting the error:<br>
[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(VideoError, Failed to load video: Cannot Open, null, null) <br>
I searched for the error 'Failed to load video: Cannot Open' and found GitHub issue which is still open. but only one person had the same 'Cannot Open' as me. They are getting error like: 'Failed to load video: Operation Stopped,'. And this issue is still unsolved. And seems to be a Http error.
I am able to play the same video from my assets. And I am able to do the same steps to display an Image on IOS and on Android.
I would be greatful for any help. Thanks in advance!
Update:<br>
After I downloaded the file with the Duo package instead of .getData(), I was able to deliver the file as wished mp4 and play it with the video_player. <br>
But if I safe the data in the cache with the cache manager, I will get the data as .file and video_player is not able to play .file files on iOS.
答案1
得分: 0
I solved the Problem.
Somehow is video_player able to open "*.file" on Android, but on iOS!
To solve the problem you have to rename your videoFile like:
final videoFile = (await resourceExplorer.getVideoFile(videoPath)).value;
String videoFilePath = videoFile.path;
String videoFilePathAsMp = '${videoFilePath.substring(0, videoFilePath.length - 4)}mp4';
final renamedVideo = await videoFile.rename(videoFilePathAsMp);
_vpController = VideoPlayerController.file(renamedVideo)
..addListener(() => setState(() {}))
..setLooping(true)
..setVolume(0.0)
..initialize().then((_) => _vpController!.play());
英文:
I solved the Problem.
Somehow is video_player able to open "*.file" on Android, but on iOS!
To solve the problem you have to rename your videoFile like:
final videoFile = (await resourceExplorer.getVideoFile(videoPath)).value;
String videoFilePath = videoFile.path;
String videoFilePathAsMp = '${videoFilePath.substring(0, videoFilePath.length - 4)}mp4';
final renamedVideo = await videoFile.rename(videoFilePathAsMp);
_vpController = VideoPlayerController.file(renamedVideo)
..addListener(() => setState(() {}))
..setLooping(true)
..setVolume(0.0)
..initialize().then((_) => _vpController!.play());
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论