Quellcode durchsuchen

Allow retry with transcode instead of usng a hard failure. (#127)

Ian Walton vor 2 Jahren
Ursprung
Commit
bfd1b923c0
1 geänderte Dateien mit 22 neuen und 12 gelöschten Zeilen
  1. 22 12
      native/mpvVideoPlayer.js

+ 22 - 12
native/mpvVideoPlayer.js

@@ -7,7 +7,7 @@
     }
 
     class mpvVideoPlayer {
-        constructor({ events, loading, appRouter, globalize, appHost, appSettings, toast }) {
+        constructor({ events, loading, appRouter, globalize, appHost, appSettings, confirm }) {
             this.events = events;
             this.loading = loading;
             this.appRouter = appRouter;
@@ -189,23 +189,33 @@
              * @private
              * @param e {Event} The event received from the `<video>` element
              */
-            this.onError = (error) => {
+            this.onError = async (error) => {
                 this.removeMediaDialog();
-                toast(`media error: ${error}`);
                 console.error(`media error: ${error}`);
 
-                this.events.trigger(this, 'error', [
-                    {
-                        type: 'mediadecodeerror',
+                const errorData = {
+                    type: 'mediadecodeerror'
+                };
+
+                try {
+                    await confirm({
+                        title: "Playback Failed",
+                        text: `Playback failed with error "${error}". Retry with transcode? (Note this may hang the player.)`,
+                        cancelText: "Cancel",
+                        confirmText: "Retry"
+                    });
+                } catch (ex) {
+                    // User declined retry
+                    errorData.streamInfo = {
                         // Prevent jellyfin-web retrying with transcode
                         // which crashes the player
-                        streamInfo: {
-                            mediaSource: {
-                                SupportsTranscoding: false
-                            }
+                        mediaSource: {
+                            SupportsTranscoding: false
                         }
-                    }
-                ]);
+                    };
+                }
+
+                this.events.trigger(this, 'error', [errorData]);
             };
 
             this.onDuration = (duration) => {