@srgssr/pillarbox-web 1.26.0 → 1.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,7 @@
3
3
  const videojs = require('video.js');
4
4
  require('videojs-contrib-eme');
5
5
 
6
- const version = "1.25.0";
6
+ const version = "1.26.0";
7
7
 
8
8
  /** @import VJSPlayer from 'video.js/dist/types/player' */
9
9
  /** @import AudioTrack from 'video.js/dist/types/tracks/audio-track' */
@@ -162,6 +162,24 @@ class Player extends vjsPlayer {
162
162
  return ranges;
163
163
  }
164
164
 
165
+ /**
166
+ * Overrides the default `src` behavior to ensure the underlying tech is fully
167
+ * reset before setting a new source.
168
+ *
169
+ * This is a workaround for a Video.js issue where, under certain failure cases the
170
+ * internal `src_` reload logic is not triggered. As a result, the previous media
171
+ * can continue playing in the background even though the new source failed.
172
+ *
173
+ * @see https://docs.videojs.com/player#src
174
+ */
175
+ src(source) {
176
+ if (source) {
177
+ this.poster(null);
178
+ this.techCall_('reset');
179
+ }
180
+ super.src(source);
181
+ }
182
+
165
183
  /**
166
184
  * A getter/setter for the media's text track.
167
185
  * Activates the text track according to the language and kind properties.
@@ -1 +1 @@
1
- {"version":3,"file":"pillarbox-core.cjs","sources":["../src/components/player.js","../src/pillarbox.js"],"sourcesContent":["import videojs from 'video.js';\nimport 'videojs-contrib-eme';\n\n/** @import VJSPlayer from 'video.js/dist/types/player' */\n/** @import AudioTrack from 'video.js/dist/types/tracks/audio-track' */\n/** @import TextTrack from 'video.js/dist/types/tracks/text-track' */\n/** @import {TrackSelector} from './typedef' */\n\n/**\n * @ignore\n * @type {typeof VJSPlayer}\n */\nconst vjsPlayer = videojs.getComponent('player');\n\n/**\n * This class extends the video.js Player.\n *\n * @class Player\n * @see https://docs.videojs.com/player\n */\nclass Player extends vjsPlayer {\n constructor(tag, options, ready) {\n /**\n * Configuration for plugins.\n *\n * @see [Video.js Plugins Option]{@link https://videojs.com/guides/options/#plugins}\n * @type {Object}\n * @property {boolean} eme - Enable the EME (Encrypted Media Extensions) plugin.\n */\n options = videojs.obj.merge(options, { plugins: { eme: true }});\n super(tag, options, ready);\n }\n\n /**\n * A getter/setter for the media's audio track.\n * Activates the audio track according to the language and kind properties.\n * Falls back on the first audio track found if the kind property is not satisfied.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/AudioTrack/kind\n * @see https://developer.mozilla.org/en-US/docs/Web/API/AudioTrack/language\n *\n * @param {TrackSelector} [trackSelector]\n *\n * @example\n * // Get the current audio track\n * player.audioTrack();\n *\n * @example\n * // Activate an audio track based on language and kind properties\n * player.audioTrack({language:'en', kind:'description'});\n *\n * @example\n * // Activate first audio track found corresponding to language\n * player.audioTrack({language:'fr'});\n *\n * @return {AudioTrack | undefined} The\n * currently enabled audio track. See {@link https://docs.videojs.com/audiotrack}.\n */\n audioTrack(trackSelector) {\n const audioTracks = Array.from(this.player().audioTracks());\n\n if (!trackSelector) {\n return audioTracks.find((audioTrack) => audioTrack.enabled);\n }\n\n const { kind, language } = trackSelector;\n const audioTrack =\n audioTracks.find(\n (audioTrack) =>\n audioTrack.language === language && audioTrack.kind === kind\n ) || audioTracks.find((audioTrack) => audioTrack.language === language);\n\n if (audioTrack) {\n audioTrack.enabled = true;\n }\n\n return audioTrack;\n }\n\n /**\n * Calculates an array of ranges based on the `buffered()` data.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/buffered\n *\n * @returns {Array<{start: number, end: number}>} An array of objects representing start and end points of buffered ranges.\n */\n bufferedRanges() {\n const ranges = [];\n\n for (let i = 0; i < this.buffered().length; i++) {\n const start = this.buffered().start(i);\n const end = this.buffered().end(i);\n\n ranges.push({ start, end });\n }\n\n return ranges;\n }\n\n /**\n * Get the percent (as a decimal) of the media that's been played.\n * This method is not a part of the native HTML video API.\n *\n * Live streams with DVR are not currently supported.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement#htmlmediaelement.played\n *\n * @return {number}\n * A decimal between 0 and 1 representing the percent\n * that is played 0 being 0% and 1 being 100%\n */\n playedPercent() {\n if (!Number.isFinite(this.duration())) return NaN;\n\n let timePlayed = 0;\n\n for (let i = 0; i != this.played().length; i++) {\n timePlayed += this.played().end(i) - this.played().start(i);\n }\n\n const percentPlayed = timePlayed / this.duration();\n\n return percentPlayed;\n }\n\n /**\n * Get an array of ranges based on the `played` data.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement#htmlmediaelement.played\n *\n * @returns {Array<{start: number, end: number}>} An array of objects representing start and end points of played ranges.\n */\n playedRanges() {\n const ranges = [];\n\n for (let i = 0; i < this.played().length; i++) {\n const start = this.played().start(i);\n const end = this.played().end(i);\n\n ranges.push({ start, end });\n }\n\n return ranges;\n }\n\n /**\n * Calculates an array of ranges based on the `seekable()` data.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/seekable\n *\n * @returns {Array<{start: number, end: number}>} An array of objects representing start and end points of seekable ranges.\n */\n seekableRanges() {\n const ranges = [];\n\n for (let i = 0; i < this.seekable().length; i++) {\n const start = this.seekable().start(i);\n const end = this.seekable().end(i);\n\n ranges.push({ start, end });\n }\n\n return ranges;\n }\n\n /**\n * A getter/setter for the media's text track.\n * Activates the text track according to the language and kind properties.\n * Falls back on the first text track found if the kind property is not satisfied.\n * Disables all subtitle tracks that are `showing` if the `trackSelector` is truthy but does not satisfy any condition.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/TextTrack/kind\n * @see https://developer.mozilla.org/en-US/docs/Web/API/textTrack/language\n *\n * @param {TrackSelector} [trackSelector]\n *\n * @example\n * // Get the current text track\n * player.textTrack();\n *\n * @example\n * // Disable all text tracks has a side effect\n * player.textTrack('off');\n * player.textTrack({});\n *\n * @example\n * // Activate an text track based on language and kind properties\n * player.textTrack({language:'en', kind:'captions'});\n *\n * @example\n * // Activate first text track found corresponding to language\n * player.textTrack({language:'fr'});\n *\n * @return {TextTrack | undefined} The\n * currently enabled text track. See {@link https://docs.videojs.com/texttrack}.\n */\n textTrack(trackSelector) {\n const textTracks = Array.from(this.player().textTracks()).filter(\n (textTrack) => !['chapters', 'metadata'].includes(textTrack.kind)\n );\n\n if (!trackSelector) {\n return textTracks.find((textTrack) => textTrack.mode === 'showing');\n }\n\n textTracks.forEach((textTrack) => (textTrack.mode = 'disabled'));\n\n const { kind, language } = trackSelector;\n const textTrack =\n textTracks.find((textTrack) => {\n if (textTrack.language === language && textTrack.kind === kind) {\n textTrack.mode = 'showing';\n }\n\n return textTrack.mode === 'showing';\n }) ||\n textTracks.find((textTrack) => {\n if (textTrack.language === language) {\n textTrack.mode = 'showing';\n }\n\n return textTrack.mode === 'showing';\n });\n\n return textTrack;\n }\n}\n\nvideojs.registerComponent('player', Player);\n\nexport default Player;\n","import { version } from '../package.json';\nimport videojs from 'video.js';\nimport './components/player.js';\n\n/**\n * Pillarbox is an alias for the video.js namespace with additional options.\n *\n * @namespace\n * @see https://docs.videojs.com/module-videojs-videojs\n * @type {videojs}\n */\nconst pillarbox = videojs;\n\npillarbox.VERSION = {\n pillarbox: version,\n videojs: videojs.VERSION,\n [videojs.VhsSourceHandler.name]: videojs.VhsSourceHandler.VERSION,\n eme: videojs.getPlugin('eme').VERSION,\n};\n\n/**\n * Enable smooth seeking for Pillarbox.\n *\n * @see [Video.js enableSmoothSeeking Option]{@link https://videojs.com/guides/options/#enablesmoothseeking}\n * @type {boolean}\n * @default true\n */\npillarbox.options.enableSmoothSeeking = true;\n/**\n * Enable fill mode for the video player, allowing it to expand to fill the container.\n *\n * @see [Video.js Fill Option]{@link https://videojs.com/guides/layout/#fill-mode}\n * @type {boolean}\n * @default true\n */\npillarbox.options.fill = true;\n/**\n * Configuration options for HTML5 settings in Pillarbox.\n *\n * @see [VHS useForcedSubtitles Option]{@link https://github.com/videojs/http-streaming/blob/main/README.md#useforcedsubtitles}\n * @type {Object}\n * @property {Object} vhs - Configuration for the Video.js HTTP Streaming.\n * @property {boolean} useForcedSubtitles - Enables the player to display forced subtitles by default.\n * Forced subtitles are pieces of information intended for display when no other text representation\n * is selected. They are used to clarify dialogue, provide alternate languages, display texted graphics,\n * or present location/person IDs that are not otherwise covered in the dubbed/localized audio.\n */\npillarbox.options.html5 = {\n vhs: { useForcedSubtitles: true }\n};\n/**\n * Configuration for the live tracker.\n *\n * @see [Video.js liveTracker Option]{@link https://videojs.com/guides/options/#livetrackertrackingthreshold}\n * @type {Object}\n * @property {number} trackingThreshold - A threshold that controls when the liveui should be shown.\n * @property {number} liveTolerance - An option that controls how far from the seekable end should be considered live playback.\n */\npillarbox.options.liveTracker = {\n trackingThreshold: 120,\n liveTolerance: 15,\n};\n/**\n * Allows the player to use the live ui that includes:\n *\n * - A progress bar for seeking within the live window\n * - A button that can be clicked to seek to the live edge with a circle indicating if you are at the live edge or not.\n *\n * @see [Video.js liveui Option]{@link https://videojs.com/guides/options/#liveui}\n * @type {boolean}\n */\npillarbox.options.liveui = true;\n/**\n * Indicates that the video is to be played \"inline\", that is within the element's playback area.\n *\n * @see [Video element playsinline attribute]{@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video#playsinline}\n * @type {boolean}\n */\npillarbox.options.playsinline = true;\n/**\n * Enable responsive mode, this will cause the player to customize itself based on responsive breakpoints.\n *\n * @see [Video.js Responsive Option]{@link https://videojs.com/guides/options/#responsive}\n * @type {boolean}\n */\npillarbox.options.responsive = true;\n/**\n * A placeholder for accessing trackers directly from the player.\n *\n * @type {Object}\n */\npillarbox.options.trackers = {};\n\nexport default pillarbox;\n"],"names":["vjsPlayer","videojs","getComponent","Player","constructor","tag","options","ready","obj","merge","plugins","eme","audioTrack","trackSelector","audioTracks","Array","from","player","find","enabled","kind","language","bufferedRanges","ranges","i","buffered","length","start","end","push","playedPercent","Number","isFinite","duration","NaN","timePlayed","played","percentPlayed","playedRanges","seekableRanges","seekable","textTrack","textTracks","filter","includes","mode","forEach","registerComponent","pillarbox","VERSION","version","VhsSourceHandler","name","getPlugin","enableSmoothSeeking","fill","html5","vhs","useForcedSubtitles","liveTracker","trackingThreshold","liveTolerance","liveui","playsinline","responsive","trackers"],"mappings":";;;;;;;AAGA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,MAAMA,SAAS,GAAGC,OAAO,CAACC,YAAY,CAAC,QAAQ,CAAC;;AAEhD;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,MAAM,SAASH,SAAS,CAAC;AAC7BI,EAAAA,WAAWA,CAACC,GAAG,EAAEC,OAAO,EAAEC,KAAK,EAAE;AAC/B;AACJ;AACA;AACA;AACA;AACA;AACA;IACID,OAAO,GAAGL,OAAO,CAACO,GAAG,CAACC,KAAK,CAACH,OAAO,EAAE;AAAEI,MAAAA,OAAO,EAAE;AAAEC,QAAAA,GAAG,EAAE;AAAK;AAAC,KAAC,CAAC;AAC/D,IAAA,KAAK,CAACN,GAAG,EAAEC,OAAO,EAAEC,KAAK,CAAC;AAC5B,EAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEK,UAAUA,CAACC,aAAa,EAAE;AACxB,IAAA,MAAMC,WAAW,GAAGC,KAAK,CAACC,IAAI,CAAC,IAAI,CAACC,MAAM,EAAE,CAACH,WAAW,EAAE,CAAC;IAE3D,IAAI,CAACD,aAAa,EAAE;MAClB,OAAOC,WAAW,CAACI,IAAI,CAAEN,UAAU,IAAKA,UAAU,CAACO,OAAO,CAAC;AAC7D,IAAA;IAEA,MAAM;MAAEC,IAAI;AAAEC,MAAAA;AAAS,KAAC,GAAGR,aAAa;AACxC,IAAA,MAAMD,UAAU,GACdE,WAAW,CAACI,IAAI,CACbN,UAAU,IACTA,UAAU,CAACS,QAAQ,KAAKA,QAAQ,IAAIT,UAAU,CAACQ,IAAI,KAAKA,IAC5D,CAAC,IAAIN,WAAW,CAACI,IAAI,CAAEN,UAAU,IA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S,CAACC,OAAO,GAAG;AAClBD,EAAAA,SAAS,EAAEE,OAAO;EAClBjD,OAAO,EAAEA,OAAO,CAACgD,OAAO;EACxB,CAAChD,OAAO,CAACkD,gBAAgB,CAACC,IAAI,GAAGnD,OAAO,CAACkD,gBAAgB,CAACF,OAAO;AACjEtC,EAAAA,GAAG,EAAEV,OAAO,CAACoD,SAAS,CAAC,KAAK,CAAC,CAACJ;AAChC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACAD,SAAS,CAAC1C,OAAO,CAACgD,mBAAmB,GAAG,IAAI;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACAN,SAAS,CAAC1C,OAAO,CAACiD,IAAI,GAAG,IAAI;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACAP,SAAS,CAAC1C,OAAO,CAACkD,KAAK,GAAG;AACxBC,EAAAA,GAAG,EAAE;AAAEC,IAAAA,kBAAkB,EAAE;AAAK;AAClC,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACAV,SAAS,CAAC1C,OAAO,CAACqD,WAAW,GAAG;AAC9BC,EAAAA,iBAAiB,EAAE,GAAG;AACtBC,EAAAA,aAAa,EAAE;AACjB,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACAb,SAAS,CAAC1C,OAAO,CAACwD,MAAM,GAAG,IAAI;AAC/B;AACA;AACA;AACA;AACA;AACA;AACAd,SAAS,CAAC1C,OAAO,CAACyD,WAAW,GAAG,IAAI;AACpC;AACA;AACA;AACA;AACA;AACA;AACAf,SAAS,CAAC1C,OAAO,CAAC0D,UAAU,GAAG,IAAI;AACnC;AACA;AACA;AACA;AACA;AACAhB,SAAS,CAAC1C,OAAO,CAAC2D,QAAQ,GAAG,EAAE;;;;"}
1
+ {"version":3,"file":"pillarbox-core.cjs","sources":["../src/components/player.js","../src/pillarbox.js"],"sourcesContent":["import videojs from 'video.js';\nimport 'videojs-contrib-eme';\n\n/** @import VJSPlayer from 'video.js/dist/types/player' */\n/** @import AudioTrack from 'video.js/dist/types/tracks/audio-track' */\n/** @import TextTrack from 'video.js/dist/types/tracks/text-track' */\n/** @import {TrackSelector} from './typedef' */\n\n/**\n * @ignore\n * @type {typeof VJSPlayer}\n */\nconst vjsPlayer = videojs.getComponent('player');\n\n/**\n * This class extends the video.js Player.\n *\n * @class Player\n * @see https://docs.videojs.com/player\n */\nclass Player extends vjsPlayer {\n constructor(tag, options, ready) {\n /**\n * Configuration for plugins.\n *\n * @see [Video.js Plugins Option]{@link https://videojs.com/guides/options/#plugins}\n * @type {Object}\n * @property {boolean} eme - Enable the EME (Encrypted Media Extensions) plugin.\n */\n options = videojs.obj.merge(options, { plugins: { eme: true }});\n super(tag, options, ready);\n }\n\n /**\n * A getter/setter for the media's audio track.\n * Activates the audio track according to the language and kind properties.\n * Falls back on the first audio track found if the kind property is not satisfied.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/AudioTrack/kind\n * @see https://developer.mozilla.org/en-US/docs/Web/API/AudioTrack/language\n *\n * @param {TrackSelector} [trackSelector]\n *\n * @example\n * // Get the current audio track\n * player.audioTrack();\n *\n * @example\n * // Activate an audio track based on language and kind properties\n * player.audioTrack({language:'en', kind:'description'});\n *\n * @example\n * // Activate first audio track found corresponding to language\n * player.audioTrack({language:'fr'});\n *\n * @return {AudioTrack | undefined} The\n * currently enabled audio track. See {@link https://docs.videojs.com/audiotrack}.\n */\n audioTrack(trackSelector) {\n const audioTracks = Array.from(this.player().audioTracks());\n\n if (!trackSelector) {\n return audioTracks.find((audioTrack) => audioTrack.enabled);\n }\n\n const { kind, language } = trackSelector;\n const audioTrack =\n audioTracks.find(\n (audioTrack) =>\n audioTrack.language === language && audioTrack.kind === kind\n ) || audioTracks.find((audioTrack) => audioTrack.language === language);\n\n if (audioTrack) {\n audioTrack.enabled = true;\n }\n\n return audioTrack;\n }\n\n /**\n * Calculates an array of ranges based on the `buffered()` data.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/buffered\n *\n * @returns {Array<{start: number, end: number}>} An array of objects representing start and end points of buffered ranges.\n */\n bufferedRanges() {\n const ranges = [];\n\n for (let i = 0; i < this.buffered().length; i++) {\n const start = this.buffered().start(i);\n const end = this.buffered().end(i);\n\n ranges.push({ start, end });\n }\n\n return ranges;\n }\n\n /**\n * Get the percent (as a decimal) of the media that's been played.\n * This method is not a part of the native HTML video API.\n *\n * Live streams with DVR are not currently supported.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement#htmlmediaelement.played\n *\n * @return {number}\n * A decimal between 0 and 1 representing the percent\n * that is played 0 being 0% and 1 being 100%\n */\n playedPercent() {\n if (!Number.isFinite(this.duration())) return NaN;\n\n let timePlayed = 0;\n\n for (let i = 0; i != this.played().length; i++) {\n timePlayed += this.played().end(i) - this.played().start(i);\n }\n\n const percentPlayed = timePlayed / this.duration();\n\n return percentPlayed;\n }\n\n /**\n * Get an array of ranges based on the `played` data.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement#htmlmediaelement.played\n *\n * @returns {Array<{start: number, end: number}>} An array of objects representing start and end points of played ranges.\n */\n playedRanges() {\n const ranges = [];\n\n for (let i = 0; i < this.played().length; i++) {\n const start = this.played().start(i);\n const end = this.played().end(i);\n\n ranges.push({ start, end });\n }\n\n return ranges;\n }\n\n /**\n * Calculates an array of ranges based on the `seekable()` data.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/seekable\n *\n * @returns {Array<{start: number, end: number}>} An array of objects representing start and end points of seekable ranges.\n */\n seekableRanges() {\n const ranges = [];\n\n for (let i = 0; i < this.seekable().length; i++) {\n const start = this.seekable().start(i);\n const end = this.seekable().end(i);\n\n ranges.push({ start, end });\n }\n\n return ranges;\n }\n\n /**\n * Overrides the default `src` behavior to ensure the underlying tech is fully\n * reset before setting a new source.\n *\n * This is a workaround for a Video.js issue where, under certain failure cases the\n * internal `src_` reload logic is not triggered. As a result, the previous media\n * can continue playing in the background even though the new source failed.\n *\n * @see https://docs.videojs.com/player#src\n */\n src(source) {\n if (source) {\n this.poster(null);\n this.techCall_('reset');\n }\n\n super.src(source);\n }\n\n /**\n * A getter/setter for the media's text track.\n * Activates the text track according to the language and kind properties.\n * Falls back on the first text track found if the kind property is not satisfied.\n * Disables all subtitle tracks that are `showing` if the `trackSelector` is truthy but does not satisfy any condition.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/TextTrack/kind\n * @see https://developer.mozilla.org/en-US/docs/Web/API/textTrack/language\n *\n * @param {TrackSelector} [trackSelector]\n *\n * @example\n * // Get the current text track\n * player.textTrack();\n *\n * @example\n * // Disable all text tracks has a side effect\n * player.textTrack('off');\n * player.textTrack({});\n *\n * @example\n * // Activate an text track based on language and kind properties\n * player.textTrack({language:'en', kind:'captions'});\n *\n * @example\n * // Activate first text track found corresponding to language\n * player.textTrack({language:'fr'});\n *\n * @return {TextTrack | undefined} The\n * currently enabled text track. See {@link https://docs.videojs.com/texttrack}.\n */\n textTrack(trackSelector) {\n const textTracks = Array.from(this.player().textTracks()).filter(\n (textTrack) => !['chapters', 'metadata'].includes(textTrack.kind)\n );\n\n if (!trackSelector) {\n return textTracks.find((textTrack) => textTrack.mode === 'showing');\n }\n\n textTracks.forEach((textTrack) => (textTrack.mode = 'disabled'));\n\n const { kind, language } = trackSelector;\n const textTrack =\n textTracks.find((textTrack) => {\n if (textTrack.language === language && textTrack.kind === kind) {\n textTrack.mode = 'showing';\n }\n\n return textTrack.mode === 'showing';\n }) ||\n textTracks.find((textTrack) => {\n if (textTrack.language === language) {\n textTrack.mode = 'showing';\n }\n\n return textTrack.mode === 'showing';\n });\n\n return textTrack;\n }\n}\n\nvideojs.registerComponent('player', Player);\n\nexport default Player;\n","import { version } from '../package.json';\nimport videojs from 'video.js';\nimport './components/player.js';\n\n/**\n * Pillarbox is an alias for the video.js namespace with additional options.\n *\n * @namespace\n * @see https://docs.videojs.com/module-videojs-videojs\n * @type {videojs}\n */\nconst pillarbox = videojs;\n\npillarbox.VERSION = {\n pillarbox: version,\n videojs: videojs.VERSION,\n [videojs.VhsSourceHandler.name]: videojs.VhsSourceHandler.VERSION,\n eme: videojs.getPlugin('eme').VERSION,\n};\n\n/**\n * Enable smooth seeking for Pillarbox.\n *\n * @see [Video.js enableSmoothSeeking Option]{@link https://videojs.com/guides/options/#enablesmoothseeking}\n * @type {boolean}\n * @default true\n */\npillarbox.options.enableSmoothSeeking = true;\n/**\n * Enable fill mode for the video player, allowing it to expand to fill the container.\n *\n * @see [Video.js Fill Option]{@link https://videojs.com/guides/layout/#fill-mode}\n * @type {boolean}\n * @default true\n */\npillarbox.options.fill = true;\n/**\n * Configuration options for HTML5 settings in Pillarbox.\n *\n * @see [VHS useForcedSubtitles Option]{@link https://github.com/videojs/http-streaming/blob/main/README.md#useforcedsubtitles}\n * @type {Object}\n * @property {Object} vhs - Configuration for the Video.js HTTP Streaming.\n * @property {boolean} useForcedSubtitles - Enables the player to display forced subtitles by default.\n * Forced subtitles are pieces of information intended for display when no other text representation\n * is selected. They are used to clarify dialogue, provide alternate languages, display texted graphics,\n * or present location/person IDs that are not otherwise covered in the dubbed/localized audio.\n */\npillarbox.options.html5 = {\n vhs: { useForcedSubtitles: true }\n};\n/**\n * Configuration for the live tracker.\n *\n * @see [Video.js liveTracker Option]{@link https://videojs.com/guides/options/#livetrackertrackingthreshold}\n * @type {Object}\n * @property {number} trackingThreshold - A threshold that controls when the liveui should be shown.\n * @property {number} liveTolerance - An option that controls how far from the seekable end should be considered live playback.\n */\npillarbox.options.liveTracker = {\n trackingThreshold: 120,\n liveTolerance: 15,\n};\n/**\n * Allows the player to use the live ui that includes:\n *\n * - A progress bar for seeking within the live window\n * - A button that can be clicked to seek to the live edge with a circle indicating if you are at the live edge or not.\n *\n * @see [Video.js liveui Option]{@link https://videojs.com/guides/options/#liveui}\n * @type {boolean}\n */\npillarbox.options.liveui = true;\n/**\n * Indicates that the video is to be played \"inline\", that is within the element's playback area.\n *\n * @see [Video element playsinline attribute]{@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video#playsinline}\n * @type {boolean}\n */\npillarbox.options.playsinline = true;\n/**\n * Enable responsive mode, this will cause the player to customize itself based on responsive breakpoints.\n *\n * @see [Video.js Responsive Option]{@link https://videojs.com/guides/options/#responsive}\n * @type {boolean}\n */\npillarbox.options.responsive = true;\n/**\n * A placeholder for accessing trackers directly from the player.\n *\n * @type {Object}\n */\npillarbox.options.trackers = {};\n\nexport default pillarbox;\n"],"names":["vjsPlayer","videojs","getComponent","Player","constructor","tag","options","ready","obj","merge","plugins","eme","audioTrack","trackSelector","audioTracks","Array","from","player","find","enabled","kind","language","bufferedRanges","ranges","i","buffered","length","start","end","push","playedPercent","Number","isFinite","duration","NaN","timePlayed","played","percentPlayed","playedRanges","seekableRanges","seekable","src","source","poster","techCall_","textTrack","textTracks","filter","includes","mode","forEach","registerComponent","pillarbox","VERSION","version","VhsSourceHandler","name","getPlugin","enableSmoothSeeking","fill","html5","vhs","useForcedSubtitles","liveTracker","trackingThreshold","liveTolerance","liveui","playsinline","responsive","trackers"],"mappings":";;;;;;;AAGA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,MAAMA,SAAS,GAAGC,OAAO,CAACC,YAAY,CAAC,QAAQ,CAAC;;AAEhD;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,MAAM,SAASH,SAAS,CAAC;AAC7BI,EAAAA,WAAWA,CAACC,GAAG,EAAEC,OAAO,EAAEC,KAAK,EAAE;AAC/B;AACJ;AACA;AACA;AACA;AACA;AACA;IACID,OAAO,GAAGL,OAAO,CAACO,GAAG,CAACC,KAAK,CAACH,OAAO,EAAE;AAAEI,MAAAA,OAAO,EAAE;AAAEC,QAAAA,GAAG,EAAE;AAAK;AAAC,KAAC,CAAC;AAC/D,IAAA,KAAK,CAACN,GAAG,EAAEC,OAAO,EAAEC,KAAK,CAAC;AAC5B,EAAA;;AA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C9C,OAAO,CAACoD,mBAAmB,GAAG,IAAI;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACAN,SAAS,CAAC9C,OAAO,CAACqD,IAAI,GAAG,IAAI;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACAP,SAAS,CAAC9C,OAAO,CAACsD,KAAK,GAAG;AACxBC,EAAAA,GAAG,EAAE;AAAEC,IAAAA,kBAAkB,EAAE;AAAK;AAClC,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACAV,SAAS,CAAC9C,OAAO,CAACyD,WAAW,GAAG;AAC9BC,EAAAA,iBAAiB,EAAE,GAAG;AACtBC,EAAAA,aAAa,EAAE;AACjB,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACAb,SAAS,CAAC9C,OAAO,CAAC4D,MAAM,GAAG,IAAI;AAC/B;AACA;AACA;AACA;AACA;AACA;AACAd,SAAS,CAAC9C,OAAO,CAAC6D,WAAW,GAAG,IAAI;AACpC;AACA;AACA;AACA;AACA;AACA;AACAf,SAAS,CAAC9C,OAAO,CAAC8D,UAAU,GAAG,IAAI;AACnC;AACA;AACA;AACA;AACA;AACAhB,SAAS,CAAC9C,OAAO,CAAC+D,QAAQ,GAAG,EAAE;;;;"}
@@ -1,7 +1,7 @@
1
1
  import videojs from 'video.js';
2
2
  import 'videojs-contrib-eme';
3
3
 
4
- const version = "1.25.0";
4
+ const version = "1.26.0";
5
5
 
6
6
  /** @import VJSPlayer from 'video.js/dist/types/player' */
7
7
  /** @import AudioTrack from 'video.js/dist/types/tracks/audio-track' */
@@ -160,6 +160,24 @@ class Player extends vjsPlayer {
160
160
  return ranges;
161
161
  }
162
162
 
163
+ /**
164
+ * Overrides the default `src` behavior to ensure the underlying tech is fully
165
+ * reset before setting a new source.
166
+ *
167
+ * This is a workaround for a Video.js issue where, under certain failure cases the
168
+ * internal `src_` reload logic is not triggered. As a result, the previous media
169
+ * can continue playing in the background even though the new source failed.
170
+ *
171
+ * @see https://docs.videojs.com/player#src
172
+ */
173
+ src(source) {
174
+ if (source) {
175
+ this.poster(null);
176
+ this.techCall_('reset');
177
+ }
178
+ super.src(source);
179
+ }
180
+
163
181
  /**
164
182
  * A getter/setter for the media's text track.
165
183
  * Activates the text track according to the language and kind properties.
@@ -1 +1 @@
1
- {"version":3,"file":"pillarbox-core.es.js","sources":["../src/components/player.js","../src/pillarbox.js"],"sourcesContent":["import videojs from 'video.js';\nimport 'videojs-contrib-eme';\n\n/** @import VJSPlayer from 'video.js/dist/types/player' */\n/** @import AudioTrack from 'video.js/dist/types/tracks/audio-track' */\n/** @import TextTrack from 'video.js/dist/types/tracks/text-track' */\n/** @import {TrackSelector} from './typedef' */\n\n/**\n * @ignore\n * @type {typeof VJSPlayer}\n */\nconst vjsPlayer = videojs.getComponent('player');\n\n/**\n * This class extends the video.js Player.\n *\n * @class Player\n * @see https://docs.videojs.com/player\n */\nclass Player extends vjsPlayer {\n constructor(tag, options, ready) {\n /**\n * Configuration for plugins.\n *\n * @see [Video.js Plugins Option]{@link https://videojs.com/guides/options/#plugins}\n * @type {Object}\n * @property {boolean} eme - Enable the EME (Encrypted Media Extensions) plugin.\n */\n options = videojs.obj.merge(options, { plugins: { eme: true }});\n super(tag, options, ready);\n }\n\n /**\n * A getter/setter for the media's audio track.\n * Activates the audio track according to the language and kind properties.\n * Falls back on the first audio track found if the kind property is not satisfied.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/AudioTrack/kind\n * @see https://developer.mozilla.org/en-US/docs/Web/API/AudioTrack/language\n *\n * @param {TrackSelector} [trackSelector]\n *\n * @example\n * // Get the current audio track\n * player.audioTrack();\n *\n * @example\n * // Activate an audio track based on language and kind properties\n * player.audioTrack({language:'en', kind:'description'});\n *\n * @example\n * // Activate first audio track found corresponding to language\n * player.audioTrack({language:'fr'});\n *\n * @return {AudioTrack | undefined} The\n * currently enabled audio track. See {@link https://docs.videojs.com/audiotrack}.\n */\n audioTrack(trackSelector) {\n const audioTracks = Array.from(this.player().audioTracks());\n\n if (!trackSelector) {\n return audioTracks.find((audioTrack) => audioTrack.enabled);\n }\n\n const { kind, language } = trackSelector;\n const audioTrack =\n audioTracks.find(\n (audioTrack) =>\n audioTrack.language === language && audioTrack.kind === kind\n ) || audioTracks.find((audioTrack) => audioTrack.language === language);\n\n if (audioTrack) {\n audioTrack.enabled = true;\n }\n\n return audioTrack;\n }\n\n /**\n * Calculates an array of ranges based on the `buffered()` data.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/buffered\n *\n * @returns {Array<{start: number, end: number}>} An array of objects representing start and end points of buffered ranges.\n */\n bufferedRanges() {\n const ranges = [];\n\n for (let i = 0; i < this.buffered().length; i++) {\n const start = this.buffered().start(i);\n const end = this.buffered().end(i);\n\n ranges.push({ start, end });\n }\n\n return ranges;\n }\n\n /**\n * Get the percent (as a decimal) of the media that's been played.\n * This method is not a part of the native HTML video API.\n *\n * Live streams with DVR are not currently supported.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement#htmlmediaelement.played\n *\n * @return {number}\n * A decimal between 0 and 1 representing the percent\n * that is played 0 being 0% and 1 being 100%\n */\n playedPercent() {\n if (!Number.isFinite(this.duration())) return NaN;\n\n let timePlayed = 0;\n\n for (let i = 0; i != this.played().length; i++) {\n timePlayed += this.played().end(i) - this.played().start(i);\n }\n\n const percentPlayed = timePlayed / this.duration();\n\n return percentPlayed;\n }\n\n /**\n * Get an array of ranges based on the `played` data.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement#htmlmediaelement.played\n *\n * @returns {Array<{start: number, end: number}>} An array of objects representing start and end points of played ranges.\n */\n playedRanges() {\n const ranges = [];\n\n for (let i = 0; i < this.played().length; i++) {\n const start = this.played().start(i);\n const end = this.played().end(i);\n\n ranges.push({ start, end });\n }\n\n return ranges;\n }\n\n /**\n * Calculates an array of ranges based on the `seekable()` data.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/seekable\n *\n * @returns {Array<{start: number, end: number}>} An array of objects representing start and end points of seekable ranges.\n */\n seekableRanges() {\n const ranges = [];\n\n for (let i = 0; i < this.seekable().length; i++) {\n const start = this.seekable().start(i);\n const end = this.seekable().end(i);\n\n ranges.push({ start, end });\n }\n\n return ranges;\n }\n\n /**\n * A getter/setter for the media's text track.\n * Activates the text track according to the language and kind properties.\n * Falls back on the first text track found if the kind property is not satisfied.\n * Disables all subtitle tracks that are `showing` if the `trackSelector` is truthy but does not satisfy any condition.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/TextTrack/kind\n * @see https://developer.mozilla.org/en-US/docs/Web/API/textTrack/language\n *\n * @param {TrackSelector} [trackSelector]\n *\n * @example\n * // Get the current text track\n * player.textTrack();\n *\n * @example\n * // Disable all text tracks has a side effect\n * player.textTrack('off');\n * player.textTrack({});\n *\n * @example\n * // Activate an text track based on language and kind properties\n * player.textTrack({language:'en', kind:'captions'});\n *\n * @example\n * // Activate first text track found corresponding to language\n * player.textTrack({language:'fr'});\n *\n * @return {TextTrack | undefined} The\n * currently enabled text track. See {@link https://docs.videojs.com/texttrack}.\n */\n textTrack(trackSelector) {\n const textTracks = Array.from(this.player().textTracks()).filter(\n (textTrack) => !['chapters', 'metadata'].includes(textTrack.kind)\n );\n\n if (!trackSelector) {\n return textTracks.find((textTrack) => textTrack.mode === 'showing');\n }\n\n textTracks.forEach((textTrack) => (textTrack.mode = 'disabled'));\n\n const { kind, language } = trackSelector;\n const textTrack =\n textTracks.find((textTrack) => {\n if (textTrack.language === language && textTrack.kind === kind) {\n textTrack.mode = 'showing';\n }\n\n return textTrack.mode === 'showing';\n }) ||\n textTracks.find((textTrack) => {\n if (textTrack.language === language) {\n textTrack.mode = 'showing';\n }\n\n return textTrack.mode === 'showing';\n });\n\n return textTrack;\n }\n}\n\nvideojs.registerComponent('player', Player);\n\nexport default Player;\n","import { version } from '../package.json';\nimport videojs from 'video.js';\nimport './components/player.js';\n\n/**\n * Pillarbox is an alias for the video.js namespace with additional options.\n *\n * @namespace\n * @see https://docs.videojs.com/module-videojs-videojs\n * @type {videojs}\n */\nconst pillarbox = videojs;\n\npillarbox.VERSION = {\n pillarbox: version,\n videojs: videojs.VERSION,\n [videojs.VhsSourceHandler.name]: videojs.VhsSourceHandler.VERSION,\n eme: videojs.getPlugin('eme').VERSION,\n};\n\n/**\n * Enable smooth seeking for Pillarbox.\n *\n * @see [Video.js enableSmoothSeeking Option]{@link https://videojs.com/guides/options/#enablesmoothseeking}\n * @type {boolean}\n * @default true\n */\npillarbox.options.enableSmoothSeeking = true;\n/**\n * Enable fill mode for the video player, allowing it to expand to fill the container.\n *\n * @see [Video.js Fill Option]{@link https://videojs.com/guides/layout/#fill-mode}\n * @type {boolean}\n * @default true\n */\npillarbox.options.fill = true;\n/**\n * Configuration options for HTML5 settings in Pillarbox.\n *\n * @see [VHS useForcedSubtitles Option]{@link https://github.com/videojs/http-streaming/blob/main/README.md#useforcedsubtitles}\n * @type {Object}\n * @property {Object} vhs - Configuration for the Video.js HTTP Streaming.\n * @property {boolean} useForcedSubtitles - Enables the player to display forced subtitles by default.\n * Forced subtitles are pieces of information intended for display when no other text representation\n * is selected. They are used to clarify dialogue, provide alternate languages, display texted graphics,\n * or present location/person IDs that are not otherwise covered in the dubbed/localized audio.\n */\npillarbox.options.html5 = {\n vhs: { useForcedSubtitles: true }\n};\n/**\n * Configuration for the live tracker.\n *\n * @see [Video.js liveTracker Option]{@link https://videojs.com/guides/options/#livetrackertrackingthreshold}\n * @type {Object}\n * @property {number} trackingThreshold - A threshold that controls when the liveui should be shown.\n * @property {number} liveTolerance - An option that controls how far from the seekable end should be considered live playback.\n */\npillarbox.options.liveTracker = {\n trackingThreshold: 120,\n liveTolerance: 15,\n};\n/**\n * Allows the player to use the live ui that includes:\n *\n * - A progress bar for seeking within the live window\n * - A button that can be clicked to seek to the live edge with a circle indicating if you are at the live edge or not.\n *\n * @see [Video.js liveui Option]{@link https://videojs.com/guides/options/#liveui}\n * @type {boolean}\n */\npillarbox.options.liveui = true;\n/**\n * Indicates that the video is to be played \"inline\", that is within the element's playback area.\n *\n * @see [Video element playsinline attribute]{@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video#playsinline}\n * @type {boolean}\n */\npillarbox.options.playsinline = true;\n/**\n * Enable responsive mode, this will cause the player to customize itself based on responsive breakpoints.\n *\n * @see [Video.js Responsive Option]{@link https://videojs.com/guides/options/#responsive}\n * @type {boolean}\n */\npillarbox.options.responsive = true;\n/**\n * A placeholder for accessing trackers directly from the player.\n *\n * @type {Object}\n */\npillarbox.options.trackers = {};\n\nexport default pillarbox;\n"],"names":["vjsPlayer","videojs","getComponent","Player","constructor","tag","options","ready","obj","merge","plugins","eme","audioTrack","trackSelector","audioTracks","Array","from","player","find","enabled","kind","language","bufferedRanges","ranges","i","buffered","length","start","end","push","playedPercent","Number","isFinite","duration","NaN","timePlayed","played","percentPlayed","playedRanges","seekableRanges","seekable","textTrack","textTracks","filter","includes","mode","forEach","registerComponent","pillarbox","VERSION","version","VhsSourceHandler","name","getPlugin","enableSmoothSeeking","fill","html5","vhs","useForcedSubtitles","liveTracker","trackingThreshold","liveTolerance","liveui","playsinline","responsive","trackers"],"mappings":";;;;;AAGA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,MAAMA,SAAS,GAAGC,OAAO,CAACC,YAAY,CAAC,QAAQ,CAAC;;AAEhD;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,MAAM,SAASH,SAAS,CAAC;AAC7BI,EAAAA,WAAWA,CAACC,GAAG,EAAEC,OAAO,EAAEC,KAAK,EAAE;AAC/B;AACJ;AACA;AACA;AACA;AACA;AACA;IACID,OAAO,GAAGL,OAAO,CAACO,GAAG,CAACC,KAAK,CAACH,OAAO,EAAE;AAAEI,MAAAA,OAAO,EAAE;AAAEC,QAAAA,GAAG,EAAE;AAAK;AAAC,KAAC,CAAC;AAC/D,IAAA,KAA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K,GAAG;AACxBC,EAAAA,GAAG,EAAE;AAAEC,IAAAA,kBAAkB,EAAE;AAAK;AAClC,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACAV,SAAS,CAAC1C,OAAO,CAACqD,WAAW,GAAG;AAC9BC,EAAAA,iBAAiB,EAAE,GAAG;AACtBC,EAAAA,aAAa,EAAE;AACjB,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACAb,SAAS,CAAC1C,OAAO,CAACwD,MAAM,GAAG,IAAI;AAC/B;AACA;AACA;AACA;AACA;AACA;AACAd,SAAS,CAAC1C,OAAO,CAACyD,WAAW,GAAG,IAAI;AACpC;AACA;AACA;AACA;AACA;AACA;AACAf,SAAS,CAAC1C,OAAO,CAAC0D,UAAU,GAAG,IAAI;AACnC;AACA;AACA;AACA;AACA;AACAhB,SAAS,CAAC1C,OAAO,CAAC2D,QAAQ,GAAG,EAAE;;;;"}
1
+ {"version":3,"file":"pillarbox-core.es.js","sources":["../src/components/player.js","../src/pillarbox.js"],"sourcesContent":["import videojs from 'video.js';\nimport 'videojs-contrib-eme';\n\n/** @import VJSPlayer from 'video.js/dist/types/player' */\n/** @import AudioTrack from 'video.js/dist/types/tracks/audio-track' */\n/** @import TextTrack from 'video.js/dist/types/tracks/text-track' */\n/** @import {TrackSelector} from './typedef' */\n\n/**\n * @ignore\n * @type {typeof VJSPlayer}\n */\nconst vjsPlayer = videojs.getComponent('player');\n\n/**\n * This class extends the video.js Player.\n *\n * @class Player\n * @see https://docs.videojs.com/player\n */\nclass Player extends vjsPlayer {\n constructor(tag, options, ready) {\n /**\n * Configuration for plugins.\n *\n * @see [Video.js Plugins Option]{@link https://videojs.com/guides/options/#plugins}\n * @type {Object}\n * @property {boolean} eme - Enable the EME (Encrypted Media Extensions) plugin.\n */\n options = videojs.obj.merge(options, { plugins: { eme: true }});\n super(tag, options, ready);\n }\n\n /**\n * A getter/setter for the media's audio track.\n * Activates the audio track according to the language and kind properties.\n * Falls back on the first audio track found if the kind property is not satisfied.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/AudioTrack/kind\n * @see https://developer.mozilla.org/en-US/docs/Web/API/AudioTrack/language\n *\n * @param {TrackSelector} [trackSelector]\n *\n * @example\n * // Get the current audio track\n * player.audioTrack();\n *\n * @example\n * // Activate an audio track based on language and kind properties\n * player.audioTrack({language:'en', kind:'description'});\n *\n * @example\n * // Activate first audio track found corresponding to language\n * player.audioTrack({language:'fr'});\n *\n * @return {AudioTrack | undefined} The\n * currently enabled audio track. See {@link https://docs.videojs.com/audiotrack}.\n */\n audioTrack(trackSelector) {\n const audioTracks = Array.from(this.player().audioTracks());\n\n if (!trackSelector) {\n return audioTracks.find((audioTrack) => audioTrack.enabled);\n }\n\n const { kind, language } = trackSelector;\n const audioTrack =\n audioTracks.find(\n (audioTrack) =>\n audioTrack.language === language && audioTrack.kind === kind\n ) || audioTracks.find((audioTrack) => audioTrack.language === language);\n\n if (audioTrack) {\n audioTrack.enabled = true;\n }\n\n return audioTrack;\n }\n\n /**\n * Calculates an array of ranges based on the `buffered()` data.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/buffered\n *\n * @returns {Array<{start: number, end: number}>} An array of objects representing start and end points of buffered ranges.\n */\n bufferedRanges() {\n const ranges = [];\n\n for (let i = 0; i < this.buffered().length; i++) {\n const start = this.buffered().start(i);\n const end = this.buffered().end(i);\n\n ranges.push({ start, end });\n }\n\n return ranges;\n }\n\n /**\n * Get the percent (as a decimal) of the media that's been played.\n * This method is not a part of the native HTML video API.\n *\n * Live streams with DVR are not currently supported.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement#htmlmediaelement.played\n *\n * @return {number}\n * A decimal between 0 and 1 representing the percent\n * that is played 0 being 0% and 1 being 100%\n */\n playedPercent() {\n if (!Number.isFinite(this.duration())) return NaN;\n\n let timePlayed = 0;\n\n for (let i = 0; i != this.played().length; i++) {\n timePlayed += this.played().end(i) - this.played().start(i);\n }\n\n const percentPlayed = timePlayed / this.duration();\n\n return percentPlayed;\n }\n\n /**\n * Get an array of ranges based on the `played` data.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement#htmlmediaelement.played\n *\n * @returns {Array<{start: number, end: number}>} An array of objects representing start and end points of played ranges.\n */\n playedRanges() {\n const ranges = [];\n\n for (let i = 0; i < this.played().length; i++) {\n const start = this.played().start(i);\n const end = this.played().end(i);\n\n ranges.push({ start, end });\n }\n\n return ranges;\n }\n\n /**\n * Calculates an array of ranges based on the `seekable()` data.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/seekable\n *\n * @returns {Array<{start: number, end: number}>} An array of objects representing start and end points of seekable ranges.\n */\n seekableRanges() {\n const ranges = [];\n\n for (let i = 0; i < this.seekable().length; i++) {\n const start = this.seekable().start(i);\n const end = this.seekable().end(i);\n\n ranges.push({ start, end });\n }\n\n return ranges;\n }\n\n /**\n * Overrides the default `src` behavior to ensure the underlying tech is fully\n * reset before setting a new source.\n *\n * This is a workaround for a Video.js issue where, under certain failure cases the\n * internal `src_` reload logic is not triggered. As a result, the previous media\n * can continue playing in the background even though the new source failed.\n *\n * @see https://docs.videojs.com/player#src\n */\n src(source) {\n if (source) {\n this.poster(null);\n this.techCall_('reset');\n }\n\n super.src(source);\n }\n\n /**\n * A getter/setter for the media's text track.\n * Activates the text track according to the language and kind properties.\n * Falls back on the first text track found if the kind property is not satisfied.\n * Disables all subtitle tracks that are `showing` if the `trackSelector` is truthy but does not satisfy any condition.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/TextTrack/kind\n * @see https://developer.mozilla.org/en-US/docs/Web/API/textTrack/language\n *\n * @param {TrackSelector} [trackSelector]\n *\n * @example\n * // Get the current text track\n * player.textTrack();\n *\n * @example\n * // Disable all text tracks has a side effect\n * player.textTrack('off');\n * player.textTrack({});\n *\n * @example\n * // Activate an text track based on language and kind properties\n * player.textTrack({language:'en', kind:'captions'});\n *\n * @example\n * // Activate first text track found corresponding to language\n * player.textTrack({language:'fr'});\n *\n * @return {TextTrack | undefined} The\n * currently enabled text track. See {@link https://docs.videojs.com/texttrack}.\n */\n textTrack(trackSelector) {\n const textTracks = Array.from(this.player().textTracks()).filter(\n (textTrack) => !['chapters', 'metadata'].includes(textTrack.kind)\n );\n\n if (!trackSelector) {\n return textTracks.find((textTrack) => textTrack.mode === 'showing');\n }\n\n textTracks.forEach((textTrack) => (textTrack.mode = 'disabled'));\n\n const { kind, language } = trackSelector;\n const textTrack =\n textTracks.find((textTrack) => {\n if (textTrack.language === language && textTrack.kind === kind) {\n textTrack.mode = 'showing';\n }\n\n return textTrack.mode === 'showing';\n }) ||\n textTracks.find((textTrack) => {\n if (textTrack.language === language) {\n textTrack.mode = 'showing';\n }\n\n return textTrack.mode === 'showing';\n });\n\n return textTrack;\n }\n}\n\nvideojs.registerComponent('player', Player);\n\nexport default Player;\n","import { version } from '../package.json';\nimport videojs from 'video.js';\nimport './components/player.js';\n\n/**\n * Pillarbox is an alias for the video.js namespace with additional options.\n *\n * @namespace\n * @see https://docs.videojs.com/module-videojs-videojs\n * @type {videojs}\n */\nconst pillarbox = videojs;\n\npillarbox.VERSION = {\n pillarbox: version,\n videojs: videojs.VERSION,\n [videojs.VhsSourceHandler.name]: videojs.VhsSourceHandler.VERSION,\n eme: videojs.getPlugin('eme').VERSION,\n};\n\n/**\n * Enable smooth seeking for Pillarbox.\n *\n * @see [Video.js enableSmoothSeeking Option]{@link https://videojs.com/guides/options/#enablesmoothseeking}\n * @type {boolean}\n * @default true\n */\npillarbox.options.enableSmoothSeeking = true;\n/**\n * Enable fill mode for the video player, allowing it to expand to fill the container.\n *\n * @see [Video.js Fill Option]{@link https://videojs.com/guides/layout/#fill-mode}\n * @type {boolean}\n * @default true\n */\npillarbox.options.fill = true;\n/**\n * Configuration options for HTML5 settings in Pillarbox.\n *\n * @see [VHS useForcedSubtitles Option]{@link https://github.com/videojs/http-streaming/blob/main/README.md#useforcedsubtitles}\n * @type {Object}\n * @property {Object} vhs - Configuration for the Video.js HTTP Streaming.\n * @property {boolean} useForcedSubtitles - Enables the player to display forced subtitles by default.\n * Forced subtitles are pieces of information intended for display when no other text representation\n * is selected. They are used to clarify dialogue, provide alternate languages, display texted graphics,\n * or present location/person IDs that are not otherwise covered in the dubbed/localized audio.\n */\npillarbox.options.html5 = {\n vhs: { useForcedSubtitles: true }\n};\n/**\n * Configuration for the live tracker.\n *\n * @see [Video.js liveTracker Option]{@link https://videojs.com/guides/options/#livetrackertrackingthreshold}\n * @type {Object}\n * @property {number} trackingThreshold - A threshold that controls when the liveui should be shown.\n * @property {number} liveTolerance - An option that controls how far from the seekable end should be considered live playback.\n */\npillarbox.options.liveTracker = {\n trackingThreshold: 120,\n liveTolerance: 15,\n};\n/**\n * Allows the player to use the live ui that includes:\n *\n * - A progress bar for seeking within the live window\n * - A button that can be clicked to seek to the live edge with a circle indicating if you are at the live edge or not.\n *\n * @see [Video.js liveui Option]{@link https://videojs.com/guides/options/#liveui}\n * @type {boolean}\n */\npillarbox.options.liveui = true;\n/**\n * Indicates that the video is to be played \"inline\", that is within the element's playback area.\n *\n * @see [Video element playsinline attribute]{@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video#playsinline}\n * @type {boolean}\n */\npillarbox.options.playsinline = true;\n/**\n * Enable responsive mode, this will cause the player to customize itself based on responsive breakpoints.\n *\n * @see [Video.js Responsive Option]{@link https://videojs.com/guides/options/#responsive}\n * @type {boolean}\n */\npillarbox.options.responsive = true;\n/**\n * A placeholder for accessing trackers directly from the player.\n *\n * @type {Object}\n */\npillarbox.options.trackers = {};\n\nexport default pillarbox;\n"],"names":["vjsPlayer","videojs","getComponent","Player","constructor","tag","options","ready","obj","merge","plugins","eme","audioTrack","trackSelector","audioTracks","Array","from","player","find","enabled","kind","language","bufferedRanges","ranges","i","buffered","length","start","end","push","playedPercent","Number","isFinite","duration","NaN","timePlayed","played","percentPlayed","playedRanges","seekableRanges","seekable","src","source","poster","techCall_","textTrack","textTracks","filter","includes","mode","forEach","registerComponent","pillarbox","VERSION","version","VhsSourceHandler","name","getPlugin","enableSmoothSeeking","fill","html5","vhs","useForcedSubtitles","liveTracker","trackingThreshold","liveTolerance","liveui","playsinline","responsive","trackers"],"mappings":";;;;;AAGA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,MAAMA,SAAS,GAAGC,OAAO,CAACC,YAAY,CAAC,QAAQ,CAAC;;AAEhD;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,MAAM,SAASH,SAAS,CAAC;AAC7BI,EAAAA,WAAWA,CAACC,GAAG,EAAEC,OAAO,EAAEC,KAAK,EAAE;AAC/B;AACJ;AACA;AACA;AACA;AACA;AACA;IACID,OAAO,GAAGL,OAAO,CAACO,GAAG,CAACC,KAAK,CAACH,OAAO,EAAE;AAAEI,MAAAA,OAAO,EAAE;AAAEC,QAAAA,GAAG,EAAE;AAAK;AAAC,KAAC,CAAC;AAC/D,IAAA,KAAK,CAACN,GAAG,EAAEC,OAAO,EAAEC,KAAK,CAAC;AAC5B,EAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEK,UAAUA,CAACC,aAAa,EAAE;AACxB,IAAA,MAAMC,WAAW,GAAGC,KAAK,CAACC,IAAI,CAAC,IAAI,CAACC,MAAM,EAAE,CAACH,WAAW,EAAE,CAAC;IAE3D,IAAI,CAACD,aAAa,EAAE;MAClB,OAAOC,WAAW,CAACI,IAAI,CAAEN,UAAU,IAAKA,UAAU,CAACO,OAAO,CAAC;AAC7D,IAAA;IAEA,MAAM;MAAEC,IAAI;AAAEC,MAAAA;AAAS,KAAC,GAAGR,aAAa;AACxC,IAAA,MAAMD,UAAU,GACdE,WAAW,CAACI,IAAI,CACbN,UAAU,IACTA,UAAU,CAACS,QAAQ,KAAKA,QAAQ,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M,GAAG,IAAI;AAC/B;AACA;AACA;AACA;AACA;AACA;AACAd,SAAS,CAAC9C,OAAO,CAAC6D,WAAW,GAAG,IAAI;AACpC;AACA;AACA;AACA;AACA;AACA;AACAf,SAAS,CAAC9C,OAAO,CAAC8D,UAAU,GAAG,IAAI;AACnC;AACA;AACA;AACA;AACA;AACAhB,SAAS,CAAC9C,OAAO,CAAC+D,QAAQ,GAAG,EAAE;;;;"}
@@ -94,7 +94,7 @@ function _toPropertyKey(t) {
94
94
  return "symbol" == typeof i ? i : i + "";
95
95
  }
96
96
 
97
- const version = "1.25.0";
97
+ const version = "1.26.0";
98
98
 
99
99
  /** @import VJSPlayer from 'video.js/dist/types/player' */
100
100
  /** @import AudioTrack from 'video.js/dist/types/tracks/audio-track' */
@@ -253,6 +253,24 @@ class Player extends vjsPlayer {
253
253
  return ranges;
254
254
  }
255
255
 
256
+ /**
257
+ * Overrides the default `src` behavior to ensure the underlying tech is fully
258
+ * reset before setting a new source.
259
+ *
260
+ * This is a workaround for a Video.js issue where, under certain failure cases the
261
+ * internal `src_` reload logic is not triggered. As a result, the previous media
262
+ * can continue playing in the background even though the new source failed.
263
+ *
264
+ * @see https://docs.videojs.com/player#src
265
+ */
266
+ src(source) {
267
+ if (source) {
268
+ this.poster(null);
269
+ this.techCall_('reset');
270
+ }
271
+ super.src(source);
272
+ }
273
+
256
274
  /**
257
275
  * A getter/setter for the media's text track.
258
276
  * Activates the text track according to the language and kind properties.
@@ -2762,6 +2780,8 @@ class MediaComposition {
2762
2780
  tokenType: resource.tokenType,
2763
2781
  url: resource.url,
2764
2782
  urn: this.chapterUrn,
2783
+ validFrom: this.getMainValidFromDate(),
2784
+ validTo: this.getMainValidToDate(),
2765
2785
  vendor: this.getMainChapter().vendor
2766
2786
  }));
2767
2787
  }
@@ -2794,19 +2814,27 @@ class MediaComposition {
2794
2814
  /**
2795
2815
  * Compute a date from which this content is valid. Always return a date object.
2796
2816
  *
2797
- * @returns {Date} date specified in media composition or EPOCH when no date present.
2817
+ * @returns {Date} date specified in media composition or undefined.
2798
2818
  */
2799
2819
  getMainValidFromDate() {
2800
- const mainChapter = this.getMainChapter();
2801
- if (!mainChapter) {
2802
- return new Date(0);
2803
- }
2804
2820
  const {
2805
2821
  validFrom
2806
- } = mainChapter;
2807
- if (validFrom) {
2808
- return new Date(validFrom);
2809
- }
2822
+ } = this.getMainChapter() || {};
2823
+ if (!validFrom) return;
2824
+ return new Date(validFrom);
2825
+ }
2826
+
2827
+ /**
2828
+ * Compute a date to which this content is valid. Always return a date object.
2829
+ *
2830
+ * @returns {Date} date specified in media composition or undefined.
2831
+ */
2832
+ getMainValidToDate() {
2833
+ const {
2834
+ validTo
2835
+ } = this.getMainChapter() || {};
2836
+ if (!validTo) return;
2837
+ return new Date(validTo);
2810
2838
  }
2811
2839
 
2812
2840
  /**