Malakmkd
Malakmkd

Reputation: 141

PlatformException(VideoError, Video player had error..)

I have this method

Future<void> uploadVideo(BuildContext context) async {
  File videoFile = widget.videoFile;
  print("videoFile $videoFile"); //this gives: File: '/data/user/0/com.---/app_flutter/tutorVideo/1610097782457.mp4'
  setState(() {
    isLoading = true;
  });

  StorageReference fileStorageReference = FirebaseStorage.instance
      .ref()
      .child('tutorDetails')
      .child(AuthModel().currentUser.uid)
      .child('Video')
      .child(basename(videoFile.path));

  print("storage ${fileStorageReference.path}"); //this gives: storage tutorDetails/Kb2BmJnNWnMjxartXoXcmZGRjxg2/Video/1610097782457.mp4

  StorageUploadTask uploadTask = fileStorageReference.putFile(videoFile);

  StorageTaskSnapshot taskSnapshot = await uploadTask.onComplete;

  String downloadUrl = await taskSnapshot.ref.getDownloadURL();

  UserModel().updateProfileFields({
    'videoUrl': downloadUrl,
    "tutorApplicationVideoFlag": true,
  });

  setState(() {
    isLoading = false;
  });

  Navigator.popUntil(
      context, ModalRoute.withName(TutorApplicationScreen.path));
}

and I am using the latest version of video_player flutter plugin {I updated it}, but i am having these errors

Playback error

Unhandled Exception: PlatformException(VideoError, Video player had error com.google.android.exoplayer2.ExoPlaybackException: Source error, null, null)

Unhandled Exception: 'package:firebase_storage/src/storage_reference.dart': Failed assertion: line 62 pos 12: 'file.existsSync()': is not true.

Note: It works on some devices normally and withoud any error, but on others no. Any thoughts? Thanks

Upvotes: 1

Views: 6673

Answers (1)

Malakmkd
Malakmkd

Reputation: 141

The issue was solved by updating the code, checking the docs.

Upvotes: -1

Related Questions