shaka-player 3.3.2 → 4.0.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 (389) hide show
  1. package/.csslintrc +11 -1
  2. package/.github/ISSUE_TEMPLATE/bug_report.md +1 -1
  3. package/.github/pull_request_template.md +6 -34
  4. package/.github/workflows/build-and-test.yaml +129 -0
  5. package/.github/workflows/custom-actions/prep-for-appspot/action.yaml +56 -0
  6. package/.github/workflows/custom-actions/set-commit-status/action.yaml +41 -0
  7. package/.github/workflows/demo-version-index.yaml +37 -0
  8. package/.github/workflows/nightly-demo.yaml +42 -0
  9. package/.github/workflows/release-please.yaml +168 -0
  10. package/.github/workflows/safari-homedir-launcher.sh +18 -0
  11. package/.github/workflows/selenium-lab-tests.yaml +92 -0
  12. package/.github/workflows/sync-labels.yaml +33 -0
  13. package/.github/workflows/update-issues.yaml +29 -0
  14. package/.github/workflows/validate-pr-title.yaml +35 -0
  15. package/AUTHORS +3 -0
  16. package/CHANGELOG.md +1866 -1675
  17. package/CONTRIBUTING.md +2 -2
  18. package/CONTRIBUTORS +3 -0
  19. package/README.md +16 -13
  20. package/app-engine/README.md +9 -0
  21. package/app-engine/demo-version-index/README.md +14 -0
  22. package/app-engine/demo-version-index/app.yaml +28 -0
  23. package/app-engine/demo-version-index/generate.py +164 -0
  24. package/app-engine/demo-version-index/main.py +11 -0
  25. package/app-engine/demo-version-index/requirements.txt +5 -0
  26. package/app-engine/demo-version-index/templates/index.html +114 -0
  27. package/app-engine/shaka-player-demo/README.md +18 -0
  28. package/app-engine/shaka-player-demo/app.yaml +61 -0
  29. package/app-engine/shaka-player-demo/main.py +95 -0
  30. package/app-engine/shaka-player-demo/posters/10yo.png +0 -0
  31. package/app-engine/shaka-player-demo/posters/10yo.xcf +0 -0
  32. package/app-engine/shaka-player-demo/posters/1yo.jpg +0 -0
  33. package/app-engine/shaka-player-demo/posters/2yo.png +0 -0
  34. package/app-engine/shaka-player-demo/posters/2yo.xcf +0 -0
  35. package/app-engine/shaka-player-demo/posters/3yo.png +0 -0
  36. package/app-engine/shaka-player-demo/posters/3yo.xcf +0 -0
  37. package/app-engine/shaka-player-demo/posters/4yo.png +0 -0
  38. package/app-engine/shaka-player-demo/posters/4yo.xcf +0 -0
  39. package/app-engine/shaka-player-demo/posters/5yo.png +0 -0
  40. package/app-engine/shaka-player-demo/posters/5yo.xcf +0 -0
  41. package/app-engine/shaka-player-demo/posters/6yo.png +0 -0
  42. package/app-engine/shaka-player-demo/posters/6yo.xcf +0 -0
  43. package/app-engine/shaka-player-demo/posters/7yo.png +0 -0
  44. package/app-engine/shaka-player-demo/posters/7yo.xcf +0 -0
  45. package/app-engine/shaka-player-demo/posters/8yo.png +0 -0
  46. package/app-engine/shaka-player-demo/posters/8yo.xcf +0 -0
  47. package/app-engine/shaka-player-demo/posters/9yo.png +0 -0
  48. package/app-engine/shaka-player-demo/posters/9yo.xcf +0 -0
  49. package/app-engine/shaka-player-demo/posters/audioOnly.gif +0 -0
  50. package/app-engine/shaka-player-demo/posters/audioRickRoll.gif +0 -0
  51. package/app-engine/shaka-player-demo/posters/colorbars.gif +0 -0
  52. package/app-engine/shaka-player-demo/posters/fireworks.jpg +0 -0
  53. package/app-engine/shaka-player-demo/posters/party-hat.png +0 -0
  54. package/app-engine/shaka-player-demo/posters/sources.txt +46 -0
  55. package/app-engine/shaka-player-demo/posters/standard.png +0 -0
  56. package/app-engine/shaka-player-demo/posters/trek.jpg +0 -0
  57. package/app-engine/shaka-player-demo/posters/valentines.png +0 -0
  58. package/app-engine/shaka-player-demo/posters/zombie.jpg +0 -0
  59. package/app-engine/shaka-player-demo/posters.py +110 -0
  60. package/app-engine/shaka-player-demo/requirements.txt +5 -0
  61. package/app-engine/shaka-player-demo/time.txt +1 -0
  62. package/build/README.md +3 -3
  63. package/build/checkversion.py +1 -1
  64. package/build/compiler.py +1 -1
  65. package/build/conformance.textproto +13 -0
  66. package/build/docker/Dockerfile +20 -0
  67. package/build/docker/docker-compose.yml +10 -0
  68. package/build/gendeps.py +18 -15
  69. package/build/shaka-lab.yaml +161 -0
  70. package/build/shakaBuildHelpers.py +4 -29
  71. package/build/test.py +94 -29
  72. package/build/types/core +0 -1
  73. package/build/types/polyfill +1 -3
  74. package/build/wrapper.template.js +2 -2
  75. package/demo/TengwarTelcontar.woff2 +0 -0
  76. package/demo/asset_card.js +1 -2
  77. package/demo/cast_receiver/index.html +1 -1
  78. package/demo/cast_receiver/receiver_app.css +14 -14
  79. package/demo/common/asset.js +17 -1
  80. package/demo/common/assets.js +31 -0
  81. package/demo/common/message_ids.js +6 -3
  82. package/demo/config.js +10 -12
  83. package/demo/custom.js +39 -1
  84. package/demo/customWarning.txt +2 -2
  85. package/demo/demo.less +29 -18
  86. package/demo/demo_uncompiled.js +1 -13
  87. package/demo/demo_utils.js +0 -1
  88. package/demo/index.html +1 -1
  89. package/demo/locales/en.json +6 -3
  90. package/demo/locales/source.json +22 -10
  91. package/demo/main.js +12 -9
  92. package/demo/search.js +2 -1
  93. package/dist/controls.css +3 -3
  94. package/dist/controls.css.map +1 -1
  95. package/dist/demo.compiled.debug.js +236 -232
  96. package/dist/demo.compiled.debug.map +4 -4
  97. package/dist/demo.compiled.js +236 -232
  98. package/dist/demo.compiled.map +4 -4
  99. package/dist/demo.css +1 -1
  100. package/dist/demo.css.map +1 -1
  101. package/dist/deps.js +229 -226
  102. package/dist/locales.js +34 -32
  103. package/dist/receiver.compiled.debug.js +75 -73
  104. package/dist/receiver.compiled.debug.map +4 -4
  105. package/dist/receiver.compiled.js +75 -73
  106. package/dist/receiver.compiled.map +4 -4
  107. package/dist/shaka-player.compiled.d.ts +321 -314
  108. package/dist/shaka-player.compiled.debug.d.ts +321 -314
  109. package/dist/shaka-player.compiled.debug.externs.js +140 -129
  110. package/dist/shaka-player.compiled.debug.js +527 -592
  111. package/dist/shaka-player.compiled.debug.map +4 -4
  112. package/dist/shaka-player.compiled.externs.js +140 -129
  113. package/dist/shaka-player.compiled.js +836 -860
  114. package/dist/shaka-player.compiled.map +4 -4
  115. package/dist/shaka-player.ui.d.ts +367 -358
  116. package/dist/shaka-player.ui.debug.d.ts +367 -358
  117. package/dist/shaka-player.ui.debug.externs.js +148 -129
  118. package/dist/shaka-player.ui.debug.js +586 -649
  119. package/dist/shaka-player.ui.debug.map +4 -4
  120. package/dist/shaka-player.ui.externs.js +148 -129
  121. package/dist/shaka-player.ui.js +1008 -1028
  122. package/dist/shaka-player.ui.map +4 -4
  123. package/docs/design/REDESIGN.md +33 -33
  124. package/docs/design/bg-fetch.md +2 -2
  125. package/docs/design/codec_preferences.md +1 -1
  126. package/docs/design/dash-audio-channels.md +3 -3
  127. package/docs/design/dash-manifests.md +1 -1
  128. package/docs/design/gap-jumping.md +3 -3
  129. package/docs/design/preload.md +2 -2
  130. package/docs/tutorials/config.md +0 -2
  131. package/docs/tutorials/drm-config.md +5 -0
  132. package/docs/tutorials/fairplay.md +7 -22
  133. package/docs/tutorials/faq.md +8 -19
  134. package/docs/tutorials/index.json +3 -8
  135. package/docs/tutorials/plugins.md +4 -6
  136. package/docs/tutorials/selenium-grid-config.md +122 -0
  137. package/docs/tutorials/upgrade.md +83 -11
  138. package/docs/tutorials/welcome.md +10 -2
  139. package/externs/cmcd.js +1 -1
  140. package/externs/polyfill.js +15 -0
  141. package/externs/shaka/manifest.js +5 -1
  142. package/externs/shaka/net.js +12 -0
  143. package/externs/shaka/offline.js +5 -1
  144. package/externs/shaka/player.js +39 -32
  145. package/externs/shaka/text.js +12 -12
  146. package/externs/sourcebuffer.js +15 -0
  147. package/karma.conf.js +137 -30
  148. package/lib/abr/simple_abr_manager.js +12 -6
  149. package/lib/ads/client_side_ad.js +13 -2
  150. package/lib/ads/client_side_ad_manager.js +22 -4
  151. package/lib/cast/cast_proxy.js +3 -4
  152. package/lib/cast/cast_utils.js +0 -1
  153. package/lib/cea/cea608_data_channel.js +2 -2
  154. package/lib/cea/cea708_service.js +5 -4
  155. package/lib/cea/mp4_cea_parser.js +11 -5
  156. package/lib/cea/sei_processor.js +6 -3
  157. package/lib/dash/content_protection.js +85 -5
  158. package/lib/dash/dash_parser.js +10 -12
  159. package/lib/dash/mpd_utils.js +4 -5
  160. package/lib/dash/segment_list.js +1 -2
  161. package/lib/dash/segment_template.js +3 -3
  162. package/lib/hls/hls_parser.js +386 -749
  163. package/lib/hls/manifest_text_parser.js +5 -6
  164. package/lib/media/adaptation_set.js +1 -2
  165. package/lib/media/content_workarounds.js +2 -2
  166. package/lib/media/drm_engine.js +105 -55
  167. package/lib/media/gap_jumping_controller.js +10 -45
  168. package/lib/media/media_source_engine.js +90 -17
  169. package/lib/media/mp4_segment_index_parser.js +1 -4
  170. package/lib/media/playhead.js +4 -7
  171. package/lib/media/presentation_timeline.js +19 -10
  172. package/lib/media/segment_index.js +13 -46
  173. package/lib/media/segment_reference.js +47 -1
  174. package/lib/media/streaming_engine.js +35 -17
  175. package/lib/media/time_ranges_utils.js +5 -12
  176. package/lib/media/video_wrapper.js +1 -1
  177. package/lib/net/networking_engine.js +4 -1
  178. package/lib/offline/indexeddb/v1_storage_cell.js +1 -0
  179. package/lib/offline/indexeddb/v2_storage_cell.js +1 -0
  180. package/lib/offline/manifest_converter.js +1 -0
  181. package/lib/offline/storage.js +104 -136
  182. package/lib/player.js +50 -216
  183. package/lib/polyfill/all.js +2 -3
  184. package/lib/polyfill/encryption_scheme.js +1 -1
  185. package/lib/polyfill/media_capabilities.js +15 -9
  186. package/lib/polyfill/mediasource.js +0 -28
  187. package/lib/polyfill/patchedmediakeys_nop.js +2 -0
  188. package/lib/polyfill/patchedmediakeys_webkit.js +2 -0
  189. package/lib/polyfill/symbol.js +46 -0
  190. package/lib/text/cue.js +1 -7
  191. package/lib/text/lrc_text_parser.js +8 -0
  192. package/lib/text/mp4_ttml_parser.js +8 -0
  193. package/lib/text/mp4_vtt_parser.js +8 -0
  194. package/lib/text/sbv_text_parser.js +8 -0
  195. package/lib/text/simple_text_displayer.js +3 -8
  196. package/lib/text/srt_text_parser.js +8 -0
  197. package/lib/text/ssa_text_parser.js +8 -0
  198. package/lib/text/text_engine.js +19 -3
  199. package/lib/text/ttml_text_parser.js +16 -5
  200. package/lib/text/ui_text_displayer.js +2 -8
  201. package/lib/text/vtt_text_parser.js +24 -2
  202. package/lib/text/web_vtt_generator.js +1 -7
  203. package/lib/util/buffer_utils.js +1 -3
  204. package/lib/util/ebml_parser.js +3 -3
  205. package/lib/util/error.js +10 -14
  206. package/lib/util/fairplay_utils.js +109 -0
  207. package/lib/util/functional.js +0 -42
  208. package/lib/util/iterables.js +0 -46
  209. package/lib/util/mime_utils.js +2 -0
  210. package/lib/util/mp4_box_parsers.js +1 -4
  211. package/lib/util/mp4_parser.js +5 -7
  212. package/lib/util/periods.js +10 -11
  213. package/lib/util/platform.js +48 -3
  214. package/lib/util/player_configuration.js +12 -6
  215. package/lib/util/pssh.js +24 -8
  216. package/lib/util/stream_utils.js +96 -25
  217. package/lib/util/string_utils.js +3 -5
  218. package/lib/util/uint8array_utils.js +3 -21
  219. package/lib/util/xml_utils.js +16 -8
  220. package/package.json +61 -36
  221. package/roadmap.md +27 -27
  222. package/shaka-player.uncompiled.js +1 -3
  223. package/test/abr/simple_abr_manager_unit.js +3 -8
  224. package/test/ads/ad_manager_unit.js +0 -6
  225. package/test/cast/cast_proxy_unit.js +0 -8
  226. package/test/cast/cast_receiver_integration.js +1 -18
  227. package/test/cast/cast_receiver_unit.js +1 -9
  228. package/test/cast/cast_sender_unit.js +0 -6
  229. package/test/cast/cast_utils_unit.js +1 -13
  230. package/test/cea/cea608_memory_unit.js +0 -5
  231. package/test/cea/cea708_service_unit.js +0 -7
  232. package/test/cea/cea708_window_unit.js +0 -5
  233. package/test/cea/cea_decoder_unit.js +0 -6
  234. package/test/cea/dtvcc_packet_builder_unit.js +0 -3
  235. package/test/cea/dtvcc_packet_unit.js +0 -5
  236. package/test/cea/mp4_cea_parser_unit.js +0 -4
  237. package/test/dash/dash_parser_content_protection_unit.js +45 -10
  238. package/test/dash/dash_parser_live_unit.js +2 -15
  239. package/test/dash/dash_parser_manifest_unit.js +2 -40
  240. package/test/dash/dash_parser_segment_base_unit.js +1 -8
  241. package/test/dash/dash_parser_segment_list_unit.js +1 -7
  242. package/test/dash/dash_parser_segment_template_unit.js +3 -13
  243. package/test/dash/mpd_utils_unit.js +3 -11
  244. package/test/demo/demo_unit.js +2 -6
  245. package/test/deprecate/enforcer_unit.js +0 -4
  246. package/test/deprecate/version_unit.js +0 -2
  247. package/test/hls/hls_live_unit.js +101 -234
  248. package/test/hls/hls_parser_unit.js +517 -447
  249. package/test/hls/manifest_text_parser_unit.js +0 -10
  250. package/test/media/adaptation_set_criteria_unit.js +3 -7
  251. package/test/media/adaptation_set_unit.js +0 -2
  252. package/test/media/buffering_observer_unit.js +1 -4
  253. package/test/media/closed_caption_parser_unit.js +0 -3
  254. package/test/media/drm_engine_integration.js +2 -15
  255. package/test/media/drm_engine_unit.js +90 -144
  256. package/test/media/manifest_parser_unit.js +0 -4
  257. package/test/media/media_source_engine_integration.js +26 -10
  258. package/test/media/media_source_engine_unit.js +8 -20
  259. package/test/media/mp4_segment_index_parser_unit.js +0 -4
  260. package/test/media/play_rate_controller_unit.js +0 -4
  261. package/test/media/playhead_unit.js +35 -207
  262. package/test/media/presentation_timeline_unit.js +4 -7
  263. package/test/media/quality_observer_unit.js +0 -4
  264. package/test/media/region_observer_unit.js +1 -6
  265. package/test/media/region_timeline_unit.js +0 -3
  266. package/test/media/segment_index_unit.js +15 -31
  267. package/test/media/segment_reference_unit.js +0 -3
  268. package/test/media/stall_detector_unit.js +0 -5
  269. package/test/media/streaming_engine_integration.js +13 -75
  270. package/test/media/streaming_engine_unit.js +14 -37
  271. package/test/media/time_ranges_utils_unit.js +0 -7
  272. package/test/media/transmuxer_integration.js +0 -6
  273. package/test/media/webm_segment_index_parser_unit.js +0 -4
  274. package/test/net/data_uri_plugin_unit.js +0 -7
  275. package/test/net/http_plugin_unit.js +0 -9
  276. package/test/net/networking_engine_unit.js +0 -11
  277. package/test/offline/download_progress_estimator_unit.js +0 -2
  278. package/test/offline/indexeddb_storage_unit.js +0 -6
  279. package/test/offline/manifest_convert_unit.js +34 -12
  280. package/test/offline/offline_integration.js +1 -10
  281. package/test/offline/offline_manifest_parser_unit.js +1 -6
  282. package/test/offline/offline_scheme_unit.js +0 -8
  283. package/test/offline/offline_uri_unit.js +0 -2
  284. package/test/offline/storage_compatibility_unit.js +1 -14
  285. package/test/offline/storage_integration.js +6 -31
  286. package/test/player_external.js +1 -15
  287. package/test/player_integration.js +38 -28
  288. package/test/player_load_graph_integration.js +1 -6
  289. package/test/player_src_equals_external.js +3 -9
  290. package/test/player_src_equals_integration.js +0 -7
  291. package/test/player_unit.js +78 -37
  292. package/test/routing/walker_unit.js +0 -8
  293. package/test/test/assets/large_file.mpd +1 -1
  294. package/test/test/boot.js +75 -22
  295. package/test/test/externs/jasmine.js +2 -2
  296. package/test/test/externs/karma.js +4 -0
  297. package/test/test/namespace.js +10 -0
  298. package/test/test/util/canned_idb.js +0 -8
  299. package/test/test/util/cea_utils.js +0 -6
  300. package/test/test/util/dash_parser_util.js +0 -13
  301. package/test/test/util/fake_ad.js +0 -3
  302. package/test/test/util/fake_ad_manager.js +0 -9
  303. package/test/test/util/fake_demo_main.js +0 -5
  304. package/test/test/util/fake_drm_engine.js +0 -6
  305. package/test/test/util/fake_media_source_engine.js +11 -11
  306. package/test/test/util/fake_networking_engine.js +0 -5
  307. package/test/test/util/fake_text_displayer.js +0 -5
  308. package/test/test/util/indexeddb_utils.js +1 -10
  309. package/test/test/util/jasmine_fetch.js +0 -1
  310. package/test/test/util/loader.js +0 -18
  311. package/test/test/util/manifest_generator.js +12 -15
  312. package/test/test/util/manifest_parser_util.js +4 -7
  313. package/test/test/util/offline_utils.js +1 -5
  314. package/test/test/util/simple_fakes.js +9 -26
  315. package/test/test/util/stream_generator.js +0 -14
  316. package/test/test/util/streaming_engine_util.js +1 -15
  317. package/test/test/util/test_scheme.js +25 -20
  318. package/test/test/util/ttml_utils.js +0 -2
  319. package/test/test/util/ui_utils.js +0 -9
  320. package/test/test/util/util.js +9 -23
  321. package/test/test/util/waiter.js +84 -43
  322. package/test/text/cue_integration.js +2 -6
  323. package/test/text/lrc_text_parser_unit.js +6 -11
  324. package/test/text/mp4_ttml_parser_unit.js +6 -10
  325. package/test/text/mp4_vtt_parser_unit.js +7 -12
  326. package/test/text/sbv_text_parser_unit.js +5 -10
  327. package/test/text/simple_text_displayer_unit.js +1 -8
  328. package/test/text/srt_text_parser_unit.js +5 -10
  329. package/test/text/ssa_text_parser_unit.js +17 -34
  330. package/test/text/text_engine_unit.js +47 -12
  331. package/test/text/text_track_integration.js +0 -2
  332. package/test/text/ttml_text_parser_unit.js +79 -88
  333. package/test/text/ui_text_displayer_unit.js +44 -41
  334. package/test/text/vtt_text_parser_unit.js +55 -66
  335. package/test/text/web_vtt_generator_unit.js +0 -3
  336. package/test/ui/ad_ui_unit.js +0 -11
  337. package/test/ui/localization_unit.js +0 -3
  338. package/test/ui/text_displayer_layout_unit.js +1 -12
  339. package/test/ui/ui_customization_unit.js +0 -6
  340. package/test/ui/ui_integration.js +0 -32
  341. package/test/ui/ui_unit.js +28 -17
  342. package/test/util/abortable_operation_unit.js +4 -9
  343. package/test/util/array_utils_unit.js +0 -2
  344. package/test/util/buffer_utils_unit.js +0 -2
  345. package/test/util/cmcd_manager_unit.js +3 -3
  346. package/test/util/data_view_reader_unit.js +0 -4
  347. package/test/util/ebml_parser_unit.js +0 -4
  348. package/test/util/event_manager_unit.js +0 -3
  349. package/test/util/fake_event_target_unit.js +0 -5
  350. package/test/util/iterables_unit.js +0 -64
  351. package/test/util/language_utils_unit.js +0 -3
  352. package/test/util/manifest_parser_utils_unit.js +0 -2
  353. package/test/util/mp4_box_parsers_unit.js +0 -5
  354. package/test/util/mp4_parser_unit.js +0 -4
  355. package/test/util/multi_map_unit.js +0 -3
  356. package/test/util/object_utils_unit.js +0 -2
  357. package/test/util/periods_unit.js +14 -7
  358. package/test/util/pssh_unit.js +0 -5
  359. package/test/util/state_history_unit.js +0 -2
  360. package/test/util/stream_utils_unit.js +26 -15
  361. package/test/util/string_utils_unit.js +0 -6
  362. package/test/util/text_parser_unit.js +0 -2
  363. package/test/util/xml_utils_unit.js +0 -4
  364. package/ui/controls.js +65 -40
  365. package/ui/fullscreen_button.js +26 -6
  366. package/ui/less/ad_controls.less +6 -6
  367. package/ui/less/buttons.less +6 -6
  368. package/ui/less/containers.less +10 -12
  369. package/ui/less/overflow_menu.less +4 -4
  370. package/ui/less/range_elements.less +7 -2
  371. package/ui/less/tooltip.less +4 -4
  372. package/ui/locales/en.json +1 -0
  373. package/ui/locales/sjn-translations.yaml +257 -0
  374. package/ui/locales/sjn.json +42 -0
  375. package/ui/locales/source.json +5 -0
  376. package/ui/resolution_selection.js +31 -33
  377. package/ui/seek_bar.js +2 -1
  378. package/ui/ui.js +0 -17
  379. package/.github/workflows/build_and_test.yaml +0 -73
  380. package/.github/workflows/release.yaml +0 -53
  381. package/docs/tutorials/upgrade-v2-5.md +0 -441
  382. package/docs/tutorials/upgrade-v3.md +0 -38
  383. package/externs/svgelement.js +0 -18
  384. package/externs/webcrypto.js +0 -18
  385. package/lib/polyfill/mathround.js +0 -49
  386. package/lib/polyfill/patchedmediakeys_apple.js +0 -744
  387. package/lib/polyfill/patchedmediakeys_ms.js +0 -698
  388. package/lib/util/mutex.js +0 -52
  389. package/test/util/functional_unit.js +0 -82
package/CONTRIBUTING.md CHANGED
@@ -3,8 +3,8 @@
3
3
  We'd love to accept your patches and contributions to this project. There are
4
4
  just a few small guidelines you need to follow.
5
5
 
6
- 1. File a bug at https://github.com/google/shaka-player/issues (if there isn't
7
- one already). If your patch is going to be large, you should start a
6
+ 1. File a bug at https://github.com/shaka-project/shaka-player/issues (if there
7
+ isn't one already). If your patch is going to be large, you should start a
8
8
  discussion on GitHub first.
9
9
 
10
10
  Leave a comment to let us know that you are working on a PR for the issue.
package/CONTRIBUTORS CHANGED
@@ -50,6 +50,7 @@ Esteban Dosztal <edosztal@gmail.com>
50
50
  Fadomire <fadomire@gmail.com>
51
51
  François Beaufort <fbeaufort@google.com>
52
52
  Gil Gonen <gil.gonen@gmail.com>
53
+ Giorgio Gamberoni <giorgio.gamberoni@gmail.com>
53
54
  Giuseppe Samela <giuseppe.samela@gmail.com>
54
55
  Hichem Taoufik <hichem@code-it.fr>
55
56
  Itay Kinnrot <itay.kinnrot@kaltura.com>
@@ -65,6 +66,7 @@ John Bowers <john.bowers@verizondigitalmedia.com>
65
66
  Jonas Birmé <jonas.birme@eyevinn.se>
66
67
  Jono Ward <jonoward@gmail.com>
67
68
  Jozef Chúťka <jozefchutka@gmail.com>
69
+ Jun Hong Chong <chongjunhong@gmail.com>
68
70
  Leandro Ribeiro Moreira <leandro.ribeiro.moreira@gmail.com>
69
71
  Lucas Gabriel Sánchez <unkiwii@gmail.com>
70
72
  Matias Russitto <russitto@gmail.com>
@@ -95,6 +97,7 @@ Sam Dutton <dutton@google.com>
95
97
  Sanborn Hilland <sanbornh@rogers.com>
96
98
  Sander Saares <sander@saares.eu>
97
99
  Sandra Lokshina <ismena@google.com>
100
+ Sanil Raut <sr1990003@gmail.com>
98
101
  Satheesh Velmurugan <satheesh@philo.com>
99
102
  Semih Gokceoglu <semih.gkcoglu@gmail.com>
100
103
  Seth Madison <seth@philo.com>
package/README.md CHANGED
@@ -26,7 +26,7 @@ For details on what's coming next, see our [development roadmap](roadmap.md).
26
26
 
27
27
  ## Platform and browser support matrix
28
28
 
29
- |Browser |Windows |Mac |Linux |Android |iOS >= 12 |ChromeOS|Other|
29
+ |Browser |Windows |Mac |Linux |Android |iOS >= 13 |ChromeOS|Other|
30
30
  |:---------:|:--------:|:-------:|:-------:|:-------:|:--------:|:------:|:---:|
31
31
  |Chrome¹ |**Y** |**Y** |**Y** |**Y** |**Native**|**Y** | - |
32
32
  |Firefox¹ |**Y** |**Y** |**Y** |untested⁵|**Native**| - | - |
@@ -41,7 +41,7 @@ For details on what's coming next, see our [development roadmap](roadmap.md).
41
41
  |Xbox One | - | - | - | - | - | - |**Y**|
42
42
 
43
43
  NOTES:
44
- - ¹: On macOS, only Safari 12+ is supported. On iOS, only iOS 12+ is
44
+ - ¹: On macOS, only Safari 13+ is supported. On iOS, only iOS 13+ is
45
45
  supported. Older versions will be rejected.
46
46
  - ²: The latest stable Chromecast firmware is tested. Both sender and receiver
47
47
  can be implemented with Shaka Player.
@@ -52,9 +52,9 @@ NOTES:
52
52
  - ⁶: These are expected to work, but are community-supported and untested by
53
53
  us.
54
54
  - Official support for LG WebOS TV:
55
- https://github.com/google/shaka-player/issues/1330
55
+ https://github.com/shaka-project/shaka-player/issues/1330
56
56
 
57
- We support iOS 12+ through Apple's native HLS player. We provide the same
57
+ We support iOS 13+ through Apple's native HLS player. We provide the same
58
58
  top-level API, but we just set the video's `src` element to the manifest/media.
59
59
  So we are dependent on the browser supporting the manifests.
60
60
 
@@ -65,7 +65,7 @@ features and similar APIs for native apps on iOS. This project uses its own
65
65
  media stack, which allows it to play content that would otherwise not be
66
66
  supported. This supports both DASH and HLS manifests.
67
67
 
68
- [Shaka Player Embedded]: https://github.com/google/shaka-player-embedded
68
+ [Shaka Player Embedded]: https://github.com/shaka-project/shaka-player-embedded
69
69
 
70
70
 
71
71
  ## Manifest format support matrix
@@ -102,16 +102,18 @@ DASH features supported:
102
102
  DASH features **not** supported:
103
103
  - Xlink with actuate=onRequest
104
104
  - Manifests without any segment info:
105
- https://github.com/google/shaka-player/issues/1088
105
+ https://github.com/shaka-project/shaka-player/issues/1088
106
106
  - Changing codecs during a presentation (unsupported by MSE)
107
107
  - Multiple trick mode tracks for the same resolution at varying framerates or
108
108
  bitrates
109
109
  - Timescales so large that timestamps cannot be represented as integers in
110
- JavaScript (2^53): https://github.com/google/shaka-player/issues/1667
110
+ JavaScript (2^53): https://github.com/shaka-project/shaka-player/issues/1667
111
111
 
112
112
 
113
113
  ## HLS features
114
114
 
115
+ **Only supported on browsers with SourceBuffer.mode=sequence support**
116
+
115
117
  HLS features supported:
116
118
  - VOD, Live, and Event types
117
119
  - Low-latency streaming with partial segments, preload hints, and delta updates
@@ -122,13 +124,12 @@ HLS features supported:
122
124
  - WebVTT and TTML
123
125
  - CEA-608/708 captions
124
126
  - Encrypted content with PlayReady and Widevine
125
- - Encrypted content with FairPlay (Safari on macOS and iOS 12+ only)
127
+ - Encrypted content with FairPlay (Safari on macOS and iOS 13+ only)
128
+ - Raw AAC, MP3, etc (without an MP4 container)
126
129
 
127
130
  HLS features **not** supported:
128
- - Key rotation: https://github.com/google/shaka-player/issues/917
129
- - I-frame-only playlists: https://github.com/google/shaka-player/issues/742
130
- - Raw AAC, MP3, etc (without an MP4 container):
131
- https://github.com/google/shaka-player/issues/2337
131
+ - Key rotation: https://github.com/shaka-project/shaka-player/issues/917
132
+ - I-frame-only playlists: https://github.com/shaka-project/shaka-player/issues/742
132
133
  - Low-latency streaming with blocking playlist reload
133
134
 
134
135
  [mux.js]: https://github.com/videojs/mux.js/releases
@@ -171,7 +172,9 @@ NOTES:
171
172
  |HLS |**Y** |**Y** |**Y** ¹ | - |
172
173
 
173
174
  NOTES:
174
- - ¹: We support FairPlay through Apple's native HLS player.
175
+ - ¹: By default, FairPlay is handled using Apple's native HLS player, when on
176
+ Safari. We do support FairPlay through MSE/EME, however. See the
177
+ `streaming.useNativeHlsOnSafari` configuration value.
175
178
 
176
179
 
177
180
  ## Media container and subtitle support
@@ -0,0 +1,9 @@
1
+ # Google App Engine Code
2
+
3
+ This folder contains source code for the services we run on Google App Engine
4
+ (appspot.com).
5
+
6
+ - shaka-player-demo: Our hosted demo on https://shaka-player-demo.appspot.com/
7
+
8
+ - demo-version-index: An index of Shaka Player releases and demos, hosted at
9
+ https://index-dot-shaka-player-demo.appspot.com/
@@ -0,0 +1,14 @@
1
+ # Google App Engine Version Index
2
+
3
+ This folder contains everything necessary to host an index of Shaka Player
4
+ releases and demos at https://index-dot-shaka-player-demo.appspot.com/
5
+
6
+ - app.yaml: App Engine config file. Defines the runtime (Python 3).
7
+
8
+ - generate.py: A python script that generates the index's static content from
9
+ a template.
10
+
11
+ - requirements.txt: Used by App Engine to install the necessary Python server
12
+ requirements (Flask).
13
+
14
+ - templates/index.html: A Jinja2 template used to generate the index HTML.
@@ -0,0 +1,28 @@
1
+ # Copyright 2022 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ runtime: python39
16
+ default_expiration: 1h
17
+
18
+ handlers:
19
+ # Server static/index.html as the root.
20
+ - url: /
21
+ secure: always
22
+ static_files: static/index.html
23
+ upload: static/index.html
24
+ # Any other requests are served from the static/ folder.
25
+ - url: /(.+)
26
+ secure: always
27
+ static_files: static/\1
28
+ upload: static/.+
@@ -0,0 +1,164 @@
1
+ #!/usr/bin/env python3
2
+
3
+ # Shaka Player Version Index Generator
4
+ # Copyright 2022 Google LLC
5
+ # SPDX-License-Identifier: Apache-2.0
6
+
7
+ # Generate an index of Shaka Player versions on appspot.
8
+
9
+ import collections
10
+ import jinja2
11
+ import os
12
+ import re
13
+ import subprocess
14
+
15
+ DEMO_URL_TEMPLATE = 'https://{0}-dot-shaka-player-demo.appspot.com/'
16
+
17
+ # In Google Hosted Libraries
18
+ HOSTED_URL_TEMPLATE = 'https://ajax.googleapis.com/ajax/libs/shaka-player/{0}/shaka-player.{1}'
19
+
20
+ # Before Google Hosted Libraries, v1 appspot URLs
21
+ V1_URL_TEMPLATE = 'https://{0}-dot-shaka-player-demo.appspot.com/shaka-player.{1}'
22
+ # Before Google Hosted Libraries, v2 appspot URLs
23
+ V2_URL_TEMPLATE = 'https://{0}-dot-shaka-player-demo.appspot.com/dist/shaka-player.{1}'
24
+
25
+ def version_to_demo_url(v):
26
+ return DEMO_URL_TEMPLATE.format(v.replace('.', '-'))
27
+
28
+ def version_to_lib_url(v):
29
+ if v == 'nightly':
30
+ return V2_URL_TEMPLATE.format(v, 'compiled.js')
31
+ elif (version_key(v) == version_key('v1.6.5') or
32
+ version_key(v) >= version_key('v2.0.6')):
33
+ return HOSTED_URL_TEMPLATE.format(v.replace('v', ''), 'compiled.js')
34
+ elif version_key(v) >= version_key('v2.0.0-beta'):
35
+ return V2_URL_TEMPLATE.format(v.replace('.', '-'), 'compiled.js')
36
+ else:
37
+ return V1_URL_TEMPLATE.format(v.replace('.', '-'), 'compiled.js')
38
+
39
+ def version_to_ui_lib_url(v):
40
+ if v == 'nightly':
41
+ return V2_URL_TEMPLATE.format(v, 'ui.js')
42
+ elif version_key(v) >= version_key('v2.5.0'):
43
+ return HOSTED_URL_TEMPLATE.format(v.replace('v', ''), 'ui.js')
44
+ else:
45
+ return None
46
+
47
+ def version_to_lib_externs_url(v):
48
+ if v == 'nightly':
49
+ return V2_URL_TEMPLATE.format(v, 'compiled.externs.js')
50
+ elif version_key(v) >= version_key('v2.0.6'):
51
+ return HOSTED_URL_TEMPLATE.format(v.replace('v', ''), 'compiled.externs.js')
52
+ else:
53
+ return None
54
+
55
+ def version_to_ui_lib_externs_url(v):
56
+ if v == 'nightly':
57
+ return V2_URL_TEMPLATE.format(v, 'ui.externs.js')
58
+ elif version_key(v) >= version_key('v2.5.0'):
59
+ return HOSTED_URL_TEMPLATE.format(v.replace('v', ''), 'ui.externs.js')
60
+ else:
61
+ return None
62
+
63
+ def version_to_lib_defs_url(v):
64
+ if v == 'nightly':
65
+ return V2_URL_TEMPLATE.format(v, 'compiled.d.ts')
66
+ elif version_key(v) >= version_key('v3.0.6'):
67
+ return HOSTED_URL_TEMPLATE.format(v.replace('v', ''), 'compiled.d.ts')
68
+ else:
69
+ return None
70
+
71
+ def version_to_ui_lib_defs_url(v):
72
+ if v == 'nightly':
73
+ return V2_URL_TEMPLATE.format(v, 'ui.d.ts')
74
+ elif version_key(v) >= version_key('v3.0.6'):
75
+ return HOSTED_URL_TEMPLATE.format(v.replace('v', ''), 'ui.d.ts')
76
+ else:
77
+ return None
78
+
79
+ def version_to_metadata(v):
80
+ return {
81
+ 'version': v,
82
+ 'best': False, # Corrected later in another loop
83
+ 'demo': version_to_demo_url(v),
84
+ 'lib': version_to_lib_url(v),
85
+ 'ui_lib': version_to_ui_lib_url(v),
86
+ 'lib_externs': version_to_lib_externs_url(v),
87
+ 'ui_lib_externs': version_to_ui_lib_externs_url(v),
88
+ 'lib_defs': version_to_lib_defs_url(v),
89
+ 'ui_lib_defs': version_to_ui_lib_defs_url(v),
90
+ }
91
+
92
+ def is_release_tag(name):
93
+ matches = re.match(r'v\d+\.\d+\.\d+(-.+)?', name)
94
+ # Doesn't match, not a version tag.
95
+ if not matches:
96
+ return False
97
+ # A "master" (old) or "main" (new) tag, indicating the state of the main
98
+ # branch at the time of a release. Not an actual version in itself, though.
99
+ if matches.group(1) == '-master' or matches.group(1) == '-main':
100
+ return False
101
+ # For historical reasons, these oldest few tags are not currently deployed to
102
+ # appengine. All other matching tags are, though.
103
+ if name in ['v1.2.0', 'v1.2.1', 'v1.2.2', 'v1.2.3']:
104
+ return False
105
+ return True
106
+
107
+ def version_key(version):
108
+ if version == 'nightly':
109
+ # A false version number for nightly, greater than any actual release
110
+ # version.
111
+ return [float('inf')]
112
+
113
+ assert version[0] == 'v'
114
+ main_version, _, suffix = version[1:].partition('-')
115
+ if not suffix:
116
+ suffix = '}}}' # this puts main releases after prerelease versions
117
+ version_tuple = [int(x) for x in main_version.split('.')]
118
+ return version_tuple + [suffix]
119
+
120
+ def get_release_tags():
121
+ output = subprocess.check_output(['git', 'tag'], text=True)
122
+ return list(filter(is_release_tag, output.split('\n')))
123
+
124
+ def generate():
125
+ # Get all release tags.
126
+ versions = get_release_tags()
127
+ # Now sort, putting prerelease versions ahead of the corresponding release.
128
+ versions.sort(key=version_key)
129
+
130
+ version_metadata = collections.OrderedDict()
131
+ latest_by_branch = {}
132
+ for v in versions:
133
+ version_metadata[v] = version_to_metadata(v)
134
+
135
+ # Because |versions| is already sorted, we can just overwrite the entry
136
+ # in the latest_by_branch dictionary.
137
+ branch_key = tuple(version_key(v)[0:2])
138
+ latest_by_branch[branch_key] = v
139
+
140
+ for v in latest_by_branch.values():
141
+ version_metadata[v]['best'] = True
142
+
143
+ # Append nightly rather than filter for it, so that it always appears at the
144
+ # end of the list.
145
+ version_metadata['nightly'] = version_to_metadata('nightly')
146
+ version_metadata['nightly']['best'] = True
147
+
148
+ # Debug: uncomment to see a list of version metadata objects.
149
+ #for i in version_metadata.values(): print(i)
150
+
151
+ script_path = os.path.dirname(__file__)
152
+ template_path = os.path.join(script_path, 'templates', 'index.html')
153
+ output_path = os.path.join(script_path, 'static', 'index.html')
154
+
155
+ os.makedirs(os.path.dirname(output_path), exist_ok=True)
156
+
157
+ with open(template_path, 'r') as template_file:
158
+ with open(output_path, 'w') as output_file:
159
+ template = jinja2.Template(template_file.read())
160
+ output = template.render(versions=version_metadata.values())
161
+ output_file.write(output)
162
+
163
+ if __name__ == '__main__':
164
+ generate()
@@ -0,0 +1,11 @@
1
+ # Shaka Player Version Index - Appspot Entrypoint
2
+ # Copyright 2022 Google LLC
3
+ # SPDX-License-Identifier: Apache-2.0
4
+
5
+ # In the App Engine Python 3 runtime, you must have an entrypoint, even if all
6
+ # content is static and no routes are defined. This seems pretty weird, and
7
+ # wasn't required in the Python 2 runtime.
8
+
9
+ from flask import Flask
10
+
11
+ app = Flask(__name__)
@@ -0,0 +1,5 @@
1
+ # Shaka Player Version Index - Appspot Python Runtime Requirements
2
+ # Copyright 2022 Google LLC
3
+ # SPDX-License-Identifier: Apache-2.0
4
+
5
+ Flask==2.0.3
@@ -0,0 +1,114 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Shaka Player Demo - Version Index</title>
5
+ <style>
6
+
7
+ #background {
8
+ top: 0;
9
+ left: 0;
10
+ bottom: 0;
11
+ right: 0;
12
+ position: fixed;
13
+ z-index: -1;
14
+
15
+ background:
16
+ url(https://shaka-player-demo.appspot.com/assets/poster.jpg)
17
+ no-repeat center center fixed;
18
+ background-size: contain;
19
+
20
+ opacity: 0.4;
21
+ filter: sepia(50%);
22
+ }
23
+
24
+ #links {
25
+ margin: 20px;
26
+ }
27
+
28
+ #links a {
29
+ margin: 0.5em;
30
+ padding: 0.5em;
31
+
32
+ border: 2px solid black;
33
+ background-color: #006;
34
+
35
+ font-size: 110%;
36
+ color: white;
37
+ font-weight: bold;
38
+ text-decoration: none;
39
+ }
40
+
41
+ table.best tr.old {
42
+ display: none;
43
+ }
44
+
45
+ th, td {
46
+ border: 1px solid black;
47
+ padding: 0.2em 2em;
48
+ }
49
+
50
+ table.best tr.best-even,
51
+ table.all tr:nth-child(2n) {
52
+ background-color: rgba(0,0,0,0.1);
53
+ }
54
+
55
+ </style>
56
+ <script>
57
+ function display(which) {
58
+ table.class = 'which';
59
+ }
60
+ </script>
61
+ </head>
62
+ <body>
63
+ <div id="background"></div>
64
+
65
+ <h1>Shaka Player release demos on appspot</h1>
66
+
67
+ <div id="links">
68
+ <a href="#" onclick="table.className = 'best'">Best versions</a>
69
+ <a href="#" onclick="table.className = 'all'">All versions</a>
70
+ </div>
71
+
72
+ <table id="table" class="best">
73
+ <tr><th>Version</th></tr>
74
+ {% set best_counter = 0 %}
75
+ {% for v in versions %}
76
+ {% if v.best %}
77
+ <tr class="best {{'best-even' if best_counter % 2 == 0 else ''}}">
78
+ {% set best_counter = best_counter + 1 %}
79
+ {% else %}
80
+ <tr class="old">
81
+ {% endif %}
82
+ <th>{{ v.version }}</th>
83
+ <td><a href="{{ v.demo }}">demo</a></td>
84
+ <td><a href="{{ v.lib }}">non-UI library</a></td>
85
+ <td>
86
+ {% if v.ui_lib %}
87
+ <a href="{{ v.ui_lib }}">UI-enabled library</a>
88
+ {% endif %}
89
+ </td>
90
+ <td>
91
+ {% if v.lib_externs %}
92
+ <a href="{{ v.lib_externs }}">non-UI externs</a>
93
+ {% endif %}
94
+ </td>
95
+ <td>
96
+ {% if v.ui_lib_externs %}
97
+ <a href="{{ v.ui_lib_externs }}">UI-enabled externs</a>
98
+ {% endif %}
99
+ </td>
100
+ <td>
101
+ {% if v.lib_defs %}
102
+ <a href="{{ v.lib_defs }}">non-UI typescript defs</a>
103
+ {% endif %}
104
+ </td>
105
+ <td>
106
+ {% if v.ui_lib_defs %}
107
+ <a href="{{ v.ui_lib_defs }}">UI-enabled typescript defs</a>
108
+ {% endif %}
109
+ </td>
110
+ </tr>
111
+ {% endfor %}
112
+ </table>
113
+ </body>
114
+ </html>
@@ -0,0 +1,18 @@
1
+ # Google App Engine Demo
2
+
3
+ This folder contains everything necessary to host our demo on
4
+ https://shaka-player-demo.appspot.com/
5
+
6
+ - app.yaml: App Engine config file. Defines cache expiration and how specific
7
+ URLs are mapped to specific files.
8
+
9
+ - main.py: A catch-all python service to serve any non-static files. This
10
+ handles HTTP redirects for the root path (this is the only way to
11
+ do HTTP redirects in App Engine) and the poster service (which
12
+ returns special poster images on certain days).
13
+
14
+ - requirements.txt: Used by App Engine to install the necessary Python server
15
+ requirements (Flask).
16
+
17
+ - time.txt: A static file used for time sync in the client. Configured with
18
+ special response headers for cross-origin access.
@@ -0,0 +1,61 @@
1
+ # Copyright 2016 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ runtime: python39
16
+ default_expiration: 5m
17
+
18
+ handlers:
19
+ # A static file used for clock sync in the demo app
20
+ - url: /time.txt
21
+ static_files: time.txt
22
+ upload: time.txt
23
+ expiration: 0
24
+ http_headers:
25
+ Access-Control-Allow-Origin: "*"
26
+ Access-Control-Allow-Headers: "If-Modified-Since,Range,Origin"
27
+ Access-Control-Expose-Headers: "Date"
28
+ Access-Control-Max-Age: "2592000"
29
+
30
+ # These used to exist in the repo, but have been generated server-side for many
31
+ # years now.
32
+ - url: /assets/poster.jpg
33
+ script: auto
34
+ - url: /assets/audioOnly.gif
35
+ script: auto
36
+
37
+ # Serve favicon.ico from the demo folder.
38
+ - url: /favicon.ico
39
+ secure: always
40
+ static_files: demo/favicon.ico
41
+ upload: demo/favicon.ico
42
+
43
+ # For these folders, serve their indexes.
44
+ - url: /docs/api/
45
+ secure: always
46
+ static_files: docs/api/index.html
47
+ upload: docs/api/index.html
48
+ - url: /demo/
49
+ secure: always
50
+ static_files: demo/index.html
51
+ upload: demo/index.html
52
+ - url: /demo/
53
+ secure: always
54
+ static_files: demo/index.html
55
+ upload: demo/index.html
56
+
57
+ # Serve everything else directly.
58
+ - url: /(.+)
59
+ secure: always
60
+ static_files: \1
61
+ upload: .+
@@ -0,0 +1,95 @@
1
+ # Shaka Player Demo - Appspot Entrypoint
2
+ # Copyright 2022 Google LLC
3
+ # SPDX-License-Identifier: Apache-2.0
4
+
5
+ # Most of the app is served as static content. Any exceptions go here.
6
+
7
+ import datetime
8
+ import os
9
+
10
+ from flask import Flask, make_response, redirect, request, send_file
11
+
12
+
13
+ app = Flask(__name__)
14
+
15
+
16
+ # Redirect root requests to /demo.
17
+ @app.route('/')
18
+ def root():
19
+ return redirect('/demo/', code=302)
20
+
21
+
22
+ # A Doodle-like service to change the poster on certain days.
23
+ # All posters are chosen based on the current date in PST.
24
+
25
+ from posters import VIDEO_POSTERS, VIDEO_DEFAULT, AUDIO_POSTERS, AUDIO_DEFAULT
26
+
27
+
28
+ # Timezone info for PST.
29
+ # I'm ignoring DST to avoid complicating the code.
30
+ class PST(datetime.tzinfo):
31
+ def utcoffset(self, dt):
32
+ return datetime.timedelta(hours=-8)
33
+
34
+ def dst(self, dt):
35
+ return datetime.timedelta(0)
36
+
37
+ def tzname(self, dt):
38
+ return 'PST'
39
+
40
+
41
+ def get_poster(poster_map, default_poster):
42
+ now = datetime.datetime.now(PST())
43
+ today = (now.month, now.day)
44
+ today_with_year = (now.month, now.day, now.year)
45
+ midnight = datetime.datetime(now.year, now.month, now.day, tzinfo=PST())
46
+ local_expiration = midnight + datetime.timedelta(days=1)
47
+ max_age = (local_expiration - now).total_seconds()
48
+
49
+ # For internal debugging and testing of the poster service, we can override
50
+ # the date. To set an override, open /assets/poster.jpg and run this in the
51
+ # JS console:
52
+ # document.cookie="posterdate=10-31"
53
+ # To clear an override, run:
54
+ # document.cookie="posterdate="
55
+ override = request.cookies.get('posterdate')
56
+ if override:
57
+ override_tuple = [int(x) for x in override.split('-')]
58
+ print('Date override:', repr(override_tuple))
59
+
60
+ if len(override_tuple) == 3:
61
+ # Override includes year.
62
+ today_with_year = tuple(override_tuple)
63
+ today = tuple(override_tuple[0:2])
64
+ elif len(override_tuple) == 2:
65
+ # Override does not include year, so add the current year.
66
+ today_with_year = tuple(override_tuple + [now.year])
67
+ today = tuple(override_tuple)
68
+ else:
69
+ # Bad override format. Ignore the year, but add a response header to
70
+ # indicate that the override failed. For internal debugging of the
71
+ # poster service.
72
+ print('Bad date override:', override, file=sys.stderr)
73
+
74
+ # Prefer a poster for this specific year.
75
+ name = poster_map.get(today_with_year, poster_map.get(today, default_poster))
76
+ path = 'posters/%s' % name
77
+
78
+ response = make_response(
79
+ send_file(path, last_modified=midnight, max_age=max_age))
80
+
81
+ response.headers['Access-Control-Allow-Origin'] = '*'
82
+ response.headers['Access-Control-Allow-Headers'] = 'If-Modified-Since,Range'
83
+ response.headers['Access-Control-Expose-Headers'] = 'Date'
84
+ response.headers['Access-Control-Max-Age'] = '2592000'
85
+
86
+ return response
87
+
88
+
89
+ @app.route('/assets/poster.jpg')
90
+ def get_video_poster():
91
+ return get_poster(VIDEO_POSTERS, VIDEO_DEFAULT)
92
+
93
+ @app.route('/assets/audioOnly.gif')
94
+ def get_audio_poster():
95
+ return get_poster(AUDIO_POSTERS, AUDIO_DEFAULT)