shaka-player 4.7.12 → 4.8.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.
Files changed (120) hide show
  1. package/AUTHORS +1 -0
  2. package/CONTRIBUTORS +1 -0
  3. package/LICENSE +54 -0
  4. package/README.md +22 -1
  5. package/dist/controls.css +1 -1
  6. package/dist/controls.css.map +1 -1
  7. package/dist/deps.js +36 -25
  8. package/dist/locales.js +40 -30
  9. package/dist/shaka-player.compiled.d.ts +196 -46
  10. package/dist/shaka-player.compiled.debug.d.ts +196 -46
  11. package/dist/shaka-player.compiled.debug.externs.js +474 -337
  12. package/dist/shaka-player.compiled.debug.js +992 -871
  13. package/dist/shaka-player.compiled.debug.map +4 -4
  14. package/dist/shaka-player.compiled.externs.js +474 -337
  15. package/dist/shaka-player.compiled.js +1248 -1174
  16. package/dist/shaka-player.compiled.map +4 -4
  17. package/dist/shaka-player.ui.d.ts +259 -49
  18. package/dist/shaka-player.ui.debug.d.ts +259 -49
  19. package/dist/shaka-player.ui.debug.externs.js +591 -376
  20. package/dist/shaka-player.ui.debug.js +1208 -1003
  21. package/dist/shaka-player.ui.debug.map +4 -4
  22. package/dist/shaka-player.ui.externs.js +591 -376
  23. package/dist/shaka-player.ui.js +1533 -1408
  24. package/dist/shaka-player.ui.map +4 -4
  25. package/externs/device_sensor_event.js +18 -0
  26. package/externs/hisense.js +16 -0
  27. package/externs/playstation.js +31 -0
  28. package/externs/shaka/abr_manager.js +3 -1
  29. package/externs/shaka/ads.js +5 -0
  30. package/externs/shaka/codecs.js +13 -0
  31. package/externs/shaka/manifest.js +69 -7
  32. package/externs/shaka/net.js +13 -1
  33. package/externs/shaka/offline.js +7 -1
  34. package/externs/shaka/player.js +184 -13
  35. package/externs/shaka/text.js +19 -0
  36. package/externs/tizen.js +41 -0
  37. package/externs/webos.js +19 -0
  38. package/externs/xbox.js +43 -0
  39. package/lib/abr/simple_abr_manager.js +9 -1
  40. package/lib/ads/ad_manager.js +19 -2
  41. package/lib/ads/client_side_ad_manager.js +5 -3
  42. package/lib/ads/media_tailor_ad_manager.js +9 -0
  43. package/lib/cast/cast_receiver.js +0 -14
  44. package/lib/cast/cast_utils.js +1 -0
  45. package/lib/cea/mp4_cea_parser.js +6 -1
  46. package/lib/dash/content_protection.js +97 -53
  47. package/lib/dash/dash_parser.js +240 -179
  48. package/lib/dash/mpd_utils.js +72 -65
  49. package/lib/dash/segment_base.js +35 -22
  50. package/lib/dash/segment_list.js +39 -31
  51. package/lib/dash/segment_template.js +47 -23
  52. package/lib/hls/hls_parser.js +376 -165
  53. package/lib/media/buffering_observer.js +25 -1
  54. package/lib/media/drm_engine.js +91 -71
  55. package/lib/media/manifest_filterer.js +220 -0
  56. package/lib/media/media_source_engine.js +108 -29
  57. package/lib/media/playhead.js +3 -3
  58. package/lib/media/preload_manager.js +827 -0
  59. package/lib/media/presentation_timeline.js +11 -0
  60. package/lib/media/segment_index.js +60 -49
  61. package/lib/media/segment_prefetch.js +140 -43
  62. package/lib/media/segment_reference.js +31 -8
  63. package/lib/media/segment_utils.js +208 -25
  64. package/lib/media/streaming_engine.js +321 -77
  65. package/lib/mss/content_protection.js +31 -25
  66. package/lib/mss/mss_parser.js +78 -55
  67. package/lib/net/networking_engine.js +49 -4
  68. package/lib/offline/indexeddb/v1_storage_cell.js +2 -0
  69. package/lib/offline/indexeddb/v2_storage_cell.js +2 -0
  70. package/lib/offline/manifest_converter.js +10 -3
  71. package/lib/offline/storage.js +5 -3
  72. package/lib/player.js +896 -674
  73. package/lib/polyfill/media_capabilities.js +16 -1
  74. package/lib/text/simple_text_displayer.js +9 -0
  75. package/lib/text/stub_text_displayer.js +7 -0
  76. package/lib/text/text_engine.js +16 -3
  77. package/lib/text/ttml_text_parser.js +116 -114
  78. package/lib/text/ui_text_displayer.js +28 -11
  79. package/lib/text/vtt_text_parser.js +54 -115
  80. package/lib/transmuxer/opus.js +91 -0
  81. package/lib/transmuxer/ts_transmuxer.js +115 -0
  82. package/lib/util/cmcd_manager.js +152 -3
  83. package/lib/util/dom_utils.js +11 -0
  84. package/lib/util/error.js +5 -0
  85. package/lib/util/fake_event.js +2 -0
  86. package/lib/util/manifest_parser_utils.js +97 -3
  87. package/lib/util/mime_utils.js +10 -5
  88. package/lib/util/mp4_box_parsers.js +346 -17
  89. package/lib/util/mp4_generator.js +23 -0
  90. package/lib/util/periods.js +24 -37
  91. package/lib/util/platform.js +161 -9
  92. package/lib/util/player_configuration.js +61 -3
  93. package/lib/util/stats.js +16 -0
  94. package/lib/util/stream_utils.js +350 -277
  95. package/lib/util/string_utils.js +36 -0
  96. package/lib/util/tXml.js +814 -0
  97. package/lib/util/ts_parser.js +50 -0
  98. package/lib/util/xml_utils.js +10 -338
  99. package/package.json +2 -2
  100. package/shaka-player.uncompiled.js +8 -0
  101. package/ui/controls.js +187 -5
  102. package/ui/enums.js +2 -0
  103. package/ui/externs/ui.js +30 -3
  104. package/ui/gl_matrix/matrix_4x4.js +568 -0
  105. package/ui/gl_matrix/matrix_quaternion.js +45 -0
  106. package/ui/less/containers.less +11 -0
  107. package/ui/locales/en-GB.json +2 -0
  108. package/ui/locales/en.json +2 -0
  109. package/ui/locales/es-419.json +2 -0
  110. package/ui/locales/es.json +2 -0
  111. package/ui/locales/source.json +8 -0
  112. package/ui/recenter_vr.js +126 -0
  113. package/ui/resolution_selection.js +25 -5
  114. package/ui/statistics_button.js +12 -0
  115. package/ui/text_selection.js +1 -1
  116. package/ui/toggle_stereoscopic.js +127 -0
  117. package/ui/ui.js +74 -38
  118. package/ui/vr_manager.js +557 -0
  119. package/ui/vr_utils.js +232 -0
  120. package/ui/vr_webgl.js +697 -0
@@ -85,6 +85,8 @@ shaka.extern.StateChange;
85
85
  * gapsJumped: number,
86
86
  * stallsDetected: number,
87
87
  *
88
+ * bytesDownloaded: number,
89
+ *
88
90
  * switchHistory: !Array.<shaka.extern.TrackChoice>,
89
91
  * stateHistory: !Array.<shaka.extern.StateChange>
90
92
  * }}
@@ -161,6 +163,9 @@ shaka.extern.StateChange;
161
163
  * The presentation's max segment duration in seconds. If nothing is loaded,
162
164
  * NaN.
163
165
  *
166
+ * @property {number} bytesDownloaded
167
+ * The bytes downloaded during the playback. If nothing is loaded, NaN.
168
+ *
164
169
  * @property {!Array.<shaka.extern.TrackChoice>} switchHistory
165
170
  * A history of the stream changes.
166
171
  * @property {!Array.<shaka.extern.StateChange>} stateHistory
@@ -534,7 +539,8 @@ shaka.extern.MetadataFrame;
534
539
  * startTime: number,
535
540
  * endTime: number,
536
541
  * id: string,
537
- * eventElement: Element
542
+ * eventElement: Element,
543
+ * eventNode: ?shaka.extern.xml.Node
538
544
  * }}
539
545
  *
540
546
  * @description
@@ -552,7 +558,10 @@ shaka.extern.MetadataFrame;
552
558
  * The presentation time (in seconds) that the region should end.
553
559
  * @property {string} id
554
560
  * Specifies an identifier for this instance of the region.
555
- * @property {Element} eventElement
561
+ * @property {Elment} eventElement
562
+ * <b>DEPRECATED</b>: Use eventElement instead.
563
+ * The XML element that defines the Event.
564
+ * @property {?shaka.extern.xml.Node} eventNode
556
565
  * The XML element that defines the Event.
557
566
  * @exportDoc
558
567
  */
@@ -818,7 +827,8 @@ shaka.extern.PersistentSessionMetadata;
818
827
  * <i>Defaults to 1.</i> <br>
819
828
  * The frequency in seconds with which to check the expiration of a session.
820
829
  * @property {!Array.<string>} preferredKeySystems
821
- * <i>Defaults to an empty array. </i> <br>
830
+ * <i>Defaults ['com.microsoft.playready'] on Xbox One and PlayStation 4, and
831
+ * an empty array for all other browsers.</i> <br>
822
832
  * Specifies the priorties of available DRM key systems.
823
833
  * @property {Object.<string, string>} keySystemsMapping
824
834
  * A map of key system name to key system name.
@@ -853,6 +863,30 @@ shaka.extern.DrmConfiguration;
853
863
  shaka.extern.InitDataTransform;
854
864
 
855
865
 
866
+ /**
867
+ * @typedef {{
868
+ * tagName: !string,
869
+ * attributes: !Object<string, string>,
870
+ * children: !Array.<shaka.extern.xml.Node | string>,
871
+ * parent: ?shaka.extern.xml.Node
872
+ * }}
873
+ *
874
+ * @description
875
+ * Data structure for xml nodes as simple objects
876
+ *
877
+ * @property {!string} tagName
878
+ * The name of the element
879
+ * @property {!object} attributes
880
+ * The attributes of the element
881
+ * @property {!Array.<shaka.extern.xml.Node | string>} children
882
+ * The child nodes or string body of the element
883
+ * @property {?shaka.extern.xml.Node} parent
884
+ * The parent of the current element
885
+ *
886
+ * @exportDoc
887
+ */
888
+ shaka.extern.xml.Node;
889
+
856
890
  /**
857
891
  * @typedef {{
858
892
  * clockSyncUri: string,
@@ -867,9 +901,12 @@ shaka.extern.InitDataTransform;
867
901
  * ignoreMaxSegmentDuration: boolean,
868
902
  * keySystemsByURI: !Object.<string, string>,
869
903
  * manifestPreprocessor: function(!Element),
904
+ * manifestPreprocessorTXml: function(!shaka.extern.xml.Node),
870
905
  * sequenceMode: boolean,
871
906
  * enableAudioGroups: boolean,
872
- * multiTypeVariantsAllowed: boolean
907
+ * multiTypeVariantsAllowed: boolean,
908
+ * useStreamOnceInPeriodFlattening: boolean,
909
+ * updatePeriod: number
873
910
  * }}
874
911
  *
875
912
  * @property {string} clockSyncUri
@@ -920,6 +957,11 @@ shaka.extern.InitDataTransform;
920
957
  * A map of scheme URI to key system name. Defaults to default key systems
921
958
  * mapping handled by Shaka.
922
959
  * @property {function(!Element)} manifestPreprocessor
960
+ * <b>DEPRECATED</b>: Use manifestPreprocessorTXml instead.
961
+ * Called immediately after the DASH manifest has been parsed into an
962
+ * XMLDocument. Provides a way for applications to perform efficient
963
+ * preprocessing of the manifest.
964
+ * @property {function(!shaka.extern.xml.Node)} manifestPreprocessorTXml
923
965
  * Called immediately after the DASH manifest has been parsed into an
924
966
  * XMLDocument. Provides a way for applications to perform efficient
925
967
  * preprocessing of the manifest.
@@ -941,6 +983,18 @@ shaka.extern.InitDataTransform;
941
983
  * Might result in undesirable behavior if mediaSource.codecSwitchingStrategy
942
984
  * is not set to SMOOTH.
943
985
  * Defaults to true if SMOOTH codec switching is supported, RELOAD overwise.
986
+ * @property {boolean} useStreamOnceInPeriodFlattening
987
+ * If period combiner is used, this option ensures every stream is used
988
+ * only once in period flattening. It speeds up underlying algorithm
989
+ * but may raise issues if manifest does not have stream consistency
990
+ * between periods.
991
+ * Defaults to <code>false</code>.
992
+ * @property {number} updatePeriod
993
+ * Override the minimumUpdatePeriod of the manifest. The value is in second
994
+ * if the value is greater than the minimumUpdatePeriod, it will update the
995
+ * manifest less frequently. if you update the value during for a dynamic
996
+ * manifest, it will directly trigger a new download of the manifest
997
+ * Defaults to <code>-1</code>.
944
998
  * @exportDoc
945
999
  */
946
1000
  shaka.extern.DashManifestConfiguration;
@@ -953,6 +1007,7 @@ shaka.extern.DashManifestConfiguration;
953
1007
  * defaultAudioCodec: string,
954
1008
  * defaultVideoCodec: string,
955
1009
  * ignoreManifestProgramDateTime: boolean,
1010
+ * ignoreManifestProgramDateTimeForTypes: !Array<string>,
956
1011
  * mediaPlaylistFullMimeType: string,
957
1012
  * useSafariBehaviorForLive: boolean,
958
1013
  * liveSegmentsDelay: number,
@@ -981,6 +1036,14 @@ shaka.extern.DashManifestConfiguration;
981
1036
  * Meant for streams where <code>EXT-X-PROGRAM-DATE-TIME</code> is incorrect
982
1037
  * or malformed.
983
1038
  * <i>Defaults to <code>false</code>.</i>
1039
+ * @property {!Array.<string>} ignoreManifestProgramDateTimeForTypes
1040
+ * An array of strings representing types for which
1041
+ * <code>EXT-X-PROGRAM-DATE-TIME</code> should be ignored. Only used if the
1042
+ * the main ignoreManifestProgramDateTime is set to false.
1043
+ * For example, setting this to ['text', 'video'] will cause the PDT values
1044
+ * text and video streams to be ignored, while still using the PDT values for
1045
+ * audio.
1046
+ * <i>Defaults to an empty array.</i>
984
1047
  * @property {string} mediaPlaylistFullMimeType
985
1048
  * A string containing a full mime type, including both the basic mime type
986
1049
  * and also the codecs. Used when the HLS parser parses a media playlist
@@ -1032,11 +1095,17 @@ shaka.extern.HlsManifestConfiguration;
1032
1095
  /**
1033
1096
  * @typedef {{
1034
1097
  * manifestPreprocessor: function(!Element),
1098
+ * manifestPreprocessorTXml: function(!shaka.extern.xml.Node),
1035
1099
  * sequenceMode: boolean,
1036
1100
  * keySystemsBySystemId: !Object.<string, string>
1037
1101
  * }}
1038
1102
  *
1039
1103
  * @property {function(!Element)} manifestPreprocessor
1104
+ * <b>DEPRECATED</b>: Use manifestPreprocessorTXml instead.
1105
+ * Called immediately after the MSS manifest has been parsed into an
1106
+ * XMLDocument. Provides a way for applications to perform efficient
1107
+ * preprocessing of the manifest.
1108
+ * @property {function(!shaka.extern.xml.Node)} manifestPreprocessorTXml
1040
1109
  * Called immediately after the MSS manifest has been parsed into an
1041
1110
  * XMLDocument. Provides a way for applications to perform efficient
1042
1111
  * preprocessing of the manifest.
@@ -1121,6 +1190,7 @@ shaka.extern.ManifestConfiguration;
1121
1190
  * rebufferingGoal: number,
1122
1191
  * bufferingGoal: number,
1123
1192
  * bufferBehind: number,
1193
+ * evictionGoal: number,
1124
1194
  * ignoreTextStreamFailures: boolean,
1125
1195
  * alwaysStreamText: boolean,
1126
1196
  * startAtSegmentBoundary: boolean,
@@ -1132,6 +1202,7 @@ shaka.extern.ManifestConfiguration;
1132
1202
  * stallThreshold: number,
1133
1203
  * stallSkip: number,
1134
1204
  * useNativeHlsOnSafari: boolean,
1205
+ * useNativeHlsForFairPlay: boolean,
1135
1206
  * inaccurateManifestTolerance: number,
1136
1207
  * lowLatencyMode: boolean,
1137
1208
  * autoLowLatencyMode: boolean,
@@ -1143,13 +1214,23 @@ shaka.extern.ManifestConfiguration;
1143
1214
  * maxDisabledTime: number,
1144
1215
  * parsePrftBox: boolean,
1145
1216
  * segmentPrefetchLimit: number,
1217
+ * prefetchAudioLanguages: !Array<string>,
1218
+ * disableAudioPrefetch: boolean,
1219
+ * disableTextPrefetch: boolean,
1220
+ * disableVideoPrefetch: boolean,
1146
1221
  * liveSync: boolean,
1147
1222
  * liveSyncMaxLatency: number,
1148
1223
  * liveSyncPlaybackRate: number,
1149
1224
  * liveSyncMinLatency: number,
1150
1225
  * liveSyncMinPlaybackRate: number,
1226
+ * liveSyncPanicMode: boolean,
1227
+ * liveSyncPanicThreshold: number,
1151
1228
  * allowMediaSourceRecoveries: boolean,
1152
- * minTimeBetweenRecoveries: number
1229
+ * minTimeBetweenRecoveries: number,
1230
+ * vodDynamicPlaybackRate: boolean,
1231
+ * vodDynamicPlaybackRateLowBufferRate: number,
1232
+ * vodDynamicPlaybackRateBufferRatio: number,
1233
+ * infiniteLiveStreamDuration: boolean
1153
1234
  * }}
1154
1235
  *
1155
1236
  * @description
@@ -1173,6 +1254,10 @@ shaka.extern.ManifestConfiguration;
1173
1254
  * The maximum number of seconds of content that the StreamingEngine will keep
1174
1255
  * in buffer behind the playhead when it appends a new media segment.
1175
1256
  * The StreamingEngine will evict content to meet this limit.
1257
+ * @property {number} evictionGoal
1258
+ * The minimum duration in seconds of buffer overflow the StreamingEngine
1259
+ * requires to start removing content from the buffer.
1260
+ * Values less than <code>1.0</code> are not recommended.
1176
1261
  * @property {boolean} ignoreTextStreamFailures
1177
1262
  * If <code>true</code>, the player will ignore text stream failures and
1178
1263
  * continue playing other streams.
@@ -1221,9 +1306,15 @@ shaka.extern.ManifestConfiguration;
1221
1306
  * @property {boolean} useNativeHlsOnSafari
1222
1307
  * Desktop Safari has both MediaSource and their native HLS implementation.
1223
1308
  * Depending on the application's needs, it may prefer one over the other.
1309
+ * Only applies to clear streams
1310
+ * Defaults to <code>true</code>.
1311
+ * @property {boolean} useNativeHlsForFairPlay
1312
+ * Desktop Safari has both MediaSource and their native HLS implementation.
1313
+ * Depending on the application's needs, it may prefer one over the other.
1224
1314
  * Warning when disabled: Where single-key DRM streams work fine, multi-keys
1225
1315
  * streams is showing unexpected behaviours (stall, audio playing with video
1226
1316
  * freezes, ...). Use with care.
1317
+ * Defaults to <code>true</code>.
1227
1318
  * @property {number} inaccurateManifestTolerance
1228
1319
  * The maximum difference, in seconds, between the times in the manifest and
1229
1320
  * the times in the segments. Larger values allow us to compensate for more
@@ -1249,7 +1340,7 @@ shaka.extern.ManifestConfiguration;
1249
1340
  * If true, all emsg boxes are parsed and dispatched.
1250
1341
  * @property {boolean} observeQualityChanges
1251
1342
  * If true, monitor media quality changes and emit
1252
- * <code.shaka.Player.MediaQualityChangedEvent</code>.
1343
+ * <code>shaka.Player.MediaQualityChangedEvent</code>.
1253
1344
  * @property {number} maxDisabledTime
1254
1345
  * The maximum time a variant can be disabled when NETWORK HTTP_ERROR
1255
1346
  * is reached, in seconds.
@@ -1261,11 +1352,26 @@ shaka.extern.ManifestConfiguration;
1261
1352
  * start date will not change, and would save parsing the segment multiple
1262
1353
  * times needlessly.
1263
1354
  * Defaults to <code>false</code>.
1264
- * @property {boolean} segmentPrefetchLimit
1355
+ * @property {number} segmentPrefetchLimit
1265
1356
  * The maximum number of segments for each active stream to be prefetched
1266
1357
  * ahead of playhead in parallel.
1267
1358
  * If <code>0</code>, the segments will be fetched sequentially.
1268
1359
  * Defaults to <code>0</code>.
1360
+ * @property {!Array<string>} prefetchAudioLanguages
1361
+ * The audio languages to prefetch.
1362
+ * Defaults to an empty array.
1363
+ * @property {boolean} disableAudioPrefetch
1364
+ * If set and prefetch limit is defined, it will prevent from prefetching data
1365
+ * for audio.
1366
+ * Defaults to <code>false</code>.
1367
+ * @property {boolean} disableTextPrefetch
1368
+ * If set and prefetch limit is defined, it will prevent from prefetching data
1369
+ * for text.
1370
+ * Defaults to <code>false</code>.
1371
+ * @property {boolean} disableVideoPrefetch
1372
+ * If set and prefetch limit is defined, it will prevent from prefetching data
1373
+ * for video.
1374
+ * Defaults to <code>false</code>.
1269
1375
  * @property {boolean} liveSync
1270
1376
  * Enable the live stream sync against the live edge by changing the playback
1271
1377
  * rate. Defaults to <code>false</code>.
@@ -1285,6 +1391,14 @@ shaka.extern.ManifestConfiguration;
1285
1391
  * Minimum playback rate used for latency chasing. It is recommended to use a
1286
1392
  * value between 0 and 1. Effective only if liveSync is true. Defaults to
1287
1393
  * <code>1</code>.
1394
+ * @property {boolean} liveSyncPanicMode
1395
+ * If <code>true</code>, panic mode for live sync is enabled. When enabled,
1396
+ * will set the playback rate to the <code>liveSyncMinPlaybackRate</code>
1397
+ * until playback has continued past a rebuffering for longer than the
1398
+ * <code>liveSyncPanicThreshold</code>. Defaults to <code>false</code>.
1399
+ * @property {number} liveSyncPanicThreshold
1400
+ * Number of seconds that playback stays in panic mode after a rebuffering.
1401
+ * Defaults to <code>60</code>
1288
1402
  * @property {boolean} allowMediaSourceRecoveries
1289
1403
  * Indicate if we should recover from VIDEO_ERROR resetting Media Source.
1290
1404
  * Defaults to <code>true</code>.
@@ -1292,6 +1406,21 @@ shaka.extern.ManifestConfiguration;
1292
1406
  * The minimum time between recoveries when VIDEO_ERROR is reached, in
1293
1407
  * seconds.
1294
1408
  * Defaults to <code>5</code>.
1409
+ * @property {boolean} vodDynamicPlaybackRate
1410
+ * Adapt the playback rate of the player to keep the buffer full. Defaults to
1411
+ * <code>false</code>.
1412
+ * @property {number} vodDynamicPlaybackRateLowBufferRate
1413
+ * Playback rate to use if the buffer is too small. Defaults to
1414
+ * <code>0.95</code>.
1415
+ * @property {number} vodDynamicPlaybackRateBufferRatio
1416
+ * Ratio of the <code>bufferingGoal</code> as the low threshold for
1417
+ * setting the playback rate to
1418
+ * <code>vodDynamicPlaybackRateLowBufferRate</code>.
1419
+ * Defaults to <code>0.5</code>.
1420
+ * @property {boolean} infiniteLiveStreamDuration
1421
+ * If <code>true</code>, the media source live duration
1422
+ * set as a<code>Infinity</code>
1423
+ * Defaults to <code> false </code>.
1295
1424
  * @exportDoc
1296
1425
  */
1297
1426
  shaka.extern.StreamingConfiguration;
@@ -1300,9 +1429,10 @@ shaka.extern.StreamingConfiguration;
1300
1429
  /**
1301
1430
  * @typedef {{
1302
1431
  * codecSwitchingStrategy: shaka.config.CodecSwitchingStrategy,
1303
- * sourceBufferExtraFeatures: string,
1432
+ * addExtraFeaturesToSourceBuffer: function(string): string,
1304
1433
  * forceTransmux: boolean,
1305
- * insertFakeEncryptionInInit: boolean
1434
+ * insertFakeEncryptionInInit: boolean,
1435
+ * modifyCueCallback: shaka.extern.TextParser.ModifyCueCallback
1306
1436
  * }}
1307
1437
  *
1308
1438
  * @description
@@ -1313,10 +1443,12 @@ shaka.extern.StreamingConfiguration;
1313
1443
  * SourceBuffer.changeType. RELOAD uses cycling of MediaSource.
1314
1444
  * Defaults to SMOOTH if SMOOTH codec switching is supported, RELOAD
1315
1445
  * overwise.
1316
- * @property {string} sourceBufferExtraFeatures
1446
+ * @property {function(string): string} addExtraFeaturesToSourceBuffer
1447
+ * Callback to generate extra features string based on used MIME type.
1317
1448
  * Some platforms may need to pass features when initializing the
1318
1449
  * sourceBuffer.
1319
- * This string is ultimately appended to MIME types in addSourceBuffer().
1450
+ * This string is ultimately appended to a MIME type in addSourceBuffer() &
1451
+ * changeType().
1320
1452
  * @property {boolean} forceTransmux
1321
1453
  * If this is <code>true</code>, we will transmux AAC and TS content even if
1322
1454
  * not strictly necessary for the assets to be played.
@@ -1332,6 +1464,10 @@ shaka.extern.StreamingConfiguration;
1332
1464
  * time.
1333
1465
  * <br><br>
1334
1466
  * This value defaults to <code>true</code>.
1467
+ * @property {shaka.extern.TextParser.ModifyCueCallback} modifyCueCallback
1468
+ * A callback called for each cue after it is parsed, but right before it
1469
+ * is appended to the presentation.
1470
+ * Gives a chance for client-side editing of cue text, cue timing, etc.
1335
1471
  * @exportDoc
1336
1472
  */
1337
1473
  shaka.extern.MediaSourceConfiguration;
@@ -1339,7 +1475,8 @@ shaka.extern.MediaSourceConfiguration;
1339
1475
 
1340
1476
  /**
1341
1477
  * @typedef {{
1342
- * customPlayheadTracker: boolean
1478
+ * customPlayheadTracker: boolean,
1479
+ * skipPlayDetection: boolean
1343
1480
  * }}
1344
1481
  *
1345
1482
  * @description
@@ -1350,6 +1487,12 @@ shaka.extern.MediaSourceConfiguration;
1350
1487
  * Client Side. This is useful because it allows you to implement the use of
1351
1488
  * IMA on platforms that do not support multiple video elements.
1352
1489
  * This value defaults to <code>false</code>.
1490
+ * @property {boolean} skipPlayDetection
1491
+ * If this is true, we will load Client Side ads without waiting for a play
1492
+ * event.
1493
+ * Defaults to <code>false</code> except on Tizen, WebOS, Chromecast,
1494
+ * Hisense, PlayStation 4, PlayStation5, Xbox whose default value is
1495
+ * <code>true</code>.
1353
1496
  *
1354
1497
  * @exportDoc
1355
1498
  */
@@ -1465,7 +1608,9 @@ shaka.extern.AdvancedAbrConfiguration;
1465
1608
  * enabled: boolean,
1466
1609
  * useHeaders: boolean,
1467
1610
  * sessionId: string,
1468
- * contentId: string
1611
+ * contentId: string,
1612
+ * rtpSafetyFactor: number,
1613
+ * includeKeys: !Array<string>
1469
1614
  * }}
1470
1615
  *
1471
1616
  * @description
@@ -1488,6 +1633,12 @@ shaka.extern.AdvancedAbrConfiguration;
1488
1633
  * characters. This value is consistent across multiple different sessions and
1489
1634
  * devices and is defined and updated at the discretion of the service
1490
1635
  * provider.
1636
+ * @property {number} rtpSafetyFactor
1637
+ * RTP safety factor.
1638
+ * Defaults to <code>5</code>.
1639
+ * @property {!Array<string>} includeKeys
1640
+ * An array of keys to include in the CMCD data. If not provided, all keys
1641
+ * will be included.
1491
1642
  * @exportDoc
1492
1643
  */
1493
1644
  shaka.extern.CmcdConfiguration;
@@ -1602,6 +1753,23 @@ shaka.extern.LcevcConfiguration;
1602
1753
  shaka.extern.OfflineConfiguration;
1603
1754
 
1604
1755
 
1756
+ /**
1757
+ * @typedef {{
1758
+ * captionsUpdatePeriod: number
1759
+ * }}
1760
+ *
1761
+ * @description
1762
+ * Text displayer configuration.
1763
+ *
1764
+ * @property {number} captionsUpdatePeriod
1765
+ * The number of seconds to see if the captions should be updated.
1766
+ * Defaults to <code>0.25</code>.
1767
+ *
1768
+ * @exportDoc
1769
+ */
1770
+ shaka.extern.TextDisplayerConfiguration;
1771
+
1772
+
1605
1773
  /**
1606
1774
  * @typedef {{
1607
1775
  * ads: shaka.extern.AdsConfiguration,
@@ -1633,6 +1801,7 @@ shaka.extern.OfflineConfiguration;
1633
1801
  * restrictions: shaka.extern.Restrictions,
1634
1802
  * playRangeStart: number,
1635
1803
  * playRangeEnd: number,
1804
+ * textDisplayer: shaka.extern.TextDisplayerConfiguration,
1636
1805
  * textDisplayFactory: shaka.extern.TextDisplayer.Factory
1637
1806
  * }}
1638
1807
  *
@@ -1719,6 +1888,8 @@ shaka.extern.OfflineConfiguration;
1719
1888
  * @property {number} playRangeEnd
1720
1889
  * Optional playback and seek end time in seconds. Defaults to the end of
1721
1890
  * the presentation if not provided.
1891
+ * @property {shaka.extern.TextDisplayerConfiguration} textDisplayer
1892
+ * Text displayer configuration and settings.
1722
1893
  * @property {shaka.extern.TextDisplayer.Factory} textDisplayFactory
1723
1894
  * A factory to construct a text displayer. Note that, if this is changed
1724
1895
  * during playback, it will cause the text tracks to be reloaded.
@@ -85,6 +85,18 @@ shaka.extern.TextParser = class {
85
85
  shaka.extern.TextParser.TimeContext;
86
86
 
87
87
 
88
+ /**
89
+ * A callback used for editing cues before appending.
90
+ * Provides the cue, the URI of the captions file the cue was parsed from, and
91
+ * the time context that was used when generating that cue.
92
+ * You can edit the cue object passed in.
93
+ * @typedef {function(!shaka.text.Cue, ?string,
94
+ * !shaka.extern.TextParser.TimeContext)}
95
+ * @exportDoc
96
+ */
97
+ shaka.extern.TextParser.ModifyCueCallback;
98
+
99
+
88
100
  /**
89
101
  * @typedef {function():!shaka.extern.TextParser}
90
102
  * @exportDoc
@@ -120,6 +132,13 @@ shaka.extern.TextDisplayer = class {
120
132
  */
121
133
  destroy() {}
122
134
 
135
+ /**
136
+ * Sets the TextDisplayer configuration.
137
+ *
138
+ * @param {shaka.extern.TextDisplayerConfiguration} config
139
+ */
140
+ configure(config) {}
141
+
123
142
  /**
124
143
  * Append given text cues to the list of cues to be displayed.
125
144
  *
@@ -0,0 +1,41 @@
1
+ /*! @license
2
+ * Shaka Player
3
+ * Copyright 2016 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ /**
8
+ * @fileoverview Externs for Tizen
9
+ * @externs
10
+ */
11
+
12
+
13
+ /** @const */
14
+ var webapis = {};
15
+
16
+
17
+ /** @const */
18
+ webapis.systeminfo = {};
19
+
20
+
21
+ /**
22
+ * @return {{width: number, height: number}}
23
+ */
24
+ webapis.systeminfo.getMaxVideoResolution = function() {};
25
+
26
+
27
+ /** @const */
28
+ webapis.productinfo = {};
29
+
30
+
31
+ /**
32
+ * @return {boolean}
33
+ */
34
+ webapis.productinfo.is8KPanelSupported = function() {};
35
+
36
+
37
+ /**
38
+ * @return {boolean}
39
+ */
40
+ webapis.productinfo.isUdPanelSupported = function() {};
41
+
@@ -0,0 +1,19 @@
1
+ /*! @license
2
+ * Shaka Player
3
+ * Copyright 2016 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ /**
8
+ * @fileoverview Externs for WebOS
9
+ *
10
+ * @externs
11
+ */
12
+
13
+
14
+ /** @const */
15
+ var PalmSystem = {};
16
+
17
+
18
+ /** @type {string} */
19
+ PalmSystem.deviceInfo;
@@ -0,0 +1,43 @@
1
+ /*! @license
2
+ * Shaka Player
3
+ * Copyright 2016 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ /**
8
+ * @fileoverview Externs for Xbox
9
+ *
10
+ * @externs
11
+ */
12
+
13
+
14
+ /** @const */
15
+ var Windows = {};
16
+
17
+
18
+ /** @const */
19
+ Windows.Media = {};
20
+
21
+
22
+ /** @const */
23
+ Windows.Media.Protection = {};
24
+
25
+
26
+ /** @const */
27
+ Windows.Media.Protection.ProtectionCapabilities = class {
28
+ /**
29
+ * @param {string} type
30
+ * @param {string} keySystem
31
+ * @return {!Windows.Media.Protection.ProtectionCapabilityResult}
32
+ */
33
+ isTypeSupported(type, keySystem) {}
34
+ };
35
+
36
+ /**
37
+ * @enum {string}
38
+ */
39
+ Windows.Media.Protection.ProtectionCapabilityResult = {
40
+ notSupported: 'NotSupported',
41
+ maybe: 'Maybe',
42
+ probably: 'Probably',
43
+ };
@@ -297,11 +297,19 @@ shaka.abr.SimpleAbrManager = class {
297
297
 
298
298
 
299
299
  /**
300
+ * @param {number} deltaTimeMs The duration, in milliseconds, that the request
301
+ * took to complete.
302
+ * @param {number} numBytes The total number of bytes transferred.
303
+ * @param {boolean} allowSwitch Indicate if the segment is allowed to switch
304
+ * to another stream.
305
+ * @param {shaka.extern.Request=} request
306
+ * A reference to the request
300
307
  * @override
301
308
  * @export
302
309
  */
303
- segmentDownloaded(deltaTimeMs, numBytes, allowSwitch) {
310
+ segmentDownloaded(deltaTimeMs, numBytes, allowSwitch, request) {
304
311
  shaka.log.v2('Segment downloaded:',
312
+ 'contentType=' + (request && request.contentType),
305
313
  'deltaTimeMs=' + deltaTimeMs,
306
314
  'numBytes=' + numBytes,
307
315
  'lastTimeChosenMs=' + this.lastTimeChosenMs_,
@@ -560,6 +560,23 @@ shaka.ads.AdManager = class extends shaka.util.FakeEventTarget {
560
560
  }
561
561
 
562
562
 
563
+ /**
564
+ * @param {string} url
565
+ * @override
566
+ * @export
567
+ */
568
+ addMediaTailorTrackingUrl(url) {
569
+ if (!this.mtAdManager_) {
570
+ throw new shaka.util.Error(
571
+ shaka.util.Error.Severity.RECOVERABLE,
572
+ shaka.util.Error.Category.ADS,
573
+ shaka.util.Error.Code.MT_AD_MANAGER_NOT_INITIALIZED);
574
+ }
575
+
576
+ this.mtAdManager_.addTrackingUrl(url);
577
+ }
578
+
579
+
563
580
  /**
564
581
  * @override
565
582
  * @export
@@ -705,8 +722,8 @@ shaka.ads.AdManager = class extends shaka.util.FakeEventTarget {
705
722
  onDashTimedMetadata(region) {
706
723
  if (this.ssAdManager_ && region.schemeIdUri == 'urn:google:dai:2018') {
707
724
  const type = region.schemeIdUri;
708
- const data = region.eventElement ?
709
- region.eventElement.getAttribute('messageData') : null;
725
+ const data = region.eventNode ?
726
+ region.eventNode.attributes['messageData'] : null;
710
727
  const timestamp = region.startTime;
711
728
  this.ssAdManager_.onTimedMetadata(type, data, timestamp);
712
729
  }
@@ -308,7 +308,7 @@ shaka.ads.ClientSideAdManager = class {
308
308
  // seen the ads actually play until requestAds() is called.
309
309
  // Note: We listen for a play event to avoid autoplay issues that might
310
310
  // crash IMA.
311
- if (this.videoPlayed_) {
311
+ if (this.videoPlayed_ || this.config_.skipPlayDetection) {
312
312
  this.imaAdsManager_.start();
313
313
  } else {
314
314
  this.eventManager_.listenOnce(this.video_, 'play', () => {
@@ -533,7 +533,9 @@ shaka.ads.ClientSideAdManager = class {
533
533
  shaka.ads.AdManager.AD_STARTED, data));
534
534
  if (this.ad_.isLinear()) {
535
535
  this.adContainer_.setAttribute('ad-active', 'true');
536
- this.video_.pause();
536
+ if (!this.config_.customPlayheadTracker) {
537
+ this.video_.pause();
538
+ }
537
539
  if (this.video_.muted) {
538
540
  this.ad_.setInitialMuted(this.video_.volume);
539
541
  } else {
@@ -551,7 +553,7 @@ shaka.ads.ClientSideAdManager = class {
551
553
  (new Map()).set('originalEvent', e)));
552
554
  if (this.ad_ && this.ad_.isLinear()) {
553
555
  this.adContainer_.removeAttribute('ad-active');
554
- if (!this.video_.ended) {
556
+ if (!this.config_.customPlayheadTracker && !this.video_.ended) {
555
557
  this.video_.play();
556
558
  }
557
559
  }
@@ -130,6 +130,15 @@ shaka.ads.MediaTailorAdManager = class {
130
130
  return this.streamPromise_;
131
131
  }
132
132
 
133
+ /**
134
+ * @param {string} url
135
+ */
136
+ addTrackingUrl(url) {
137
+ this.trackingUrl_ = url;
138
+ this.onEvent_(new shaka.util.FakeEvent(shaka.ads.AdManager.ADS_LOADED,
139
+ (new Map()).set('loadTime', 0)));
140
+ }
141
+
133
142
  /**
134
143
  * Resets the MediaTailor manager and removes any continuous polling.
135
144
  */
@@ -287,20 +287,6 @@ shaka.cast.CastReceiver = class extends shaka.util.FakeEventTarget {
287
287
  this.player_, name, (event) => this.proxyEvent_('player', event));
288
288
  }
289
289
 
290
- // In our tests, the original Chromecast seems to have trouble decoding
291
- // above 1080p. It would be a waste to select a higher res anyway, given
292
- // that the device only outputs 1080p to begin with.
293
-
294
- // Chromecast has an extension to query the device/display's resolution.
295
- if (cast.__platform__ && cast.__platform__.canDisplayType(
296
- 'video/mp4; codecs="avc1.640028"; width=3840; height=2160')) {
297
- // The device and display can both do 4k. Assume a 4k limit.
298
- this.player_.setMaxHardwareResolution(3840, 2160);
299
- } else {
300
- // Chromecast has always been able to do 1080p. Assume a 1080p limit.
301
- this.player_.setMaxHardwareResolution(1920, 1080);
302
- }
303
-
304
290
  // Do not start excluding values from update messages until the video is
305
291
  // fully loaded.
306
292
  this.eventManager_.listen(this.video_, 'loadeddata', () => {