From d7b4d24ba6fb23302de139a122229ff69446ff30 Mon Sep 17 00:00:00 2001 From: Jeff Cunat Date: Mon, 20 Apr 2020 17:25:45 +0200 Subject: [PATCH] MediaPlayer.setInitialMediaSettingsFor compatible with fragmentedText media type --- samples/captioning/multi-track-captions.html | 6 +++ samples/dash-if-reference-player/app/main.js | 9 ++++- samples/dash-if-reference-player/index.html | 4 +- src/streaming/MediaPlayer.js | 8 ++-- src/streaming/controllers/MediaController.js | 1 + src/streaming/text/TextController.js | 32 ++++++++++------ test/unit/mocks/MediaControllerMock.js | 7 ++++ test/unit/streaming.MediaPlayer.js | 7 ++++ test/unit/streaming.text.TextController.js | 39 ++++++++++++++++++-- 9 files changed, 92 insertions(+), 21 deletions(-) diff --git a/samples/captioning/multi-track-captions.html b/samples/captioning/multi-track-captions.html index c559eb959e..96207d47b3 100644 --- a/samples/captioning/multi-track-captions.html +++ b/samples/captioning/multi-track-captions.html @@ -28,6 +28,12 @@ player = dashjs.MediaPlayer().create(); player.initialize(videoElement, url, true); + /* player.setInitialMediaSettingsFor('fragmentedText', { + lang: 'eng', + role: 'caption' + }); + */ + // player.setTextDefaultLanguage('swe'); player.attachTTMLRenderingDiv(TTMLRenderingDiv); controlbar = new ControlBar(player); // Checkout ControlBar.js for more info on how to target/add text tracks to UI controlbar.initialize(); diff --git a/samples/dash-if-reference-player/app/main.js b/samples/dash-if-reference-player/app/main.js index 6a5c784455..325efa8fa2 100644 --- a/samples/dash-if-reference-player/app/main.js +++ b/samples/dash-if-reference-player/app/main.js @@ -619,7 +619,14 @@ app.controller('DashController', function ($scope, sources, contributors, dashif }); } if ($scope.initialSettings.text) { - $scope.player.setTextDefaultLanguage($scope.initialSettings.text); + if ($scope.initialSettings.textRole) { + $scope.player.setInitialMediaSettingsFor('fragmentedText', { + role: $scope.initialSettings.textRole, + lang: $scope.initialSettings.text + }); + } else { + $scope.player.setTextDefaultLanguage($scope.initialSettings.text); + } } $scope.player.setTextDefaultEnabled($scope.initialSettings.textEnabled); $scope.player.enableForcedTextStreaming($scope.initialSettings.forceTextStreaming); diff --git a/samples/dash-if-reference-player/index.html b/samples/dash-if-reference-player/index.html index 40f5d56e18..9c5521de2e 100644 --- a/samples/dash-if-reference-player/index.html +++ b/samples/dash-if-reference-player/index.html @@ -239,8 +239,10 @@ - + + +