diff --git a/docs/creating-content.md b/docs/creating-content.md index c030f09d8..c1b1b9493 100644 --- a/docs/creating-content.md +++ b/docs/creating-content.md @@ -2,7 +2,7 @@ ## Commands for creating tests streams -### Streams with EXT-X-PROGRAM-DATE-TIME for testing seekToStreamTime and convertToStreamTime +### Streams with EXT-X-PROGRAM-DATE-TIME for testing seekToProgramTime and convertToProgramTime lavfi and testsrc are provided for creating a test stream in ffmpeg -g 300 sets the GOP size to 300 (keyframe interval, at 30fps, one keyframe every 10 seconds) diff --git a/docs/program-time-from-player-time.md b/docs/program-time-from-player-time.md index e7d4cf500..c2ddb4016 100644 --- a/docs/program-time-from-player-time.md +++ b/docs/program-time-from-player-time.md @@ -13,7 +13,7 @@ NOTE: All times referenced in seconds unless otherwise specified. In order to convert from a *player time* to a *stream time*, an "anchor point" is required to match up a *player time*, *stream time*, and *program time*. -Two anchor points that are usable are the time since the start of a new timeline (e.g., the time since the last discontinuity or start of the stream), and the start of a segment. Because, in our requirements for this conversion, each segment is tagged with its *program time* in the form of an [EXT-X-PROGRAM-DATE-TIME tag](https://tools.ietf.org/html/draft-pantos-http-live-streaming-23#section-4.3.2.6), using the segment start as the anchor point is the easiest solution. It's the closest potential anchor point to the time to convert, and it doesn't require us to track time changes across segments. +Two anchor points that are usable are the time since the start of a new timeline (e.g., the time since the last discontinuity or start of the stream), and the start of a segment. Because, in our requirements for this conversion, each segment is tagged with its *program time* in the form of an [EXT-X-PROGRAM-DATE-TIME tag](https://tools.ietf.org/html/draft-pantos-http-live-streaming-23#section-4.3.2.6), using the segment start as the anchor point is the easiest solution. It's the closest potential anchor point to the time to convert, and it doesn't require us to track time changes across segments (e.g., trimmed or prepended content). Those time changes are the result of the transmuxer, which can add/remove content in order to keep the content playable (without gaps or other breaking changes between segments), particularly when a segment doesn't start with a key frame. diff --git a/src/util/time.js b/src/util/time.js index 553a34779..d849ba054 100644 --- a/src/util/time.js +++ b/src/util/time.js @@ -52,10 +52,10 @@ export const originalSegmentVideoDuration = (videoTimingInfo) => { * Finds a segment that contains the time requested given as an ISO-8601 string. The * returned segment might be an estimate or an accurate match. * - * @param {String} streamTime The ISO-8601 streamTime to find a match for + * @param {String} programTime The ISO-8601 programTime to find a match for * @param {Object} playlist A playlist object to search within */ -export const findSegmentForStreamTime = (streamTime, playlist) => { +export const findSegmentForProgramTime = (programTime, playlist) => { // Assumptions: // - verifyProgramDateTimeTags has already been run // - live streams have been started @@ -63,7 +63,7 @@ export const findSegmentForStreamTime = (streamTime, playlist) => { let dateTimeObject; try { - dateTimeObject = new Date(streamTime); + dateTimeObject = new Date(programTime); } catch (e) { return null; } @@ -191,29 +191,30 @@ export const findSegmentForPlayerTime = (time, playlist) => { }; /** - * Gives the offset of the comparisonTimestamp from the streamTime timestamp in seconds. - * If the offset returned is positive, the streamTime occurs before the comparisonTimestamp. - * If the offset is negative, the streamTime occurs before the comparisonTimestamp. + * Gives the offset of the comparisonTimestamp from the programTime timestamp in seconds. + * If the offset returned is positive, the programTime occurs after the + * comparisonTimestamp. + * If the offset is negative, the programTime occurs before the comparisonTimestamp. * * @param {String} comparisonTimeStamp An ISO-8601 timestamp to compare against - * @param {String} streamTime The streamTime as an ISO-8601 string + * @param {String} programTime The programTime as an ISO-8601 string * @return {Number} offset */ -export const getOffsetFromTimestamp = (comparisonTimeStamp, streamTime) => { +export const getOffsetFromTimestamp = (comparisonTimeStamp, programTime) => { let segmentDateTime; - let streamDateTime; + let programDateTime; try { segmentDateTime = new Date(comparisonTimeStamp); - streamDateTime = new Date(streamTime); + programDateTime = new Date(programTime); } catch (e) { // TODO handle error } const segmentTimeEpoch = segmentDateTime.getTime(); - const streamTimeEpoch = streamDateTime.getTime(); + const programTimeEpoch = programDateTime.getTime(); - return (streamTimeEpoch - segmentTimeEpoch) / 1000; + return (programTimeEpoch - segmentTimeEpoch) / 1000; }; /** @@ -238,7 +239,7 @@ export const verifyProgramDateTimeTags = (playlist) => { }; /** - * Returns the streamTime of the media given a playlist and a playerTime. + * Returns the programTime of the media given a playlist and a playerTime. * The playlist must have programDateTime tags for a programDateTime tag to be returned. * If the segments containing the time requested have not been buffered yet, an estimate * may be returned to the callback. @@ -246,25 +247,25 @@ export const verifyProgramDateTimeTags = (playlist) => { * @param {Object} args * @param {Object} args.playlist A playlist object to search within * @param {Number} time A playerTime in seconds - * @param {Function} callback(err, streamTime) + * @param {Function} callback(err, programTime) * @returns {String} err.message A detailed error message - * @returns {Object} streamTime - * @returns {Number} streamTime.mediaSeconds The streamTime in seconds - * @returns {String} streamTime.programDateTime The streamTime as an ISO-8601 String + * @returns {Object} programTime + * @returns {Number} programTime.mediaSeconds The streamTime in seconds + * @returns {String} programTime.programDateTime The programTime as an ISO-8601 String */ -export const getStreamTime = ({ +export const getProgramTime = ({ playlist, time = undefined, callback }) => { if (!callback) { - throw new Error('getStreamTime: callback must be provided'); + throw new Error('getProgramTime: callback must be provided'); } if (!playlist || time === undefined) { return callback({ - message: 'getStreamTime: playlist and time must be provided' + message: 'getProgramTime: playlist and time must be provided' }); } @@ -272,14 +273,14 @@ export const getStreamTime = ({ if (!matchedSegment) { return callback({ - message: 'valid streamTime was not found' + message: 'valid programTime was not found' }); } if (matchedSegment.type === 'estimate') { return callback({ message: - 'Accurate streamTime could not be determined.' + + 'Accurate programTime could not be determined.' + ' Please seek to e.seekTime and try again', seekTime: matchedSegment.estimatedStart }); @@ -298,10 +299,10 @@ export const getStreamTime = ({ }; /** - * Seeks in the player to a time that matches the given streamTime ISO-8601 string. + * Seeks in the player to a time that matches the given programTime ISO-8601 string. * * @param {Object} args - * @param {String} args.streamTime A streamTime to seek to as an ISO-8601 String + * @param {String} args.programTime A programTime to seek to as an ISO-8601 String * @param {Object} args.playlist A playlist to look within * @param {Number} args.retryCount The number of times to try for an accurate seek. Default is 2. * @param {Function} args.seekTo A method to perform a seek @@ -311,8 +312,8 @@ export const getStreamTime = ({ * @returns {String} err.message A detailed error message * @returns {Number} newTime The exact time that was seeked to in seconds */ -export const seekToStreamTime = ({ - streamTime, +export const seekToProgramTime = ({ + programTime, playlist, retryCount = 2, seekTo, @@ -322,12 +323,12 @@ export const seekToStreamTime = ({ }) => { if (!callback) { - throw new Error('seekToStreamTime: callback must be provided'); + throw new Error('seekToProgramTime: callback must be provided'); } - if (typeof streamTime === 'undefined' || !playlist || !seekTo) { + if (typeof programTime === 'undefined' || !playlist || !seekTo) { return callback({ - message: 'seekToStreamTime: streamTime, seekTo and playlist must be provided' + message: 'seekToProgramTime: programTime, seekTo and playlist must be provided' }); } @@ -343,34 +344,34 @@ export const seekToStreamTime = ({ }); } - const matchedSegment = findSegmentForStreamTime(streamTime, playlist); + const matchedSegment = findSegmentForProgramTime(programTime, playlist); // no match if (!matchedSegment) { return callback({ - message: `${streamTime} was not found in the stream` + message: `${programTime} was not found in the stream` }); } const segment = matchedSegment.segment; const mediaOffset = getOffsetFromTimestamp( segment.dateTimeObject, - streamTime + programTime ); if (matchedSegment.type === 'estimate') { // we've run out of retries if (retryCount === 0) { return callback({ - message: `${streamTime} is not buffered yet. Try again` + message: `${programTime} is not buffered yet. Try again` }); } seekTo(matchedSegment.estimatedStart + mediaOffset); tech.one('seeked', () => { - seekToStreamTime({ - streamTime, + seekToProgramTime({ + programTime, playlist, retryCount: retryCount - 1, seekTo, diff --git a/src/videojs-http-streaming.js b/src/videojs-http-streaming.js index b59bd354d..d7d587abb 100644 --- a/src/videojs-http-streaming.js +++ b/src/videojs-http-streaming.js @@ -11,8 +11,8 @@ import xhrFactory from './xhr'; import { Decrypter, AsyncStream, decrypt } from 'aes-decrypter'; import * as utils from './bin-utils'; import { - getStreamTime, - seekToStreamTime + getProgramTime, + seekToProgramTime } from './util/time'; import { timeRangesToArray } from './ranges'; import { MediaSource, URL } from './mse/index'; @@ -753,8 +753,8 @@ class HlsHandler extends Component { super.dispose(); } - convertToStreamTime(time, callback) { - return getStreamTime({ + convertToProgramTime(time, callback) { + return getProgramTime({ playlist: this.masterPlaylistController_.media(), time, callback @@ -762,9 +762,9 @@ class HlsHandler extends Component { } // the player must be playing before calling this - seekToStreamTime(streamTime, callback, pauseAfterSeek = true, retryCount = 2) { - return seekToStreamTime({ - streamTime, + seekToProgramTime(programTime, callback, pauseAfterSeek = true, retryCount = 2) { + return seekToProgramTime({ + programTime, playlist: this.masterPlaylistController_.media(), retryCount, pauseAfterSeek, diff --git a/test/util/time.test.js b/test/util/time.test.js index 9ec5831d4..9647ab51e 100644 --- a/test/util/time.test.js +++ b/test/util/time.test.js @@ -1,11 +1,11 @@ import QUnit from 'qunit'; import videojs from 'video.js'; import { - getStreamTime, - seekToStreamTime, + getProgramTime, + seekToProgramTime, verifyProgramDateTimeTags, findSegmentForPlayerTime, - findSegmentForStreamTime, + findSegmentForProgramTime, getOffsetFromTimestamp, originalSegmentVideoDuration, playerTimeToProgramTime @@ -251,14 +251,15 @@ function(assert) { ); }); -QUnit.test('findSegmentForStreamTime returns nothing if a match cannot be found', function(assert) { +QUnit.test('findSegmentForProgramTime returns nothing if a match cannot be found', +function(assert) { assert.equal( - findSegmentForStreamTime('2018-11-10T19:39:57.158Z', {}), + findSegmentForProgramTime('2018-11-10T19:39:57.158Z', {}), null, 'returns nothing if empty playlist' ); assert.equal( - findSegmentForStreamTime('2018-11-10T19:39:57.158Z', { + findSegmentForProgramTime('2018-11-10T19:39:57.158Z', { segments: [], targetDuration: 1 }), @@ -266,7 +267,7 @@ QUnit.test('findSegmentForStreamTime returns nothing if a match cannot be found' 'returns nothing if empty segment list' ); assert.equal( - findSegmentForStreamTime('2018-11-10T19:40:57.158Z', { + findSegmentForProgramTime('2018-11-10T19:40:57.158Z', { segments: [{ videoTimingInfo: { transmuxerPrependedSeconds: 0, @@ -283,7 +284,7 @@ QUnit.test('findSegmentForStreamTime returns nothing if a match cannot be found' ); }); -QUnit.test('findSegmentForStreamTime returns estimate if last segment and not buffered', +QUnit.test('findSegmentForProgramTime returns estimate if last segment and not buffered', function(assert) { const segment = { duration: 1, @@ -291,7 +292,7 @@ function(assert) { }; assert.deepEqual( - findSegmentForStreamTime('2018-11-10T19:38:57.200Z', { + findSegmentForProgramTime('2018-11-10T19:38:57.200Z', { segments: [segment] }), { @@ -303,7 +304,8 @@ function(assert) { ); }); -QUnit.test('findSegmentForStreamTime returns estimate if not buffered', function(assert) { +QUnit.test('findSegmentForProgramTime returns estimate if not buffered', +function(assert) { const segment1 = { duration: 1, dateTimeObject: new Date('2018-11-10T19:38:57.158Z') @@ -314,7 +316,7 @@ QUnit.test('findSegmentForStreamTime returns estimate if not buffered', function }; assert.deepEqual( - findSegmentForStreamTime('2018-11-10T19:38:57.200Z', { + findSegmentForProgramTime('2018-11-10T19:38:57.200Z', { segments: [segment1, segment2] }), { @@ -326,7 +328,8 @@ QUnit.test('findSegmentForStreamTime returns estimate if not buffered', function ); }); -QUnit.test('findSegmentForStreamTime returns accurate match if buffered', function(assert) { +QUnit.test('findSegmentForProgramTime returns accurate match if buffered', +function(assert) { const segment = { videoTimingInfo: { transmuxerPrependedSeconds: 0, @@ -338,7 +341,7 @@ QUnit.test('findSegmentForStreamTime returns accurate match if buffered', functi }; assert.deepEqual( - findSegmentForStreamTime('2018-11-10T19:38:57.200Z', { + findSegmentForProgramTime('2018-11-10T19:38:57.200Z', { segments: [segment] }), { @@ -350,7 +353,7 @@ QUnit.test('findSegmentForStreamTime returns accurate match if buffered', functi ); }); -QUnit.test('findSegmentForStreamTime returns accurate last segment', function(assert) { +QUnit.test('findSegmentForProgramTime returns accurate last segment', function(assert) { const playlist = { mediaSequence: 0, segments: [{ @@ -373,7 +376,7 @@ QUnit.test('findSegmentForStreamTime returns accurate last segment', function(as }; assert.deepEqual( - findSegmentForStreamTime('2018-11-10T19:38:58.200Z', playlist), + findSegmentForProgramTime('2018-11-10T19:38:58.200Z', playlist), { type: 'accurate', segment: playlist.segments[1], @@ -384,7 +387,7 @@ QUnit.test('findSegmentForStreamTime returns accurate last segment', function(as }); QUnit.test( -'findSegmentForStreamTime returns null if beyond last segment and segment transmuxed', +'findSegmentForProgramTime returns null if beyond last segment and segment transmuxed', function(assert) { const playlist = { mediaSequence: 0, @@ -408,13 +411,13 @@ function(assert) { }; assert.deepEqual( - findSegmentForStreamTime('2018-11-10T19:38:59.200Z', playlist), + findSegmentForProgramTime('2018-11-10T19:38:59.200Z', playlist), null, 'returns null if beyond the transmuxed last segment' ); }); -QUnit.test('findSegmentForStreamTime returns estimated last segment', function(assert) { +QUnit.test('findSegmentForProgramTime returns estimated last segment', function(assert) { const playlist = { mediaSequence: 0, segments: [{ @@ -433,11 +436,11 @@ QUnit.test('findSegmentForStreamTime returns estimated last segment', function(a // 25% of last segment duration + last segment duration on top of last segment start // to test allowed fudge - const streamTime = + const programTime = new Date(playlist.segments[1].dateTimeObject.getTime() + 1.25 * 1000); assert.deepEqual( - findSegmentForStreamTime(streamTime.toISOString(), playlist), + findSegmentForProgramTime(programTime.toISOString(), playlist), { type: 'estimate', segment: playlist.segments[1], @@ -448,7 +451,8 @@ QUnit.test('findSegmentForStreamTime returns estimated last segment', function(a }); QUnit.test( -'findSegmentForStreamTime returns null if beyond last segment and segment not transmuxed', +'findSegmentForProgramTime returns null if beyond last segment and' + +' segment not transmuxed', function(assert) { const playlist = { mediaSequence: 0, @@ -467,11 +471,11 @@ function(assert) { }; // just over allowed fudge of 25% - const streamTime = + const programTime = new Date(playlist.segments[1].dateTimeObject.getTime() + 1.26 * 1000); assert.equal( - findSegmentForStreamTime(streamTime.toISOString(), playlist), + findSegmentForProgramTime(programTime.toISOString(), playlist), null, 'returns null if beyond the non transmuxed last segment' ); @@ -493,7 +497,7 @@ QUnit.test('getOffsetFromTimestamp will calculate second differences in timestam assert.equal( getOffsetFromTimestamp('2018-11-10T19:38:57.158Z', '2018-11-10T19:38:56.158Z'), -1, - 'negative offset returned if streamTime is before comparison timestamp' + 'negative offset returned if programTime is before comparison timestamp' ); }); @@ -580,7 +584,7 @@ function(assert) { ); }); -QUnit.module('Time: getStreamTime', { +QUnit.module('Time: getProgramTime', { beforeEach(assert) { this.playlist = { mediaSequence: 0, @@ -607,24 +611,24 @@ QUnit.test('returns error if playlist or time is not provided', function(assert) const done = assert.async(); const done2 = assert.async(); - getStreamTime({ + getProgramTime({ time: 1, - callback: (err, streamTime) => { + callback: (err, programTime) => { assert.equal( err.message, - 'getStreamTime: playlist and time must be provided', + 'getProgramTime: playlist and time must be provided', 'error message is returned when no playlist provided' ); done(); } }); - getStreamTime({ + getProgramTime({ playlist: this.playlist, - callback: (err, streamTime) => { + callback: (err, programTime) => { assert.equal( err.message, - 'getStreamTime: playlist and time must be provided', + 'getProgramTime: playlist and time must be provided', 'error message is returned when no playlist provided' ); done2(); @@ -635,12 +639,12 @@ QUnit.test('returns error if playlist or time is not provided', function(assert) QUnit.test('throws error if no callback is provided', function(assert) { assert.throws( () => { - return getStreamTime({ + return getProgramTime({ time: 1, playlist: this.playlist }); }, - /getStreamTime: callback must be provided/, + /getProgramTime: callback must be provided/, 'throws error if callback is not provided' ); }); @@ -649,25 +653,25 @@ QUnit.test('returns info to accept callback if accurate value can be returned', function(assert) { const done = assert.async(); - getStreamTime({ + getProgramTime({ playlist: this.playlist, time: 6, - callback: (err, streamTime) => { + callback: (err, programTime) => { assert.notOk( err, 'should not fail when accurate segment times are available' ); assert.equal( - typeof streamTime, + typeof programTime, 'object', 'should return an object to onsuccess callback' ); assert.ok( - streamTime.mediaSeconds !== undefined, + programTime.mediaSeconds !== undefined, 'mediaSeconds is passed to onsuccess' ); assert.ok( - streamTime.programDateTime !== undefined, + programTime.programDateTime !== undefined, 'programDateTime is passed to onsuccess' ); @@ -676,7 +680,7 @@ function(assert) { new Date(this.playlist.segments[0].dateTimeObject.getTime() + 6 * 1000); assert.equal( - streamTime.programDateTime, + programTime.programDateTime, expectedDateTime.toISOString(), 'uses programDateTime found in media segments' ); @@ -706,13 +710,14 @@ function(assert) { ] }; - getStreamTime({ + getProgramTime({ playlist, time: 2, - callback: (err, streamTime) => { + callback: (err, programTime) => { assert.equal( err.message, - 'Accurate streamTime could not be determined. Please seek to e.seekTime and try again', + 'Accurate programTime could not be determined.' + + ' Please seek to e.seekTime and try again', 'error message is returned for seekTime' ); assert.equal( @@ -739,13 +744,13 @@ QUnit.test('returns time if no modifications', function(assert) { ] }; - getStreamTime({ + getProgramTime({ playlist, time: 3, - callback: (err, streamTime) => { + callback: (err, programTime) => { assert.equal(err, null, 'no error'); assert.equal( - streamTime.mediaSeconds, + programTime.mediaSeconds, 3, 'mediaSeconds is currentTime if no further modifications' ); @@ -768,13 +773,13 @@ QUnit.test('returns programDateTime parsed from media segment tags', function(as ] }; - getStreamTime({ + getProgramTime({ playlist, time: 0, - callback: (err, streamTime) => { + callback: (err, programTime) => { assert.equal(err, null, 'no error'); assert.equal( - streamTime.programDateTime, + programTime.programDateTime, playlist.segments[0].dateTimeString, 'uses programDateTime found in media segments' ); @@ -783,7 +788,7 @@ QUnit.test('returns programDateTime parsed from media segment tags', function(as }); }); -QUnit.module('Time: seekToStreamTime', { +QUnit.module('Time: seekToProgramTime', { beforeEach(assert) { this.seekTo = () => {}; this.ct = 0; @@ -808,47 +813,47 @@ QUnit.module('Time: seekToStreamTime', { } }); -QUnit.test('returns error if no playlist or streamTime provided', function(assert) { +QUnit.test('returns error if no playlist or programTime provided', function(assert) { const done = assert.async(); const done2 = assert.async(); const done3 = assert.async(); - seekToStreamTime({ - streamTime: 0, + seekToProgramTime({ + programTime: 0, seekTo: this.seekTo, tech: this.tech, callback: (err, newTime) => { assert.equal( err.message, - 'seekToStreamTime: streamTime, seekTo and playlist must be provided', + 'seekToProgramTime: programTime, seekTo and playlist must be provided', 'error message is returned when no playlist is provided' ); done(); } }); - seekToStreamTime({ + seekToProgramTime({ playlist: {}, seekTo: this.seekTo, tech: this.tech, callback: (err, newTime) => { assert.equal( err.message, - 'seekToStreamTime: streamTime, seekTo and playlist must be provided', + 'seekToProgramTime: programTime, seekTo and playlist must be provided', 'error message is returned when no time is provided' ); done2(); } }); - seekToStreamTime({ - streamTime: 0, + seekToProgramTime({ + programTime: 0, playlist: {}, tech: this.tech, callback: (err, newTime) => { assert.equal( err.message, - 'seekToStreamTime: streamTime, seekTo and playlist must be provided', + 'seekToProgramTime: programTime, seekTo and playlist must be provided', 'error message is returned when no seekTo method is provided' ); done3(); @@ -859,8 +864,8 @@ QUnit.test('returns error if no playlist or streamTime provided', function(asser QUnit.test('throws error if no callback is provided', function(assert) { assert.throws( () => { - return seekToStreamTime({ - streamTime: 1, + return seekToProgramTime({ + programTime: 1, playlist: {}, seekTo: this.seekTo, tech: this.tech @@ -875,8 +880,8 @@ function(assert) { const done = assert.async(); const done2 = assert.async(); - seekToStreamTime({ - streamTime: 1, + seekToProgramTime({ + programTime: 1, playlist: { segments: [], resolvedUri: 'test' @@ -898,8 +903,8 @@ function(assert) { } }); - seekToStreamTime({ - streamTime: 1, + seekToProgramTime({ + programTime: 1, playlist: { segments: [ { @@ -937,8 +942,8 @@ QUnit.test('returns error if live stream has not started', function(assert) { hasStarted_: false }); - seekToStreamTime({ - streamTime: 1, + seekToProgramTime({ + programTime: 1, playlist: { segments: [], resolvedUri: 'test' @@ -960,8 +965,8 @@ QUnit.test('returns error if live stream has not started', function(assert) { QUnit.test('returns error if time does not exist in live stream', function(assert) { const done = assert.async(); - seekToStreamTime({ - streamTime: '2018-10-12T22:33:52.037+00:00', + seekToProgramTime({ + programTime: '2018-10-12T22:33:52.037+00:00', playlist: { segments: [{ dateTimeString: '2018-10-12T22:33:49.037+00:00', @@ -1007,8 +1012,8 @@ QUnit.test('vod: seeks and returns player time seeked to if buffered', function( tech.currentTime(t); }; - seekToStreamTime({ - streamTime: '2018-10-12T22:33:50.037+00:00', + seekToProgramTime({ + programTime: '2018-10-12T22:33:50.037+00:00', playlist: { segments: [ { @@ -1073,8 +1078,8 @@ QUnit.test('vod: does not account for prepended content duration', function(asse tech.currentTime(t); }; - seekToStreamTime({ - streamTime: '2018-10-12T22:33:51.037+00:00', + seekToProgramTime({ + programTime: '2018-10-12T22:33:51.037+00:00', playlist: { segments: [ { @@ -1139,8 +1144,8 @@ QUnit.test('live: seeks and returns player time seeked to if buffered', function tech.currentTime(t); }; - seekToStreamTime({ - streamTime: '2018-10-12T22:33:50.037+00:00', + seekToProgramTime({ + programTime: '2018-10-12T22:33:50.037+00:00', playlist: { segments: [ { @@ -1204,8 +1209,8 @@ QUnit.test('setting pauseAfterSeek to false seeks without pausing', function(ass tech.currentTime(t); }; - seekToStreamTime({ - streamTime: '2018-10-12T22:33:50.037+00:00', + seekToProgramTime({ + programTime: '2018-10-12T22:33:50.037+00:00', playlist: { segments: [ { diff --git a/test/videojs-http-streaming.test.js b/test/videojs-http-streaming.test.js index 0e97dafa6..c1b4aa5a8 100644 --- a/test/videojs-http-streaming.test.js +++ b/test/videojs-http-streaming.test.js @@ -3212,7 +3212,8 @@ function(assert) { videojs.options.hls = origHlsOptions; }); -QUnit.test('convertToStreamTime will return error if time is not buffered', function(assert) { +QUnit.test('convertToProgramTime will return error if time is not buffered', +function(assert) { const done = assert.async(); this.player.src({ @@ -3228,12 +3229,13 @@ QUnit.test('convertToStreamTime will return error if time is not buffered', func // ts this.standardXHRResponse(this.requests.shift()); - this.player.vhs.convertToStreamTime(3, (err, streamTime) => { + this.player.vhs.convertToProgramTime(3, (err, programTime) => { assert.deepEqual( err, { message: - 'Accurate streamTime could not be determined. Please seek to e.seekTime and try again', + 'Accurate programTime could not be determined.' + + ' Please seek to e.seekTime and try again', seekTime: 0 }, 'error is returned as time is not buffered' @@ -3242,7 +3244,7 @@ QUnit.test('convertToStreamTime will return error if time is not buffered', func }); }); -QUnit.test('convertToStreamTime will return stream time if buffered', function(assert) { +QUnit.test('convertToProgramTime will return stream time if buffered', function(assert) { const done = assert.async(); this.player.src({ @@ -3287,18 +3289,19 @@ QUnit.test('convertToStreamTime will return stream time if buffered', function(a // ts this.standardXHRResponse(this.requests[3], muxedSegment()); - this.player.vhs.convertToStreamTime(0.01, (err, streamTime) => { + this.player.vhs.convertToProgramTime(0.01, (err, programTime) => { assert.notOk(err, 'no errors'); assert.equal( - streamTime.mediaSeconds, + programTime.mediaSeconds, 0.01, - 'returned the streamTime of the source' + 'returned the stream time of the source' ); done(); }); }); -QUnit.test('seekToStreamTime will error if live stream has not started', function(assert) { +QUnit.test('seekToProgramTime will error if live stream has not started', +function(assert) { this.player.src({ src: 'manifest/program-date-time.m3u8', type: 'application/x-mpegurl' @@ -3309,7 +3312,7 @@ QUnit.test('seekToStreamTime will error if live stream has not started', functio // media this.standardXHRResponse(this.requests.shift()); - this.player.vhs.seekToStreamTime( + this.player.vhs.seekToProgramTime( '2018-10-12T22:33:49.037+00:00', (err, newTime) => { assert.equal( @@ -3328,7 +3331,7 @@ QUnit.test('seekToStreamTime will error if live stream has not started', functio // ts this.standardXHRResponse(this.requests.shift(), muxedSegment()); - this.player.vhs.seekToStreamTime( + this.player.vhs.seekToProgramTime( '2018-10-12T22:33:49.037+00:00', (err, newTime) => { assert.equal( @@ -3340,7 +3343,7 @@ QUnit.test('seekToStreamTime will error if live stream has not started', functio ); }); -QUnit.test('seekToStreamTime will seek to time if buffered', function(assert) { +QUnit.test('seekToProgramTime will seek to time if buffered', function(assert) { const done = assert.async(); this.player.src({ @@ -3383,7 +3386,7 @@ QUnit.test('seekToStreamTime will seek to time if buffered', function(assert) { videoBuffer.trigger('updateend'); this.clock.tick(1); - this.player.vhs.seekToStreamTime( + this.player.vhs.seekToProgramTime( '2018-10-12T22:33:49.037+00:00', (err, newTime) => { assert.notOk(