Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS Failed to load video #148

Open
Quichaco opened this issue Sep 17, 2022 · 9 comments
Open

iOS Failed to load video #148

Quichaco opened this issue Sep 17, 2022 · 9 comments

Comments

@Quichaco
Copy link

Quichaco commented Sep 17, 2022

Hello,
I have this exception when i play video on iOS only
[VERBOSE-2:ui_dart_state.cc(209)] Unhandled Exception: PlatformException(VideoError, Failed to load video: Cannot Open, null, null)

I init the item :

 StoryItem.pageVideo(
            *my_url*,
            controller: storyController,
          )

When I play the same video with the video_player it still works correctly
VideoPlayerController.network(**myurl**);

I saw some parts that it could come from the header of the video returned from the server.
Here is my header :

Accept-Ranges: bytes
Content-Length: 37622786
Content-Type: application/octet-stream
Date: Sat, 17 Sep 2022 13:01:41 GMT
ETag: "cc865cd42a0f3b1a29ed59d2d5c684f3"
Last-Modified: Sat, 06 Aug 2022 14:21:42 GMT
Server: AmazonS3
x-amz-id-2: ***ID***
x-amz-request-id: ***ID***

This is a known issue ?

@waqadArshad
Copy link

@blackmann Can you please take a look at this? this is causing issues for me.

@jerrypaulsam
Copy link

Hey, I am having the same issue. Have you got a solution?

Thanks

@jerrypaulsam
Copy link

I was able to resolve this problem by loading the video directly from the url instead of the cached file. The error might be related to the caching in the VideoLoader class [Also, there is an open issue with Flutter itself]. So, for iOS, I am loading the video directly from url and for android from the cached file.

@MartinBergerDX
Copy link

MartinBergerDX commented Mar 3, 2023

@jerrypaulsam What does that mean, loading the video directly from the url, instead of cached file? How do you load the video "directly"?

In my case, I just pass the media url to StoryItem.pageVideo constructor, but still fails on iOS:

  /// Shorthand for creating page video. [controller] should be same instance as
  /// one passed to the `StoryView`
  factory StoryItem.pageVideo(
    String url, {
    required StoryController controller,
    Key? key,
    Duration? duration,
    BoxFit imageFit = BoxFit.fitWidth,
    String? caption,
    bool shown = false,
    Map<String, dynamic>? requestHeaders,
  }) {
    return StoryItem(
        Container(
          key: key,

How do you load a video from a cache? You do not have access to VideoLoader here.

@jerrypaulsam
Copy link

@MartinBergerDX Hey Martin, We forked the repo and made slight changes to the code.

@MartinBergerDX
Copy link

@jerrypaulsam Thanks for the answer! There are about 50 forks for story_view and I could not find your fork. But does not matter, I fixed it.

I have fixed it by adding ContentType to my files when uploading them with Amplify.Storage category in Flutter.

Future<StorageObject> uploadFile(
      File file,
      String s3Folder,
      List<String>? subfolderPathComponents,
      Map<String, String>? metadata,
      String? contentType,
      Function(double progress)? progressUpdate) async {
    final storageKey = _generateStorageKey(file, subfolderPathComponents);
    final uploadOptions = S3UploadFileOptions(
      accessLevel: StorageAccessLevel.protected,
      metadata: metadata,
      contentType: contentType,
    );
    debugPrint(
        'Beginning file upload with key: $storageKey, s3Folder: ${s3Folder}, subfolderPathComponents: ${subfolderPathComponents.toString()}, metadata: ${metadata.toString()}, contentType: ${contentType}.');
    final UploadFileResult result = await Amplify.Storage.uploadFile(
        local: file,
        key: storageKey,
        options: uploadOptions,
        onProgress: (progressUpdate != null)
            ? (progress) {
                progressUpdate(progress.getFractionCompleted());
              }
            : null);
    debugPrint('Successfully uploaded file with key: ${result.key}');
    final serverUploadStorageKey = _convertToAmplifyStorageKey(s3Folder, storageKey);
    debugPrint('Server upload storage key: $serverUploadStorageKey');
    return StorageObject(
      s3Folder: s3Folder,
      subfolderPathComponents: subfolderPathComponents,
      storageKey: storageKey,
      serverUploadStorageKey: serverUploadStorageKey,
    );
  }

By using S3UploadFileOptions.

final uploadOptions = S3UploadFileOptions(
      accessLevel: StorageAccessLevel.protected,
      metadata: metadata,
      contentType: contentType,
    );

ContentType is set to video/mp4 and when specified here is reflected on S3 in AWS Console. [year 2023]

AWS is making an update for this.

It seems that story_view requires some maintainers, it is awfully forgotten :)

Take care.

@AliSamir070
Copy link

any solution please i'm stuck in this problem ?

@Kanwarpalsingh1986
Copy link

really very bad support, no update on this issue, many users facing this issue form more than 1 year, they have the new versions but no fix on this issue, also no reply

@Obada2020
Copy link

any updates ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants