Skip to content

Commit

Permalink
Add config for using src= on Safari.
Browse files Browse the repository at this point in the history
Closes #2116.

Change-Id: I4742037563a20e2e585a6dfbeae29a65bffe2117
  • Loading branch information
ismena committed Aug 29, 2019
1 parent 8f57efb commit 8d4f9a4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
8 changes: 7 additions & 1 deletion externs/shaka/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,8 @@ shaka.extern.ManifestConfiguration;
* safeSeekOffset: number,
* stallEnabled: boolean,
* stallThreshold: number,
* stallSkip: number
* stallSkip: number,
* useNativeHlsOnSafari: boolean
* }}
*
* @description
Expand Down Expand Up @@ -715,6 +716,11 @@ shaka.extern.ManifestConfiguration;
* @property {number} stallSkip
* The number of seconds that the player will skip forward when a stall has
* been detected.
* @property {boolean} useNativeHlsOnSafari
* Desktop Safari has both MediaSource and their native HLS implementation.
* Depending on the application's needs, it may prefer one over the other.
* Examples: FairPlay is only supported via Safari's native HLS, but it
* doesn't have an API for selecting specific tracks.
* @exportDoc
*/
shaka.extern.StreamingConfiguration;
Expand Down
7 changes: 3 additions & 4 deletions lib/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -1088,10 +1088,9 @@ shaka.Player = class extends shaka.util.FakeEventTarget {

// We would prefer MediaSource in some cases, and src= in others. For
// example, Android has native HLS, but we'd prefer our own MediaSource
// version there. But for Safari desktop, we'd prefer the native one for
// now, because that's the only way we get FairPlay there. So use src=
// over MSE on any Apple platform.
return Platform.isApple();
// version there. For Safari, the choice is governed by the
// useNativeHlsOnSafari setting of the streaming config.
return Platform.isApple() && this.config_.streaming.useNativeHlsOnSafari;
}

// Unless there are good reasons to use src= (single-file playback or native
Expand Down
1 change: 1 addition & 0 deletions lib/util/platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ shaka.util.Platform = class {
!shaka.util.Platform.isEdge();
}


/**
* Check if the current platform is an Apple device (iOS, desktop Safari, etc)
*
Expand Down
1 change: 1 addition & 0 deletions lib/util/player_configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ shaka.util.PlayerConfiguration = class {
stallEnabled: true,
stallThreshold: 1 /* seconds */,
stallSkip: 0.1 /* seconds */,
useNativeHlsOnSafari: true,
};

// WebOS has a long hardware pipeline that responds slowly, making it easy
Expand Down

0 comments on commit 8d4f9a4

Please sign in to comment.