Skip to content

lightbox: Offer to open browser if video player doesn't support a video format #1208

Open
@chrisbobbe

Description

@chrisbobbe

Sometimes the video player fails to initialize because the video format isn't supported:

image

The app relies on the platform's (iOS or Android) set of implementations for playing videos of various formats. Sometimes the platform doesn't support a video but the user's browser does because the browser brings its own implementation. For example, it fails in the app for me on iOS 18.1.1 but succeeds in Chrome on the same device. See discussion in beta feedback.

So, when a video is unsupported, it would be helpful to offer to open it in the browser.


Implementation notes:

Here's the note from the library we use, video_player:

https://github.com/flutter/packages/tree/311b660c6/packages/video_player/video_player

Supported Formats

  • On iOS and macOS, the backing player is AVPlayer.
    The supported formats vary depending on the version of iOS, AVURLAsset class
    has audiovisualTypes that you can query for supported av formats.
  • On Android, the backing player is ExoPlayer,
    please refer here for list of supported formats.

[…]

The error I get on iOS is a PlatformException; here's what went by in the logs:

flutter: VideoPlayerController.networkUrl(https://chat.zulip.org/user_uploads/2/86/dBbfIDB3gWLscD3dQXnsBlXc/Screencast-from-2024-12-26-00-48-11.webm)
flutter: VideoPlayerController.initialize failed: PlatformException(VideoError, Failed to load video: Cannot Open: This media format is not supported.: The operation couldn’t be completed. (OSStatus error -12847.), null, null)

Looks like the structured "code" part is just a generic "VideoError", and the part that says it's specifically a format issue is this string:

Failed to load video: Cannot Open: This media format is not supported.: The operation couldn’t be completed. (OSStatus error -12847.)

Rather than parsing that, let's try just assuming a "VideoError"—or perhaps any error—is a good reason to offer to open the browser, and do so.

If the video is on-realm, needing authentication, we should use the "temp file URL" protocol; see api.tryGetFileTemporaryUrl in zulip-mobile.

Metadata

Metadata

Assignees

No one assigned

    Labels

    a-lightboxThe lightbox / image-viewer screenbeta feedbackThings beta users have specifically asked for

    Type

    No type

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions