From 84b9a89f045b195df3423f1bcd62a5dc40d42f98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Velad=20Galv=C3=A1n?= Date: Wed, 14 Jul 2021 17:35:27 +0200 Subject: [PATCH] feat: Add goToLive method (#3527) --- lib/cast/cast_utils.js | 1 + lib/player.js | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/lib/cast/cast_utils.js b/lib/cast/cast_utils.js index 91b1309deb..67990454f1 100644 --- a/lib/cast/cast_utils.js +++ b/lib/cast/cast_utils.js @@ -388,6 +388,7 @@ shaka.cast.CastUtils.PlayerVoidMethods = [ 'selectVariantsByLabel', 'setTextTrackVisibility', 'trickPlay', + 'goToLive', ]; diff --git a/lib/player.js b/lib/player.js index 169fa92697..977d7d3b40 100644 --- a/lib/player.js +++ b/lib/player.js @@ -3130,6 +3130,19 @@ shaka.Player = class extends shaka.util.FakeEventTarget { return {'start': 0, 'end': 0}; } + /** + * Go to live in a live stream. + * + * @export + */ + goToLive() { + if (this.isLive()) { + this.video_.currentTime = this.seekRange().end; + } else { + shaka.log.warning('goToLive is for live streams!'); + } + } + /** * Get the key system currently used by EME. If EME is not being used, this * will return an empty string. If the player has not loaded content, this