@tarojs/components 3.5.7-alpha.6 → 3.6.0-canary.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.
- package/README.md +1 -1
- package/dist/cjs/helper-db78e01a.js +2 -0
- package/dist/cjs/helper-db78e01a.js.map +1 -0
- package/dist/cjs/index-47a1959e.js +2 -0
- package/dist/cjs/index-47a1959e.js.map +1 -0
- package/dist/cjs/{index-7c61bee9.js → index-9174e0b1.js} +477 -234
- package/dist/cjs/index-9174e0b1.js.map +1 -0
- package/dist/cjs/index-f9d21cc5.js +2 -0
- package/dist/cjs/index-f9d21cc5.js.map +1 -0
- package/dist/cjs/index.cjs.js +2 -0
- package/dist/cjs/index.cjs.js.map +1 -0
- package/dist/cjs/intersection-observer-dc4cfcef.js +2 -0
- package/dist/cjs/intersection-observer-dc4cfcef.js.map +1 -0
- package/dist/cjs/loader.cjs.js +5 -3
- package/dist/cjs/loader.cjs.js.map +1 -0
- package/dist/cjs/taro-ad-core.cjs.entry.js +4 -2
- package/dist/cjs/taro-ad-core.cjs.entry.js.map +1 -0
- package/dist/cjs/taro-ad-custom-core.cjs.entry.js +4 -2
- package/dist/cjs/taro-ad-custom-core.cjs.entry.js.map +1 -0
- package/dist/cjs/taro-audio-core.cjs.entry.js +5 -2
- package/dist/cjs/taro-audio-core.cjs.entry.js.map +1 -0
- package/dist/cjs/taro-block-core.cjs.entry.js +4 -2
- package/dist/cjs/taro-block-core.cjs.entry.js.map +1 -0
- package/dist/cjs/taro-button-core.cjs.entry.js +7 -2
- package/dist/cjs/taro-button-core.cjs.entry.js.map +1 -0
- package/dist/cjs/taro-camera-core.cjs.entry.js +4 -2
- package/dist/cjs/taro-camera-core.cjs.entry.js.map +1 -0
- package/dist/cjs/taro-canvas-core.cjs.entry.js +6 -3
- package/dist/cjs/taro-canvas-core.cjs.entry.js.map +1 -0
- package/dist/cjs/taro-checkbox-core_2.cjs.entry.js +14 -8
- package/dist/cjs/taro-checkbox-core_2.cjs.entry.js.map +1 -0
- package/dist/cjs/taro-components.cjs.js +5 -3
- package/dist/cjs/taro-components.cjs.js.map +1 -0
- package/dist/cjs/taro-cover-image-core.cjs.entry.js +5 -2
- package/dist/cjs/taro-cover-image-core.cjs.entry.js.map +1 -0
- package/dist/cjs/taro-cover-view-core.cjs.entry.js +7 -3
- package/dist/cjs/taro-cover-view-core.cjs.entry.js.map +1 -0
- package/dist/cjs/taro-custom-wrapper-core.cjs.entry.js +4 -2
- package/dist/cjs/taro-custom-wrapper-core.cjs.entry.js.map +1 -0
- package/dist/cjs/taro-editor-core.cjs.entry.js +4 -2
- package/dist/cjs/taro-editor-core.cjs.entry.js.map +1 -0
- package/dist/cjs/taro-form-core.cjs.entry.js +5 -2
- package/dist/cjs/taro-form-core.cjs.entry.js.map +1 -0
- package/dist/cjs/taro-functional-page-navigator-core.cjs.entry.js +4 -2
- package/dist/cjs/taro-functional-page-navigator-core.cjs.entry.js.map +1 -0
- package/dist/cjs/taro-icon-core.cjs.entry.js +6 -2
- package/dist/cjs/taro-icon-core.cjs.entry.js.map +1 -0
- package/dist/cjs/taro-image-core.cjs.entry.js +5 -2
- package/dist/cjs/taro-image-core.cjs.entry.js.map +1 -0
- package/dist/cjs/taro-input-core.cjs.entry.js +18 -10
- package/dist/cjs/taro-input-core.cjs.entry.js.map +1 -0
- package/dist/cjs/taro-keyboard-accessory-core.cjs.entry.js +4 -2
- package/dist/cjs/taro-keyboard-accessory-core.cjs.entry.js.map +1 -0
- package/dist/cjs/taro-label-core.cjs.entry.js +5 -2
- package/dist/cjs/taro-label-core.cjs.entry.js.map +1 -0
- package/dist/cjs/taro-live-player-core.cjs.entry.js +4 -2
- package/dist/cjs/taro-live-player-core.cjs.entry.js.map +1 -0
- package/dist/cjs/taro-live-pusher-core.cjs.entry.js +4 -2
- package/dist/cjs/taro-live-pusher-core.cjs.entry.js.map +1 -0
- package/dist/cjs/taro-map-core.cjs.entry.js +4 -2
- package/dist/cjs/taro-map-core.cjs.entry.js.map +1 -0
- package/dist/cjs/taro-match-media-core.cjs.entry.js +4 -2
- package/dist/cjs/taro-match-media-core.cjs.entry.js.map +1 -0
- package/dist/cjs/{taro-movable-view-core.cjs.entry.js → taro-movable-area-core_2.cjs.entry.js} +187 -97
- package/dist/cjs/taro-movable-area-core_2.cjs.entry.js.map +1 -0
- package/dist/cjs/taro-navigation-bar-core.cjs.entry.js +4 -2
- package/dist/cjs/taro-navigation-bar-core.cjs.entry.js.map +1 -0
- package/dist/cjs/taro-navigator-core.cjs.entry.js +6 -2
- package/dist/cjs/taro-navigator-core.cjs.entry.js.map +1 -0
- package/dist/cjs/taro-official-account-core.cjs.entry.js +4 -2
- package/dist/cjs/taro-official-account-core.cjs.entry.js.map +1 -0
- package/dist/cjs/taro-open-data-core.cjs.entry.js +4 -2
- package/dist/cjs/taro-open-data-core.cjs.entry.js.map +1 -0
- package/dist/cjs/taro-page-container-core.cjs.entry.js +4 -2
- package/dist/cjs/taro-page-container-core.cjs.entry.js.map +1 -0
- package/dist/cjs/taro-page-meta-core.cjs.entry.js +4 -2
- package/dist/cjs/taro-page-meta-core.cjs.entry.js.map +1 -0
- package/dist/cjs/taro-picker-core_2.cjs.entry.js +31 -15
- package/dist/cjs/taro-picker-core_2.cjs.entry.js.map +1 -0
- package/dist/cjs/{taro-picker-view-core.cjs.entry.js → taro-picker-view-column-core_2.cjs.entry.js} +101 -6
- package/dist/cjs/taro-picker-view-column-core_2.cjs.entry.js.map +1 -0
- package/dist/cjs/taro-progress-core.cjs.entry.js +7 -5
- package/dist/cjs/taro-progress-core.cjs.entry.js.map +1 -0
- package/dist/cjs/taro-pull-to-refresh.cjs.entry.js +10 -8
- package/dist/cjs/taro-pull-to-refresh.cjs.entry.js.map +1 -0
- package/dist/cjs/taro-radio-core_2.cjs.entry.js +15 -9
- package/dist/cjs/taro-radio-core_2.cjs.entry.js.map +1 -0
- package/dist/cjs/taro-rich-text-core.cjs.entry.js +5 -2
- package/dist/cjs/taro-rich-text-core.cjs.entry.js.map +1 -0
- package/dist/cjs/taro-root-portal-core.cjs.entry.js +4 -2
- package/dist/cjs/taro-root-portal-core.cjs.entry.js.map +1 -0
- package/dist/cjs/taro-scroll-view-core.cjs.entry.js +28 -22
- package/dist/cjs/taro-scroll-view-core.cjs.entry.js.map +1 -0
- package/dist/cjs/taro-share-element-core.cjs.entry.js +4 -2
- package/dist/cjs/taro-share-element-core.cjs.entry.js.map +1 -0
- package/dist/cjs/taro-slider-core.cjs.entry.js +23 -19
- package/dist/cjs/taro-slider-core.cjs.entry.js.map +1 -0
- package/dist/cjs/taro-slot-core.cjs.entry.js +4 -7
- package/dist/cjs/taro-slot-core.cjs.entry.js.map +1 -0
- package/dist/cjs/taro-swiper-core_2.cjs.entry.js +25 -56
- package/dist/cjs/taro-swiper-core_2.cjs.entry.js.map +1 -0
- package/dist/cjs/taro-switch-core.cjs.entry.js +12 -8
- package/dist/cjs/taro-switch-core.cjs.entry.js.map +1 -0
- package/dist/cjs/taro-tabbar.cjs.entry.js +12 -4
- package/dist/cjs/taro-tabbar.cjs.entry.js.map +1 -0
- package/dist/cjs/taro-text-core.cjs.entry.js +4 -2
- package/dist/cjs/taro-text-core.cjs.entry.js.map +1 -0
- package/dist/cjs/taro-textarea-core.cjs.entry.js +13 -8
- package/dist/cjs/taro-textarea-core.cjs.entry.js.map +1 -0
- package/dist/cjs/taro-video-control_3.cjs.entry.js +142 -260
- package/dist/cjs/taro-video-control_3.cjs.entry.js.map +1 -0
- package/dist/cjs/taro-view-core.cjs.entry.js +7 -3
- package/dist/cjs/taro-view-core.cjs.entry.js.map +1 -0
- package/dist/cjs/taro-voip-room-core.cjs.entry.js +4 -2
- package/dist/cjs/taro-voip-room-core.cjs.entry.js.map +1 -0
- package/dist/cjs/taro-web-view-core.cjs.entry.js +5 -2
- package/dist/cjs/taro-web-view-core.cjs.entry.js.map +1 -0
- package/dist/collection/collection-manifest.json +16 -4
- package/dist/collection/components/ad/ad.js +2 -1
- package/dist/collection/components/ad/ad.js.map +1 -0
- package/dist/collection/components/ad-custom/ad-custom.js +2 -1
- package/dist/collection/components/ad-custom/ad-custom.js.map +1 -0
- package/dist/collection/components/audio/audio.js +199 -190
- package/dist/collection/components/audio/audio.js.map +1 -0
- package/dist/collection/components/block/block.js +2 -2
- package/dist/collection/components/block/block.js.map +1 -0
- package/dist/collection/components/button/button.js +224 -211
- package/dist/collection/components/button/button.js.map +1 -0
- package/dist/collection/components/camera/camera.js +2 -1
- package/dist/collection/components/camera/camera.js.map +1 -0
- package/dist/collection/components/canvas/canvas.js +67 -58
- package/dist/collection/components/canvas/canvas.js.map +1 -0
- package/dist/collection/components/checkbox/checkbox-group.js +50 -42
- package/dist/collection/components/checkbox/checkbox-group.js.map +1 -0
- package/dist/collection/components/checkbox/checkbox.js +174 -161
- package/dist/collection/components/checkbox/checkbox.js.map +1 -0
- package/dist/collection/components/cover-image/cover-image.js +81 -72
- package/dist/collection/components/cover-image/cover-image.js.map +1 -0
- package/dist/collection/components/cover-view/cover-view.js +131 -118
- package/dist/collection/components/cover-view/cover-view.js.map +1 -0
- package/dist/collection/components/custom-wrapper/custom-wrapper.js +2 -2
- package/dist/collection/components/custom-wrapper/custom-wrapper.js.map +1 -0
- package/dist/collection/components/editor/editor.js +2 -1
- package/dist/collection/components/editor/editor.js.map +1 -0
- package/dist/collection/components/form/form.js +48 -40
- package/dist/collection/components/form/form.js.map +1 -0
- package/dist/collection/components/functional-page-navigator/functional-page-navigator.js +2 -1
- package/dist/collection/components/functional-page-navigator/functional-page-navigator.js.map +1 -0
- package/dist/collection/components/icon/icon.js +61 -56
- package/dist/collection/components/icon/icon.js.map +1 -0
- package/dist/collection/components/image/image.js +123 -111
- package/dist/collection/components/image/image.js.map +1 -0
- package/dist/collection/components/input/input.js +310 -293
- package/dist/collection/components/input/input.js.map +1 -0
- package/dist/collection/components/keyboard-accessory/keyboard-accessory.js +2 -1
- package/dist/collection/components/keyboard-accessory/keyboard-accessory.js.map +1 -0
- package/dist/collection/components/label/label.js +27 -22
- package/dist/collection/components/label/label.js.map +1 -0
- package/dist/collection/components/live-player/live-player.js +2 -1
- package/dist/collection/components/live-player/live-player.js.map +1 -0
- package/dist/collection/components/live-pusher/live-pusher.js +2 -1
- package/dist/collection/components/live-pusher/live-pusher.js.map +1 -0
- package/dist/collection/components/map/map.js +2 -1
- package/dist/collection/components/map/map.js.map +1 -0
- package/dist/collection/components/match-media/match-media.js +2 -1
- package/dist/collection/components/match-media/match-media.js.map +1 -0
- package/dist/collection/components/movable-area/movable-area.js +34 -26
- package/dist/collection/components/movable-area/movable-area.js.map +1 -0
- package/dist/collection/components/movable-area/movable-view.js +415 -457
- package/dist/collection/components/movable-area/movable-view.js.map +1 -0
- package/dist/collection/components/navigation-bar/navigation-bar.js +2 -1
- package/dist/collection/components/navigation-bar/navigation-bar.js.map +1 -0
- package/dist/collection/components/navigator/navigator.js +158 -145
- package/dist/collection/components/navigator/navigator.js.map +1 -0
- package/dist/collection/components/official-account/official-account.js +2 -1
- package/dist/collection/components/official-account/official-account.js.map +1 -0
- package/dist/collection/components/open-data/open-data.js +2 -1
- package/dist/collection/components/open-data/open-data.js.map +1 -0
- package/dist/collection/components/page-container/page-container.js +2 -1
- package/dist/collection/components/page-container/page-container.js.map +1 -0
- package/dist/collection/components/page-meta/page-meta.js +2 -1
- package/dist/collection/components/page-meta/page-meta.js.map +1 -0
- package/dist/collection/components/picker/constant.js +1 -0
- package/dist/collection/components/picker/constant.js.map +1 -0
- package/dist/collection/components/picker/picker-group.js +194 -179
- package/dist/collection/components/picker/picker-group.js.map +1 -0
- package/dist/collection/components/picker/picker.js +261 -257
- package/dist/collection/components/picker/picker.js.map +1 -0
- package/dist/collection/components/picker/utils.js +1 -0
- package/dist/collection/components/picker/utils.js.map +1 -0
- package/dist/collection/components/picker-view/picker-view-column.js +158 -147
- package/dist/collection/components/picker-view/picker-view-column.js.map +1 -0
- package/dist/collection/components/picker-view/picker-view.js +171 -159
- package/dist/collection/components/picker-view/picker-view.js.map +1 -0
- package/dist/collection/components/progress/progress.js +153 -157
- package/dist/collection/components/progress/progress.js.map +1 -0
- package/dist/collection/components/pull-to-refresh/pull-to-refresh.js +121 -114
- package/dist/collection/components/pull-to-refresh/pull-to-refresh.js.map +1 -0
- package/dist/collection/components/radio/radio-group.js +50 -43
- package/dist/collection/components/radio/radio-group.js.map +1 -0
- package/dist/collection/components/radio/radio.js +152 -144
- package/dist/collection/components/radio/radio.js.map +1 -0
- package/dist/collection/components/rich-text/rich-text.js +27 -23
- package/dist/collection/components/rich-text/rich-text.js.map +1 -0
- package/dist/collection/components/root-portal/root-portal.js +2 -1
- package/dist/collection/components/root-portal/root-portal.js.map +1 -0
- package/dist/collection/components/scroll-view/scroll-view.js +242 -220
- package/dist/collection/components/scroll-view/scroll-view.js.map +1 -0
- package/dist/collection/components/share-element/share-element.js +2 -1
- package/dist/collection/components/share-element/share-element.js.map +1 -0
- package/dist/collection/components/slider/slider.js +267 -263
- package/dist/collection/components/slider/slider.js.map +1 -0
- package/dist/collection/components/slot/slot.js +2 -5
- package/dist/collection/components/slot/slot.js.map +1 -0
- package/dist/collection/components/swiper/swiper-item.js +26 -21
- package/dist/collection/components/swiper/swiper-item.js.map +1 -0
- package/dist/collection/components/swiper/swiper.js +325 -352
- package/dist/collection/components/swiper/swiper.js.map +1 -0
- package/dist/collection/components/switch/switch.js +153 -139
- package/dist/collection/components/switch/switch.js.map +1 -0
- package/dist/collection/components/tabbar/tabbar-item.js +2 -6
- package/dist/collection/components/tabbar/tabbar-item.js.map +1 -0
- package/dist/collection/components/tabbar/tabbar.js +86 -70
- package/dist/collection/components/tabbar/tabbar.js.map +1 -0
- package/dist/collection/components/text/text.js +35 -30
- package/dist/collection/components/text/text.js.map +1 -0
- package/dist/collection/components/textarea/textarea.js +239 -226
- package/dist/collection/components/textarea/textarea.js.map +1 -0
- package/dist/collection/components/video/utils.js +1 -0
- package/dist/collection/components/video/utils.js.map +1 -0
- package/dist/collection/components/video/video-control.js +274 -286
- package/dist/collection/components/video/video-control.js.map +1 -0
- package/dist/collection/components/video/video-danmu.js +111 -118
- package/dist/collection/components/video/video-danmu.js.map +1 -0
- package/dist/collection/components/video/video.js +740 -810
- package/dist/collection/components/video/video.js.map +1 -0
- package/dist/collection/components/view/view.js +131 -118
- package/dist/collection/components/view/view.js.map +1 -0
- package/dist/collection/components/voip-room/voip-room.js +2 -1
- package/dist/collection/components/voip-room/voip-room.js.map +1 -0
- package/dist/collection/components/web-view/web-view.js +68 -57
- package/dist/collection/components/web-view/web-view.js.map +1 -0
- package/dist/collection/index.js +1 -0
- package/dist/collection/index.js.map +1 -0
- package/dist/collection/utils/helper.js +1 -0
- package/dist/collection/utils/helper.js.map +1 -0
- package/dist/collection/utils/index.js +1 -0
- package/dist/collection/utils/index.js.map +1 -0
- package/dist/collection/utils/style.js +1 -0
- package/dist/collection/utils/style.js.map +1 -0
- package/dist/collection/utils/url.js +1 -0
- package/dist/collection/utils/url.js.map +1 -0
- package/dist/esm/helper-3d0ecf0f.js +2 -0
- package/dist/esm/helper-3d0ecf0f.js.map +1 -0
- package/dist/esm/index-1d8e8acd.js +2 -0
- package/dist/esm/index-1d8e8acd.js.map +1 -0
- package/dist/esm/{index-8809c729.js → index-5d881caf.js} +477 -234
- package/dist/esm/index-5d881caf.js.map +1 -0
- package/dist/esm/index-cad8203e.js +2 -0
- package/dist/esm/index-cad8203e.js.map +1 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/intersection-observer-8e4c7135.js +2 -0
- package/dist/esm/intersection-observer-8e4c7135.js.map +1 -0
- package/dist/esm/loader.js +5 -3
- package/dist/esm/loader.js.map +1 -0
- package/dist/esm/polyfills/css-shim.js +1 -1
- package/dist/esm/taro-ad-core.entry.js +4 -2
- package/dist/esm/taro-ad-core.entry.js.map +1 -0
- package/dist/esm/taro-ad-custom-core.entry.js +4 -2
- package/dist/esm/taro-ad-custom-core.entry.js.map +1 -0
- package/dist/esm/taro-audio-core.entry.js +5 -2
- package/dist/esm/taro-audio-core.entry.js.map +1 -0
- package/dist/esm/taro-block-core.entry.js +4 -2
- package/dist/esm/taro-block-core.entry.js.map +1 -0
- package/dist/esm/taro-button-core.entry.js +7 -2
- package/dist/esm/taro-button-core.entry.js.map +1 -0
- package/dist/esm/taro-camera-core.entry.js +4 -2
- package/dist/esm/taro-camera-core.entry.js.map +1 -0
- package/dist/esm/taro-canvas-core.entry.js +6 -3
- package/dist/esm/taro-canvas-core.entry.js.map +1 -0
- package/dist/esm/taro-checkbox-core_2.entry.js +14 -8
- package/dist/esm/taro-checkbox-core_2.entry.js.map +1 -0
- package/dist/esm/taro-components.js +5 -3
- package/dist/esm/taro-components.js.map +1 -0
- package/dist/esm/taro-cover-image-core.entry.js +5 -2
- package/dist/esm/taro-cover-image-core.entry.js.map +1 -0
- package/dist/esm/taro-cover-view-core.entry.js +7 -3
- package/dist/esm/taro-cover-view-core.entry.js.map +1 -0
- package/dist/esm/taro-custom-wrapper-core.entry.js +4 -2
- package/dist/esm/taro-custom-wrapper-core.entry.js.map +1 -0
- package/dist/esm/taro-editor-core.entry.js +4 -2
- package/dist/esm/taro-editor-core.entry.js.map +1 -0
- package/dist/esm/taro-form-core.entry.js +5 -2
- package/dist/esm/taro-form-core.entry.js.map +1 -0
- package/dist/esm/taro-functional-page-navigator-core.entry.js +4 -2
- package/dist/esm/taro-functional-page-navigator-core.entry.js.map +1 -0
- package/dist/esm/taro-icon-core.entry.js +6 -2
- package/dist/esm/taro-icon-core.entry.js.map +1 -0
- package/dist/esm/taro-image-core.entry.js +5 -2
- package/dist/esm/taro-image-core.entry.js.map +1 -0
- package/dist/esm/taro-input-core.entry.js +18 -10
- package/dist/esm/taro-input-core.entry.js.map +1 -0
- package/dist/esm/taro-keyboard-accessory-core.entry.js +4 -2
- package/dist/esm/taro-keyboard-accessory-core.entry.js.map +1 -0
- package/dist/esm/taro-label-core.entry.js +5 -2
- package/dist/esm/taro-label-core.entry.js.map +1 -0
- package/dist/esm/taro-live-player-core.entry.js +4 -2
- package/dist/esm/taro-live-player-core.entry.js.map +1 -0
- package/dist/esm/taro-live-pusher-core.entry.js +4 -2
- package/dist/esm/taro-live-pusher-core.entry.js.map +1 -0
- package/dist/esm/taro-map-core.entry.js +4 -2
- package/dist/esm/taro-map-core.entry.js.map +1 -0
- package/dist/esm/taro-match-media-core.entry.js +4 -2
- package/dist/esm/taro-match-media-core.entry.js.map +1 -0
- package/dist/esm/{taro-movable-view-core.entry.js → taro-movable-area-core_2.entry.js} +187 -98
- package/dist/esm/taro-movable-area-core_2.entry.js.map +1 -0
- package/dist/esm/taro-navigation-bar-core.entry.js +4 -2
- package/dist/esm/taro-navigation-bar-core.entry.js.map +1 -0
- package/dist/esm/taro-navigator-core.entry.js +6 -2
- package/dist/esm/taro-navigator-core.entry.js.map +1 -0
- package/dist/esm/taro-official-account-core.entry.js +4 -2
- package/dist/esm/taro-official-account-core.entry.js.map +1 -0
- package/dist/esm/taro-open-data-core.entry.js +4 -2
- package/dist/esm/taro-open-data-core.entry.js.map +1 -0
- package/dist/esm/taro-page-container-core.entry.js +4 -2
- package/dist/esm/taro-page-container-core.entry.js.map +1 -0
- package/dist/esm/taro-page-meta-core.entry.js +4 -2
- package/dist/esm/taro-page-meta-core.entry.js.map +1 -0
- package/dist/esm/taro-picker-core_2.entry.js +31 -15
- package/dist/esm/taro-picker-core_2.entry.js.map +1 -0
- package/dist/esm/{taro-picker-view-core.entry.js → taro-picker-view-column-core_2.entry.js} +97 -3
- package/dist/esm/taro-picker-view-column-core_2.entry.js.map +1 -0
- package/dist/esm/taro-progress-core.entry.js +7 -5
- package/dist/esm/taro-progress-core.entry.js.map +1 -0
- package/dist/esm/taro-pull-to-refresh.entry.js +10 -8
- package/dist/esm/taro-pull-to-refresh.entry.js.map +1 -0
- package/dist/esm/taro-radio-core_2.entry.js +15 -9
- package/dist/esm/taro-radio-core_2.entry.js.map +1 -0
- package/dist/esm/taro-rich-text-core.entry.js +5 -2
- package/dist/esm/taro-rich-text-core.entry.js.map +1 -0
- package/dist/esm/taro-root-portal-core.entry.js +4 -2
- package/dist/esm/taro-root-portal-core.entry.js.map +1 -0
- package/dist/esm/taro-scroll-view-core.entry.js +28 -22
- package/dist/esm/taro-scroll-view-core.entry.js.map +1 -0
- package/dist/esm/taro-share-element-core.entry.js +4 -2
- package/dist/esm/taro-share-element-core.entry.js.map +1 -0
- package/dist/esm/taro-slider-core.entry.js +23 -19
- package/dist/esm/taro-slider-core.entry.js.map +1 -0
- package/dist/esm/taro-slot-core.entry.js +4 -7
- package/dist/esm/taro-slot-core.entry.js.map +1 -0
- package/dist/esm/taro-swiper-core_2.entry.js +25 -56
- package/dist/esm/taro-swiper-core_2.entry.js.map +1 -0
- package/dist/esm/taro-switch-core.entry.js +12 -8
- package/dist/esm/taro-switch-core.entry.js.map +1 -0
- package/dist/esm/taro-tabbar.entry.js +12 -4
- package/dist/esm/taro-tabbar.entry.js.map +1 -0
- package/dist/esm/taro-text-core.entry.js +4 -2
- package/dist/esm/taro-text-core.entry.js.map +1 -0
- package/dist/esm/taro-textarea-core.entry.js +13 -8
- package/dist/esm/taro-textarea-core.entry.js.map +1 -0
- package/dist/esm/taro-video-control_3.entry.js +142 -260
- package/dist/esm/taro-video-control_3.entry.js.map +1 -0
- package/dist/esm/taro-view-core.entry.js +7 -3
- package/dist/esm/taro-view-core.entry.js.map +1 -0
- package/dist/esm/taro-voip-room-core.entry.js +4 -2
- package/dist/esm/taro-voip-room-core.entry.js.map +1 -0
- package/dist/esm/taro-web-view-core.entry.js +5 -2
- package/dist/esm/taro-web-view-core.entry.js.map +1 -0
- package/dist/esm-es5/helper-3d0ecf0f.js +2 -1
- package/dist/esm-es5/helper-3d0ecf0f.js.map +1 -0
- package/dist/esm-es5/index-1d8e8acd.js +2 -1
- package/dist/esm-es5/index-1d8e8acd.js.map +1 -0
- package/dist/esm-es5/index-5d881caf.js +3 -0
- package/dist/esm-es5/index-5d881caf.js.map +1 -0
- package/dist/esm-es5/index-cad8203e.js +2 -1
- package/dist/esm-es5/index-cad8203e.js.map +1 -0
- package/dist/esm-es5/index.js +2 -0
- package/dist/esm-es5/index.js.map +1 -0
- package/dist/esm-es5/intersection-observer-8e4c7135.js +2 -1
- package/dist/esm-es5/intersection-observer-8e4c7135.js.map +1 -0
- package/dist/esm-es5/loader.js +2 -1
- package/dist/esm-es5/loader.js.map +1 -0
- package/dist/esm-es5/taro-ad-core.entry.js +2 -1
- package/dist/esm-es5/taro-ad-core.entry.js.map +1 -0
- package/dist/esm-es5/taro-ad-custom-core.entry.js +2 -1
- package/dist/esm-es5/taro-ad-custom-core.entry.js.map +1 -0
- package/dist/esm-es5/taro-audio-core.entry.js +2 -1
- package/dist/esm-es5/taro-audio-core.entry.js.map +1 -0
- package/dist/esm-es5/taro-block-core.entry.js +2 -1
- package/dist/esm-es5/taro-block-core.entry.js.map +1 -0
- package/dist/esm-es5/taro-button-core.entry.js +2 -1
- package/dist/esm-es5/taro-button-core.entry.js.map +1 -0
- package/dist/esm-es5/taro-camera-core.entry.js +2 -1
- package/dist/esm-es5/taro-camera-core.entry.js.map +1 -0
- package/dist/esm-es5/taro-canvas-core.entry.js +2 -1
- package/dist/esm-es5/taro-canvas-core.entry.js.map +1 -0
- package/dist/esm-es5/taro-checkbox-core_2.entry.js +2 -1
- package/dist/esm-es5/taro-checkbox-core_2.entry.js.map +1 -0
- package/dist/esm-es5/taro-components.js +2 -1
- package/dist/esm-es5/taro-components.js.map +1 -0
- package/dist/esm-es5/taro-cover-image-core.entry.js +2 -1
- package/dist/esm-es5/taro-cover-image-core.entry.js.map +1 -0
- package/dist/esm-es5/taro-cover-view-core.entry.js +2 -1
- package/dist/esm-es5/taro-cover-view-core.entry.js.map +1 -0
- package/dist/esm-es5/taro-custom-wrapper-core.entry.js +2 -1
- package/dist/esm-es5/taro-custom-wrapper-core.entry.js.map +1 -0
- package/dist/esm-es5/taro-editor-core.entry.js +2 -1
- package/dist/esm-es5/taro-editor-core.entry.js.map +1 -0
- package/dist/esm-es5/taro-form-core.entry.js +2 -1
- package/dist/esm-es5/taro-form-core.entry.js.map +1 -0
- package/dist/esm-es5/taro-functional-page-navigator-core.entry.js +2 -1
- package/dist/esm-es5/taro-functional-page-navigator-core.entry.js.map +1 -0
- package/dist/esm-es5/taro-icon-core.entry.js +2 -1
- package/dist/esm-es5/taro-icon-core.entry.js.map +1 -0
- package/dist/esm-es5/taro-image-core.entry.js +2 -1
- package/dist/esm-es5/taro-image-core.entry.js.map +1 -0
- package/dist/esm-es5/taro-input-core.entry.js +2 -1
- package/dist/esm-es5/taro-input-core.entry.js.map +1 -0
- package/dist/esm-es5/taro-keyboard-accessory-core.entry.js +2 -1
- package/dist/esm-es5/taro-keyboard-accessory-core.entry.js.map +1 -0
- package/dist/esm-es5/taro-label-core.entry.js +2 -1
- package/dist/esm-es5/taro-label-core.entry.js.map +1 -0
- package/dist/esm-es5/taro-live-player-core.entry.js +2 -1
- package/dist/esm-es5/taro-live-player-core.entry.js.map +1 -0
- package/dist/esm-es5/taro-live-pusher-core.entry.js +2 -1
- package/dist/esm-es5/taro-live-pusher-core.entry.js.map +1 -0
- package/dist/esm-es5/taro-map-core.entry.js +2 -1
- package/dist/esm-es5/taro-map-core.entry.js.map +1 -0
- package/dist/esm-es5/taro-match-media-core.entry.js +2 -1
- package/dist/esm-es5/taro-match-media-core.entry.js.map +1 -0
- package/dist/esm-es5/taro-movable-area-core_2.entry.js +2 -0
- package/dist/esm-es5/taro-movable-area-core_2.entry.js.map +1 -0
- package/dist/esm-es5/taro-navigation-bar-core.entry.js +2 -1
- package/dist/esm-es5/taro-navigation-bar-core.entry.js.map +1 -0
- package/dist/esm-es5/taro-navigator-core.entry.js +2 -1
- package/dist/esm-es5/taro-navigator-core.entry.js.map +1 -0
- package/dist/esm-es5/taro-official-account-core.entry.js +2 -1
- package/dist/esm-es5/taro-official-account-core.entry.js.map +1 -0
- package/dist/esm-es5/taro-open-data-core.entry.js +2 -1
- package/dist/esm-es5/taro-open-data-core.entry.js.map +1 -0
- package/dist/esm-es5/taro-page-container-core.entry.js +2 -1
- package/dist/esm-es5/taro-page-container-core.entry.js.map +1 -0
- package/dist/esm-es5/taro-page-meta-core.entry.js +2 -1
- package/dist/esm-es5/taro-page-meta-core.entry.js.map +1 -0
- package/dist/esm-es5/taro-picker-core_2.entry.js +2 -1
- package/dist/esm-es5/taro-picker-core_2.entry.js.map +1 -0
- package/dist/esm-es5/taro-picker-view-column-core_2.entry.js +2 -0
- package/dist/esm-es5/taro-picker-view-column-core_2.entry.js.map +1 -0
- package/dist/esm-es5/taro-progress-core.entry.js +2 -1
- package/dist/esm-es5/taro-progress-core.entry.js.map +1 -0
- package/dist/esm-es5/taro-pull-to-refresh.entry.js +2 -1
- package/dist/esm-es5/taro-pull-to-refresh.entry.js.map +1 -0
- package/dist/esm-es5/taro-radio-core_2.entry.js +2 -1
- package/dist/esm-es5/taro-radio-core_2.entry.js.map +1 -0
- package/dist/esm-es5/taro-rich-text-core.entry.js +2 -1
- package/dist/esm-es5/taro-rich-text-core.entry.js.map +1 -0
- package/dist/esm-es5/taro-root-portal-core.entry.js +2 -1
- package/dist/esm-es5/taro-root-portal-core.entry.js.map +1 -0
- package/dist/esm-es5/taro-scroll-view-core.entry.js +2 -1
- package/dist/esm-es5/taro-scroll-view-core.entry.js.map +1 -0
- package/dist/esm-es5/taro-share-element-core.entry.js +2 -1
- package/dist/esm-es5/taro-share-element-core.entry.js.map +1 -0
- package/dist/esm-es5/taro-slider-core.entry.js +2 -1
- package/dist/esm-es5/taro-slider-core.entry.js.map +1 -0
- package/dist/esm-es5/taro-slot-core.entry.js +2 -1
- package/dist/esm-es5/taro-slot-core.entry.js.map +1 -0
- package/dist/esm-es5/taro-swiper-core_2.entry.js +2 -1
- package/dist/esm-es5/taro-swiper-core_2.entry.js.map +1 -0
- package/dist/esm-es5/taro-switch-core.entry.js +2 -1
- package/dist/esm-es5/taro-switch-core.entry.js.map +1 -0
- package/dist/esm-es5/taro-tabbar.entry.js +2 -1
- package/dist/esm-es5/taro-tabbar.entry.js.map +1 -0
- package/dist/esm-es5/taro-text-core.entry.js +2 -1
- package/dist/esm-es5/taro-text-core.entry.js.map +1 -0
- package/dist/esm-es5/taro-textarea-core.entry.js +2 -1
- package/dist/esm-es5/taro-textarea-core.entry.js.map +1 -0
- package/dist/esm-es5/taro-video-control_3.entry.js +56 -55
- package/dist/esm-es5/taro-video-control_3.entry.js.map +1 -0
- package/dist/esm-es5/taro-view-core.entry.js +2 -1
- package/dist/esm-es5/taro-view-core.entry.js.map +1 -0
- package/dist/esm-es5/taro-voip-room-core.entry.js +2 -1
- package/dist/esm-es5/taro-voip-room-core.entry.js.map +1 -0
- package/dist/esm-es5/taro-web-view-core.entry.js +2 -1
- package/dist/esm-es5/taro-web-view-core.entry.js.map +1 -0
- package/{dist-h5/react/components → dist/react/component-lib}/index.js +1 -1
- package/{dist-h5/react/components → dist/react/component-lib}/input.js +5 -5
- package/{dist-h5/react/utils → dist/react/component-lib}/reactify-wc.js +10 -20
- package/dist/react/components.js +65 -0
- package/dist/react/helper.js +13 -0
- package/{dist-h5 → dist}/react/index.js +0 -0
- package/dist/react/react-component-lib/index.js +2 -0
- package/dist/react/react-component-lib/interfaces.js +1 -0
- package/dist/react/react-component-lib/utils/attachProps.js +107 -0
- package/dist/react/react-component-lib/utils/case.js +10 -0
- package/dist/react/react-component-lib/utils/dev.js +12 -0
- package/dist/taro-components/index.esm.js +2 -0
- package/dist/taro-components/index.esm.js.map +1 -0
- package/dist/taro-components/p-001ef419.system.entry.js +2 -0
- package/dist/taro-components/p-001ef419.system.entry.js.map +1 -0
- package/dist/taro-components/{p-a94524c9.system.entry.js → p-057159bc.system.entry.js} +2 -1
- package/dist/taro-components/p-057159bc.system.entry.js.map +1 -0
- package/dist/taro-components/p-07281375.entry.js +2 -0
- package/dist/taro-components/p-07281375.entry.js.map +1 -0
- package/dist/taro-components/p-0a896bc7.entry.js +2 -0
- package/dist/taro-components/p-0a896bc7.entry.js.map +1 -0
- package/dist/taro-components/p-0b38e6c7.system.entry.js +2 -0
- package/dist/taro-components/p-0b38e6c7.system.entry.js.map +1 -0
- package/dist/taro-components/p-0d36ef6b.entry.js +2 -0
- package/dist/taro-components/p-0d36ef6b.entry.js.map +1 -0
- package/dist/taro-components/{p-f81a74bb.system.entry.js → p-0dfbdfdb.system.entry.js} +82 -81
- package/dist/taro-components/p-0dfbdfdb.system.entry.js.map +1 -0
- package/dist/taro-components/p-0ee6a068.entry.js +2 -0
- package/dist/taro-components/p-0ee6a068.entry.js.map +1 -0
- package/dist/taro-components/p-12e4b019.entry.js +2 -0
- package/dist/taro-components/p-12e4b019.entry.js.map +1 -0
- package/dist/taro-components/p-15dced71.system.entry.js +2 -0
- package/dist/taro-components/p-15dced71.system.entry.js.map +1 -0
- package/dist/taro-components/p-15e45ed6.system.js +2 -1
- package/dist/taro-components/p-15e45ed6.system.js.map +1 -0
- package/dist/taro-components/p-17657dca.entry.js +2 -0
- package/dist/taro-components/p-17657dca.entry.js.map +1 -0
- package/dist/taro-components/p-1b2556e2.system.entry.js +2 -0
- package/dist/taro-components/p-1b2556e2.system.entry.js.map +1 -0
- package/dist/taro-components/p-1b64d2a2.entry.js +2 -0
- package/dist/taro-components/p-1b64d2a2.entry.js.map +1 -0
- package/dist/taro-components/p-1bd3d09b.system.entry.js +2 -0
- package/dist/taro-components/p-1bd3d09b.system.entry.js.map +1 -0
- package/dist/taro-components/p-1cb76199.entry.js +2 -0
- package/dist/taro-components/p-1cb76199.entry.js.map +1 -0
- package/dist/taro-components/p-1e436d5b.entry.js +2 -0
- package/dist/taro-components/p-1e436d5b.entry.js.map +1 -0
- package/dist/taro-components/p-2096bc5f.entry.js +2 -0
- package/dist/taro-components/p-2096bc5f.entry.js.map +1 -0
- package/dist/taro-components/p-20ec6387.entry.js +2 -0
- package/dist/taro-components/p-20ec6387.entry.js.map +1 -0
- package/dist/taro-components/{p-c5fd5c7f.system.entry.js → p-21b77a13.system.entry.js} +2 -1
- package/dist/taro-components/p-21b77a13.system.entry.js.map +1 -0
- package/dist/taro-components/p-2243a376.entry.js +2 -0
- package/dist/taro-components/p-2243a376.entry.js.map +1 -0
- package/dist/taro-components/p-22f9f9fa.entry.js +2 -0
- package/dist/taro-components/p-22f9f9fa.entry.js.map +1 -0
- package/dist/taro-components/p-2915c2dd.entry.js +2 -0
- package/dist/taro-components/p-2915c2dd.entry.js.map +1 -0
- package/dist/taro-components/p-29f04296.entry.js +2 -0
- package/dist/taro-components/p-29f04296.entry.js.map +1 -0
- package/dist/taro-components/{p-3e11c8cc.system.entry.js → p-301a8b85.system.entry.js} +2 -1
- package/dist/taro-components/p-301a8b85.system.entry.js.map +1 -0
- package/dist/taro-components/p-3b1d2d37.system.js +2 -1
- package/dist/taro-components/p-3b1d2d37.system.js.map +1 -0
- package/dist/taro-components/p-3b9a1125.entry.js +2 -0
- package/dist/taro-components/p-3b9a1125.entry.js.map +1 -0
- package/dist/taro-components/p-3c256e0e.entry.js +2 -0
- package/dist/taro-components/p-3c256e0e.entry.js.map +1 -0
- package/dist/taro-components/p-3e6b29c6.entry.js +2 -0
- package/dist/taro-components/p-3e6b29c6.entry.js.map +1 -0
- package/dist/taro-components/{p-a63fbc50.system.entry.js → p-439a3349.system.entry.js} +2 -1
- package/dist/taro-components/p-439a3349.system.entry.js.map +1 -0
- package/dist/taro-components/{p-d075934f.system.entry.js → p-45b6ea0c.system.entry.js} +2 -1
- package/dist/taro-components/p-45b6ea0c.system.entry.js.map +1 -0
- package/dist/taro-components/p-49a6cae4.system.entry.js +2 -0
- package/dist/taro-components/p-49a6cae4.system.entry.js.map +1 -0
- package/dist/taro-components/p-4b05e003.entry.js +2 -0
- package/dist/taro-components/p-4b05e003.entry.js.map +1 -0
- package/dist/taro-components/{p-692d986d.system.entry.js → p-4b27df71.system.entry.js} +2 -1
- package/dist/taro-components/p-4b27df71.system.entry.js.map +1 -0
- package/dist/taro-components/{p-f7c80795.system.entry.js → p-4fbb8b4c.system.entry.js} +2 -1
- package/dist/taro-components/p-4fbb8b4c.system.entry.js.map +1 -0
- package/dist/taro-components/p-50ea2036.system.js +2 -1
- package/dist/taro-components/p-50ea2036.system.js.map +1 -0
- package/dist/taro-components/p-51de23e4.entry.js +366 -0
- package/dist/taro-components/p-51de23e4.entry.js.map +1 -0
- package/dist/taro-components/p-55519002.entry.js +2 -0
- package/dist/taro-components/p-55519002.entry.js.map +1 -0
- package/dist/taro-components/p-559bb98a.system.entry.js +2 -0
- package/dist/taro-components/p-559bb98a.system.entry.js.map +1 -0
- package/dist/taro-components/p-570222e2.entry.js +2 -0
- package/dist/taro-components/p-570222e2.entry.js.map +1 -0
- package/dist/taro-components/p-5746d7ce.js +2 -1
- package/dist/taro-components/p-5746d7ce.js.map +1 -0
- package/dist/taro-components/{p-6ad59489.system.entry.js → p-580a72d1.system.entry.js} +2 -1
- package/dist/taro-components/p-580a72d1.system.entry.js.map +1 -0
- package/dist/taro-components/{p-93eed5d7.system.entry.js → p-59418be7.system.entry.js} +2 -1
- package/dist/taro-components/p-59418be7.system.entry.js.map +1 -0
- package/dist/taro-components/p-59e02aca.system.entry.js +2 -0
- package/dist/taro-components/p-59e02aca.system.entry.js.map +1 -0
- package/dist/taro-components/p-5bfefd19.js +3 -0
- package/dist/taro-components/p-5bfefd19.js.map +1 -0
- package/dist/taro-components/p-61f225ef.system.js +2 -1
- package/dist/taro-components/p-61f225ef.system.js.map +1 -0
- package/dist/taro-components/p-663d1bb9.system.js +2 -1
- package/dist/taro-components/p-663d1bb9.system.js.map +1 -0
- package/dist/taro-components/p-6a96da58.js +2 -1
- package/dist/taro-components/p-6a96da58.js.map +1 -0
- package/dist/taro-components/p-6af8be19.entry.js +2 -0
- package/dist/taro-components/p-6af8be19.entry.js.map +1 -0
- package/dist/taro-components/p-6ea2995b.entry.js +2 -0
- package/dist/taro-components/p-6ea2995b.entry.js.map +1 -0
- package/dist/taro-components/p-6f8af69f.entry.js +2 -0
- package/dist/taro-components/p-6f8af69f.entry.js.map +1 -0
- package/dist/taro-components/{p-f4ea8a56.system.entry.js → p-701b0286.system.entry.js} +2 -1
- package/dist/taro-components/p-701b0286.system.entry.js.map +1 -0
- package/dist/taro-components/p-72f327e1.js +2 -1
- package/dist/taro-components/p-72f327e1.js.map +1 -0
- package/dist/taro-components/p-72f626ab.system.entry.js +2 -0
- package/dist/taro-components/p-72f626ab.system.entry.js.map +1 -0
- package/dist/taro-components/p-76724e58.js +3 -2
- package/dist/taro-components/p-76724e58.js.map +1 -0
- package/dist/taro-components/{p-13f0b11f.system.entry.js → p-79e9322e.system.entry.js} +2 -1
- package/dist/taro-components/p-79e9322e.system.entry.js.map +1 -0
- package/dist/taro-components/p-7baff0b4.entry.js +2 -0
- package/dist/taro-components/p-7baff0b4.entry.js.map +1 -0
- package/dist/taro-components/p-8231e748.entry.js +2 -0
- package/dist/taro-components/p-8231e748.entry.js.map +1 -0
- package/dist/taro-components/p-825f8dec.system.entry.js +2 -0
- package/dist/taro-components/p-825f8dec.system.entry.js.map +1 -0
- package/dist/taro-components/{p-07294134.system.entry.js → p-8a3620a6.system.entry.js} +2 -1
- package/dist/taro-components/p-8a3620a6.system.entry.js.map +1 -0
- package/dist/taro-components/p-8a8f286f.system.js +3 -0
- package/dist/taro-components/p-8a8f286f.system.js.map +1 -0
- package/dist/taro-components/{p-7e960ac3.system.entry.js → p-8bec95d4.system.entry.js} +2 -1
- package/dist/taro-components/p-8bec95d4.system.entry.js.map +1 -0
- package/dist/taro-components/{p-e671c8c5.system.entry.js → p-8c8fe164.system.entry.js} +2 -1
- package/dist/taro-components/p-8c8fe164.system.entry.js.map +1 -0
- package/dist/taro-components/p-8e3c923b.entry.js +2 -0
- package/dist/taro-components/p-8e3c923b.entry.js.map +1 -0
- package/dist/taro-components/p-93cc7adc.entry.js +2 -0
- package/dist/taro-components/p-93cc7adc.entry.js.map +1 -0
- package/dist/taro-components/p-946c0799.system.entry.js +2 -0
- package/dist/taro-components/p-946c0799.system.entry.js.map +1 -0
- package/dist/taro-components/p-96a784f1.entry.js +2 -0
- package/dist/taro-components/p-96a784f1.entry.js.map +1 -0
- package/dist/taro-components/p-99bbe34a.system.entry.js +2 -0
- package/dist/taro-components/p-99bbe34a.system.entry.js.map +1 -0
- package/dist/taro-components/{p-075458e5.system.entry.js → p-9f1ca602.system.entry.js} +2 -1
- package/dist/taro-components/p-9f1ca602.system.entry.js.map +1 -0
- package/dist/taro-components/p-a1ace8c7.system.entry.js +2 -0
- package/dist/taro-components/p-a1ace8c7.system.entry.js.map +1 -0
- package/dist/taro-components/p-a29509fa.system.entry.js +2 -0
- package/dist/taro-components/p-a29509fa.system.entry.js.map +1 -0
- package/dist/taro-components/p-a29e3051.entry.js +2 -0
- package/dist/taro-components/p-a29e3051.entry.js.map +1 -0
- package/dist/taro-components/{p-d4da725f.system.entry.js → p-a6f2dc54.system.entry.js} +2 -1
- package/dist/taro-components/p-a6f2dc54.system.entry.js.map +1 -0
- package/dist/taro-components/p-ab105c26.entry.js +2 -0
- package/dist/taro-components/p-ab105c26.entry.js.map +1 -0
- package/dist/taro-components/{p-c93bb915.system.entry.js → p-b04a56bd.system.entry.js} +2 -1
- package/dist/taro-components/p-b04a56bd.system.entry.js.map +1 -0
- package/dist/taro-components/p-b10cb428.entry.js +2 -0
- package/dist/taro-components/p-b10cb428.entry.js.map +1 -0
- package/dist/taro-components/{p-d6662ab3.system.entry.js → p-b500c116.system.entry.js} +2 -1
- package/dist/taro-components/p-b500c116.system.entry.js.map +1 -0
- package/dist/taro-components/p-b832f4e8.entry.js +2 -0
- package/dist/taro-components/p-b832f4e8.entry.js.map +1 -0
- package/dist/taro-components/p-b90926cc.entry.js +2 -0
- package/dist/taro-components/p-b90926cc.entry.js.map +1 -0
- package/dist/taro-components/p-ba743573.entry.js +2 -0
- package/dist/taro-components/p-ba743573.entry.js.map +1 -0
- package/dist/taro-components/p-be3f5ac0.entry.js +2 -0
- package/dist/taro-components/p-be3f5ac0.entry.js.map +1 -0
- package/dist/taro-components/p-beea63a7.entry.js +2 -0
- package/dist/taro-components/p-beea63a7.entry.js.map +1 -0
- package/dist/taro-components/{p-b7681c76.system.entry.js → p-c0e3c822.system.entry.js} +2 -1
- package/dist/taro-components/p-c0e3c822.system.entry.js.map +1 -0
- package/dist/taro-components/p-c3acf0ea.system.entry.js +2 -0
- package/dist/taro-components/p-c3acf0ea.system.entry.js.map +1 -0
- package/dist/taro-components/p-c3bb8fa6.entry.js +2 -0
- package/dist/taro-components/p-c3bb8fa6.entry.js.map +1 -0
- package/dist/taro-components/{p-733cc64a.system.entry.js → p-c4cf58af.system.entry.js} +2 -1
- package/dist/taro-components/p-c4cf58af.system.entry.js.map +1 -0
- package/dist/taro-components/{p-b11aaf69.system.entry.js → p-c5c331bf.system.entry.js} +2 -1
- package/dist/taro-components/p-c5c331bf.system.entry.js.map +1 -0
- package/dist/taro-components/p-ca64c7d4.system.entry.js +2 -0
- package/dist/taro-components/p-ca64c7d4.system.entry.js.map +1 -0
- package/dist/taro-components/p-cb17d8bd.system.js +2 -0
- package/dist/taro-components/p-cb17d8bd.system.js.map +1 -0
- package/dist/taro-components/{p-fc9f4fd7.system.entry.js → p-cbe2436d.system.entry.js} +2 -1
- package/dist/taro-components/p-cbe2436d.system.entry.js.map +1 -0
- package/dist/taro-components/p-cc506879.entry.js +2 -0
- package/dist/taro-components/p-cc506879.entry.js.map +1 -0
- package/dist/taro-components/p-cd6a7eea.entry.js +2 -0
- package/dist/taro-components/p-cd6a7eea.entry.js.map +1 -0
- package/dist/taro-components/p-d4b6f19e.system.entry.js +2 -0
- package/dist/taro-components/p-d4b6f19e.system.entry.js.map +1 -0
- package/dist/taro-components/p-d5579efa.system.entry.js +2 -0
- package/dist/taro-components/p-d5579efa.system.entry.js.map +1 -0
- package/dist/taro-components/p-d619f198.system.entry.js +2 -0
- package/dist/taro-components/p-d619f198.system.entry.js.map +1 -0
- package/dist/taro-components/p-d7ab3e23.system.entry.js +2 -0
- package/dist/taro-components/p-d7ab3e23.system.entry.js.map +1 -0
- package/dist/taro-components/p-d7f4b10f.entry.js +2 -0
- package/dist/taro-components/p-d7f4b10f.entry.js.map +1 -0
- package/dist/taro-components/p-d85b216d.entry.js +2 -0
- package/dist/taro-components/p-d85b216d.entry.js.map +1 -0
- package/dist/taro-components/p-dc75145c.system.entry.js +2 -0
- package/dist/taro-components/p-dc75145c.system.entry.js.map +1 -0
- package/dist/taro-components/p-de762042.entry.js +2 -0
- package/dist/taro-components/p-de762042.entry.js.map +1 -0
- package/dist/taro-components/p-df862d0c.entry.js +2 -0
- package/dist/taro-components/p-df862d0c.entry.js.map +1 -0
- package/dist/taro-components/p-e0d6b00b.entry.js +2 -0
- package/dist/taro-components/p-e0d6b00b.entry.js.map +1 -0
- package/dist/taro-components/p-e25653b4.system.entry.js +2 -0
- package/dist/taro-components/p-e25653b4.system.entry.js.map +1 -0
- package/dist/taro-components/p-e528e0ff.system.entry.js +2 -0
- package/dist/taro-components/p-e528e0ff.system.entry.js.map +1 -0
- package/dist/taro-components/p-e59f999e.entry.js +2 -0
- package/dist/taro-components/p-e59f999e.entry.js.map +1 -0
- package/dist/taro-components/p-e7239faa.system.entry.js +2 -0
- package/dist/taro-components/p-e7239faa.system.entry.js.map +1 -0
- package/dist/taro-components/p-e98c07c3.system.entry.js +2 -0
- package/dist/taro-components/p-e98c07c3.system.entry.js.map +1 -0
- package/dist/taro-components/p-e9abe3e2.entry.js +2 -0
- package/dist/taro-components/p-e9abe3e2.entry.js.map +1 -0
- package/dist/taro-components/{p-8e2b048e.system.entry.js → p-f0d0160d.system.entry.js} +2 -1
- package/dist/taro-components/p-f0d0160d.system.entry.js.map +1 -0
- package/dist/taro-components/p-f273ee4e.entry.js +2 -0
- package/dist/taro-components/p-f273ee4e.entry.js.map +1 -0
- package/dist/taro-components/{p-f2803c2e.system.entry.js → p-f2c75971.system.entry.js} +2 -1
- package/dist/taro-components/p-f2c75971.system.entry.js.map +1 -0
- package/dist/taro-components/p-fc1fe388.entry.js +2 -0
- package/dist/taro-components/p-fc1fe388.entry.js.map +1 -0
- package/dist/taro-components/taro-components.esm.js +2 -1
- package/dist/taro-components/taro-components.esm.js.map +1 -0
- package/dist/taro-components/taro-components.js +2 -1
- package/dist/types/components/input/input.d.ts +1 -1
- package/dist/types/components/movable-area/movable-view.d.ts +3 -3
- package/dist/types/components/progress/progress.d.ts +1 -1
- package/dist/types/components/radio/radio.d.ts +2 -2
- package/dist/types/components/scroll-view/scroll-view.d.ts +1 -1
- package/dist/types/components/slot/slot.d.ts +0 -1
- package/dist/types/components/video/utils.d.ts +1 -1
- package/dist/types/components.d.ts +176 -68
- package/dist/types/stencil-public-runtime.d.ts +20 -4
- package/{dist-h5/vue/components/index.js → dist/vue2/component-lib/components.js} +0 -0
- package/{dist-h5/vue → dist/vue2/component-lib}/createComponent.js +0 -0
- package/{dist-h5/vue → dist/vue2/component-lib}/createFormsComponent.js +0 -0
- package/{dist-h5/vue/components → dist/vue2/component-lib}/icon.js +2 -2
- package/{dist-h5/vue/components → dist/vue2/component-lib}/image.js +2 -2
- package/{dist-h5/vue → dist/vue2/component-lib}/index.js +4 -3
- package/{dist-h5/vue → dist/vue2/component-lib}/mixins/listeners.js +0 -0
- package/{dist-h5/vue → dist/vue2/component-lib}/mixins/refs.js +0 -0
- package/{dist-h5/vue/components → dist/vue2/component-lib}/picker.js +2 -2
- package/{dist-h5/vue/components → dist/vue2/component-lib}/scroll-view.js +2 -2
- package/{dist-h5/vue/components → dist/vue2/component-lib}/text.js +2 -2
- package/dist/vue2/components.js +479 -0
- package/dist/vue2/index.js +26 -0
- package/dist/vue2/vue-component-lib/utils.js +45 -0
- package/{dist-h5/vue3 → dist/vue3/component-lib}/createComponent.js +1 -1
- package/{dist-h5/vue3 → dist/vue3/component-lib}/createFormsComponent.js +0 -0
- package/{dist-h5/vue3 → dist/vue3/component-lib}/forwardRef.js +0 -0
- package/{dist-h5/vue3/components → dist/vue3/component-lib}/icon.js +2 -2
- package/{dist-h5/vue3/components → dist/vue3/component-lib}/image.js +2 -2
- package/{dist-h5/vue3/components → dist/vue3/component-lib}/index.js +2 -2
- package/{dist-h5/vue3/components → dist/vue3/component-lib}/scroll-view.js +2 -2
- package/{dist-h5/vue3/components → dist/vue3/component-lib}/text.js +2 -2
- package/dist/vue3/components.js +64 -0
- package/{dist-h5 → dist}/vue3/index.js +0 -0
- package/dist/vue3/vue-component-lib/utils.js +201 -0
- package/loader/package.json +1 -0
- package/package.json +23 -22
- package/types/Input.d.ts +3 -1
- package/dist/cjs/taro-movable-area-core.cjs.entry.js +0 -157
- package/dist/cjs/taro-picker-view-column-core.cjs.entry.js +0 -95
- package/dist/esm/taro-movable-area-core.entry.js +0 -153
- package/dist/esm/taro-picker-view-column-core.entry.js +0 -91
- package/dist/esm-es5/index-8809c729.js +0 -1
- package/dist/esm-es5/taro-movable-area-core.entry.js +0 -1
- package/dist/esm-es5/taro-movable-view-core.entry.js +0 -1
- package/dist/esm-es5/taro-picker-view-column-core.entry.js +0 -1
- package/dist/esm-es5/taro-picker-view-core.entry.js +0 -1
- package/dist/taro-components/p-028e2728.entry.js +0 -1
- package/dist/taro-components/p-0380841f.system.js +0 -1
- package/dist/taro-components/p-059912fd.js +0 -1
- package/dist/taro-components/p-06178a0c.entry.js +0 -1
- package/dist/taro-components/p-06e6864b.system.entry.js +0 -1
- package/dist/taro-components/p-10c47df8.system.entry.js +0 -1
- package/dist/taro-components/p-232ebfae.system.entry.js +0 -1
- package/dist/taro-components/p-25df0ce9.entry.js +0 -1
- package/dist/taro-components/p-27126803.system.entry.js +0 -1
- package/dist/taro-components/p-275d883f.system.entry.js +0 -1
- package/dist/taro-components/p-27c80869.system.entry.js +0 -1
- package/dist/taro-components/p-2ec47545.entry.js +0 -1
- package/dist/taro-components/p-3255f11f.system.entry.js +0 -1
- package/dist/taro-components/p-362998cf.entry.js +0 -1
- package/dist/taro-components/p-3744e978.entry.js +0 -365
- package/dist/taro-components/p-3c6090fd.entry.js +0 -1
- package/dist/taro-components/p-42630f45.entry.js +0 -1
- package/dist/taro-components/p-44398c17.system.entry.js +0 -1
- package/dist/taro-components/p-44cbb351.system.js +0 -1
- package/dist/taro-components/p-4ada10aa.entry.js +0 -1
- package/dist/taro-components/p-4cf436f9.entry.js +0 -1
- package/dist/taro-components/p-4d826fb7.entry.js +0 -1
- package/dist/taro-components/p-55266a1f.entry.js +0 -1
- package/dist/taro-components/p-56c86512.entry.js +0 -1
- package/dist/taro-components/p-5733124c.entry.js +0 -1
- package/dist/taro-components/p-57a2a441.entry.js +0 -1
- package/dist/taro-components/p-59d93770.entry.js +0 -1
- package/dist/taro-components/p-5a2305e7.entry.js +0 -1
- package/dist/taro-components/p-5a374cb9.entry.js +0 -1
- package/dist/taro-components/p-5c87902f.system.entry.js +0 -1
- package/dist/taro-components/p-5e223bab.system.entry.js +0 -1
- package/dist/taro-components/p-5f18259d.system.entry.js +0 -1
- package/dist/taro-components/p-62fc514e.entry.js +0 -1
- package/dist/taro-components/p-63a0c6b0.entry.js +0 -1
- package/dist/taro-components/p-64447f5a.system.entry.js +0 -1
- package/dist/taro-components/p-67222d90.system.entry.js +0 -1
- package/dist/taro-components/p-6800ac6f.entry.js +0 -1
- package/dist/taro-components/p-6aa557f0.entry.js +0 -1
- package/dist/taro-components/p-72f858e4.entry.js +0 -1
- package/dist/taro-components/p-7374537f.entry.js +0 -1
- package/dist/taro-components/p-7407013d.entry.js +0 -1
- package/dist/taro-components/p-7d329ab0.entry.js +0 -1
- package/dist/taro-components/p-7f93fa08.entry.js +0 -1
- package/dist/taro-components/p-82661d45.system.entry.js +0 -1
- package/dist/taro-components/p-8475421b.system.entry.js +0 -1
- package/dist/taro-components/p-8788dc46.system.entry.js +0 -1
- package/dist/taro-components/p-886571e5.entry.js +0 -1
- package/dist/taro-components/p-888fac99.entry.js +0 -1
- package/dist/taro-components/p-8aea3de3.entry.js +0 -1
- package/dist/taro-components/p-8c8be53b.entry.js +0 -1
- package/dist/taro-components/p-8cf86f31.system.entry.js +0 -1
- package/dist/taro-components/p-9234cc1d.entry.js +0 -1
- package/dist/taro-components/p-92699438.entry.js +0 -1
- package/dist/taro-components/p-9a0e70b1.entry.js +0 -1
- package/dist/taro-components/p-9afbb423.system.entry.js +0 -1
- package/dist/taro-components/p-9b39a940.entry.js +0 -1
- package/dist/taro-components/p-9e1572c5.system.entry.js +0 -1
- package/dist/taro-components/p-ab1256fe.entry.js +0 -1
- package/dist/taro-components/p-ad6ad7e3.system.entry.js +0 -1
- package/dist/taro-components/p-afbcd093.entry.js +0 -1
- package/dist/taro-components/p-b1ae9401.entry.js +0 -1
- package/dist/taro-components/p-b2800ccd.entry.js +0 -1
- package/dist/taro-components/p-b3b677fc.entry.js +0 -1
- package/dist/taro-components/p-b3d961f9.system.entry.js +0 -1
- package/dist/taro-components/p-b60820b4.entry.js +0 -1
- package/dist/taro-components/p-b7639674.entry.js +0 -1
- package/dist/taro-components/p-b7ac0b7f.system.entry.js +0 -1
- package/dist/taro-components/p-b9903f15.system.entry.js +0 -1
- package/dist/taro-components/p-bd706d39.entry.js +0 -1
- package/dist/taro-components/p-c92bafb6.system.entry.js +0 -1
- package/dist/taro-components/p-cf048af9.entry.js +0 -1
- package/dist/taro-components/p-d5f3080c.entry.js +0 -1
- package/dist/taro-components/p-df3b544a.system.entry.js +0 -1
- package/dist/taro-components/p-dff55efd.entry.js +0 -1
- package/dist/taro-components/p-eec00033.entry.js +0 -1
- package/dist/taro-components/p-eeed74e3.system.entry.js +0 -1
- package/dist/taro-components/p-ef006b23.entry.js +0 -1
- package/dist/taro-components/p-f5f1c3b7.system.entry.js +0 -1
- package/dist/taro-components/p-fa2a9bab.entry.js +0 -1
- package/dist/taro-components/p-fec6ac36.entry.js +0 -1
- package/dist/taro-components/p-ff84986d.entry.js +0 -1
- package/dist/taro-components/p-ffefd74f.entry.js +0 -1
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
import{r as t,h as i,H as r,g as e,c as n}from"./p-5bfefd19.js";import{a as s,b as a,g as u,c as o}from"./p-76724e58.js";import{t as f}from"./p-5746d7ce.js";const h=t=>{if(!t)return"";const i=Math.round(t%60);const r=Math.round((t-i)/60);return`${r<10?`0${r}`:r}:${i<10?`0${i}`:i}`};const l=(t,i)=>Math.sqrt(Math.pow(t,2)+Math.pow(i,2));const c=t=>Math.max(-1,Math.min(t,1));let v="default";const d=function(){let t;const i=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror"],["webkitRequestFullScreen","webkitCancelFullScreen","webkitCurrentFullScreenElement","webkitCancelFullScreen","webkitfullscreenchange","webkitfullscreenerror"],["mozRequestFullScreen","mozCancelFullScreen","mozFullScreenElement","mozFullScreenEnabled","mozfullscreenchange","mozfullscreenerror"],["msRequestFullscreen","msExitFullscreen","msFullscreenElement","msFullscreenEnabled","MSFullscreenChange","MSFullscreenError"]];var r=["webkitEnterFullscreen","webkitExitFullscreen","webkitCurrentFullScreenElement","webkitSupportsFullscreen","fullscreenchange","fullscreenerror"];let e=0;const n=i.length;const s={};for(;e<n;e++){t=i[e];if(t&&t[1]in document){for(e=0;e<t.length;e++){s[i[0][e]]=t[e]}return s}}if(!s[i[0][0]]){v="iOS";for(e=0;e<r.length;e++){s[i[0][e]]=r[e]}}return s}();const m=t=>/\.(m3u8)($|\?)/i.test(t);const p=class{constructor(i){t(this,i);this.visible=false;this.isDraggingProgressBall=false;this.percentage=0;this.progressDimensions={left:0,width:0};this.calcPercentage=t=>{let i=t-this.progressDimensions.left;i=Math.max(i,0);i=Math.min(i,this.progressDimensions.width);return i/this.progressDimensions.width};this.onDragProgressBallStart=()=>{this.isDraggingProgressBall=true;this.hideControlsTimer&&clearTimeout(this.hideControlsTimer)};this.onClickProgress=t=>{t.stopPropagation();const i=this.calcPercentage(t.pageX);this.seekFunc(i*this.duration);this.toggleVisibility(true)};this.controls=undefined;this.currentTime=undefined;this.duration=undefined;this.isPlaying=undefined;this.pauseFunc=undefined;this.playFunc=undefined;this.seekFunc=undefined;this.showPlayBtn=undefined;this.showProgress=undefined}onDocumentTouchMove(t){if(!this.isDraggingProgressBall)return;const i=t.touches[0].pageX;this.percentage=this.calcPercentage(i);this.setProgressBall(this.percentage);this.setCurrentTime(this.percentage*this.duration)}onDocumentTouchEnd(){if(!this.isDraggingProgressBall)return;this.isDraggingProgressBall=false;this.seekFunc(this.percentage*this.duration);this.toggleVisibility(true)}async setProgressBall(t){if(this.progressBallRef){this.progressBallRef.style.left=`${t*100}%`}}async toggleVisibility(t){const i=t===undefined?!this.visible:t;if(i){this.hideControlsTimer&&clearTimeout(this.hideControlsTimer);if(this.isPlaying){this.hideControlsTimer=setTimeout((()=>{this.toggleVisibility(false)}),2e3)}this.el.style.visibility="visible"}else{this.el.style.visibility="hidden"}this.visible=!!i}async getIsDraggingProgressBall(){return this.isDraggingProgressBall}async setCurrentTime(t){this.currentTimeRef.innerHTML=h(t)}render(){const{controls:t,currentTime:e,duration:n,isPlaying:s,pauseFunc:a,playFunc:u,showPlayBtn:o,showProgress:f}=this;const l=h(n);let c;if(!o){c=null}else if(s){c=i("div",{class:"taro-video-control-button taro-video-control-button-pause",onClick:a})}else{c=i("div",{class:"taro-video-control-button taro-video-control-button-play",onClick:u})}return i(r,{class:"taro-video-bar taro-video-bar-full"},t&&i("div",{class:"taro-video-controls"},c,f&&i("div",{class:"taro-video-current-time",ref:t=>this.currentTimeRef=t},h(e)),f&&i("div",{class:"taro-video-progress-container",onClick:this.onClickProgress},i("div",{class:"taro-video-progress",ref:t=>{if(!t)return;const i=t.getBoundingClientRect();this.progressDimensions.left=i.left;this.progressDimensions.width=i.width}},i("div",{class:"taro-video-progress-buffered",style:{width:"100%"}}),i("div",{class:"taro-video-ball",ref:t=>this.progressBallRef=t,onTouchStart:this.onDragProgressBallStart,style:{left:`${l?this.currentTime/n*100:0}%`}},i("div",{class:"taro-video-inner"})))),f&&i("div",{class:"taro-video-duration"},l)),i("slot",null))}get el(){return e(this)}};var g=s((function(t,i){typeof window!=="undefined"&&function i(r,e){t.exports=e()}(a,(function(){return function(t){var i={};function r(e){if(i[e]){return i[e].exports}var n=i[e]={i:e,l:false,exports:{}};t[e].call(n.exports,n,n.exports,r);n.l=true;return n.exports}r.m=t;r.c=i;r.d=function(t,i,e){if(!r.o(t,i)){Object.defineProperty(t,i,{enumerable:true,get:e})}};r.r=function(t){if(typeof Symbol!=="undefined"&&Symbol.toStringTag){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}Object.defineProperty(t,"__esModule",{value:true})};r.t=function(t,i){if(i&1)t=r(t);if(i&8)return t;if(i&4&&typeof t==="object"&&t&&t.__esModule)return t;var e=Object.create(null);r.r(e);Object.defineProperty(e,"default",{enumerable:true,value:t});if(i&2&&typeof t!="string")for(var n in t)r.d(e,n,function(i){return t[i]}.bind(null,n));return e};r.n=function(t){var i=t&&t.__esModule?function i(){return t["default"]}:function i(){return t};r.d(i,"a",i);return i};r.o=function(t,i){return Object.prototype.hasOwnProperty.call(t,i)};r.p="/dist/";return r(r.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":
|
|
2
|
+
/*!*********************************************!*\
|
|
3
|
+
!*** ./node_modules/eventemitter3/index.js ***!
|
|
4
|
+
\*********************************************/
|
|
5
|
+
/*! no static exports found */function(t,i,r){var e=Object.prototype.hasOwnProperty,n="~";function s(){}if(Object.create){s.prototype=Object.create(null);if(!(new s).__proto__)n=false}function a(t,i,r){this.fn=t;this.context=i;this.once=r||false}function u(t,i,r,e,s){if(typeof r!=="function"){throw new TypeError("The listener must be a function")}var u=new a(r,e||t,s),o=n?n+i:i;if(!t._events[o])t._events[o]=u,t._eventsCount++;else if(!t._events[o].fn)t._events[o].push(u);else t._events[o]=[t._events[o],u];return t}function o(t,i){if(--t._eventsCount===0)t._events=new s;else delete t._events[i]}function f(){this._events=new s;this._eventsCount=0}f.prototype.eventNames=function t(){var i=[],r,s;if(this._eventsCount===0)return i;for(s in r=this._events){if(e.call(r,s))i.push(n?s.slice(1):s)}if(Object.getOwnPropertySymbols){return i.concat(Object.getOwnPropertySymbols(r))}return i};f.prototype.listeners=function t(i){var r=n?n+i:i,e=this._events[r];if(!e)return[];if(e.fn)return[e.fn];for(var s=0,a=e.length,u=new Array(a);s<a;s++){u[s]=e[s].fn}return u};f.prototype.listenerCount=function t(i){var r=n?n+i:i,e=this._events[r];if(!e)return 0;if(e.fn)return 1;return e.length};f.prototype.emit=function t(i,r,e,s,a,u){var o=n?n+i:i;if(!this._events[o])return false;var f=this._events[o],h=arguments.length,l,c;if(f.fn){if(f.once)this.removeListener(i,f.fn,undefined,true);switch(h){case 1:return f.fn.call(f.context),true;case 2:return f.fn.call(f.context,r),true;case 3:return f.fn.call(f.context,r,e),true;case 4:return f.fn.call(f.context,r,e,s),true;case 5:return f.fn.call(f.context,r,e,s,a),true;case 6:return f.fn.call(f.context,r,e,s,a,u),true}for(c=1,l=new Array(h-1);c<h;c++){l[c-1]=arguments[c]}f.fn.apply(f.context,l)}else{var v=f.length,d;for(c=0;c<v;c++){if(f[c].once)this.removeListener(i,f[c].fn,undefined,true);switch(h){case 1:f[c].fn.call(f[c].context);break;case 2:f[c].fn.call(f[c].context,r);break;case 3:f[c].fn.call(f[c].context,r,e);break;case 4:f[c].fn.call(f[c].context,r,e,s);break;default:if(!l)for(d=1,l=new Array(h-1);d<h;d++){l[d-1]=arguments[d]}f[c].fn.apply(f[c].context,l)}}}return true};f.prototype.on=function t(i,r,e){return u(this,i,r,e,false)};f.prototype.once=function t(i,r,e){return u(this,i,r,e,true)};f.prototype.removeListener=function t(i,r,e,s){var a=n?n+i:i;if(!this._events[a])return this;if(!r){o(this,a);return this}var u=this._events[a];if(u.fn){if(u.fn===r&&(!s||u.once)&&(!e||u.context===e)){o(this,a)}}else{for(var f=0,h=[],l=u.length;f<l;f++){if(u[f].fn!==r||s&&!u[f].once||e&&u[f].context!==e){h.push(u[f])}}if(h.length)this._events[a]=h.length===1?h[0]:h;else o(this,a)}return this};f.prototype.removeAllListeners=function t(i){var r;if(i){r=n?n+i:i;if(this._events[r])o(this,r)}else{this._events=new s;this._eventsCount=0}return this};f.prototype.off=f.prototype.removeListener;f.prototype.addListener=f.prototype.on;f.prefixed=n;f.EventEmitter=f;{t.exports=f}},"./node_modules/url-toolkit/src/url-toolkit.js":
|
|
6
|
+
/*!*****************************************************!*\
|
|
7
|
+
!*** ./node_modules/url-toolkit/src/url-toolkit.js ***!
|
|
8
|
+
\*****************************************************/
|
|
9
|
+
/*! no static exports found */function(t,i,r){(function(i){var r=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#[^]*)?$/;var e=/^([^\/?#]*)([^]*)$/;var n=/(?:\/|^)\.(?=\/)/g;var s=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g;var a={buildAbsoluteURL:function(t,i,r){r=r||{};t=t.trim();i=i.trim();if(!i){if(!r.alwaysNormalize){return t}var n=a.parseURL(t);if(!n){throw new Error("Error trying to parse base URL.")}n.path=a.normalizePath(n.path);return a.buildURLFromParts(n)}var s=a.parseURL(i);if(!s){throw new Error("Error trying to parse relative URL.")}if(s.scheme){if(!r.alwaysNormalize){return i}s.path=a.normalizePath(s.path);return a.buildURLFromParts(s)}var u=a.parseURL(t);if(!u){throw new Error("Error trying to parse base URL.")}if(!u.netLoc&&u.path&&u.path[0]!=="/"){var o=e.exec(u.path);u.netLoc=o[1];u.path=o[2]}if(u.netLoc&&!u.path){u.path="/"}var f={scheme:u.scheme,netLoc:s.netLoc,path:null,params:s.params,query:s.query,fragment:s.fragment};if(!s.netLoc){f.netLoc=u.netLoc;if(s.path[0]!=="/"){if(!s.path){f.path=u.path;if(!s.params){f.params=u.params;if(!s.query){f.query=u.query}}}else{var h=u.path;var l=h.substring(0,h.lastIndexOf("/")+1)+s.path;f.path=a.normalizePath(l)}}}if(f.path===null){f.path=r.alwaysNormalize?a.normalizePath(s.path):s.path}return a.buildURLFromParts(f)},parseURL:function(t){var i=r.exec(t);if(!i){return null}return{scheme:i[1]||"",netLoc:i[2]||"",path:i[3]||"",params:i[4]||"",query:i[5]||"",fragment:i[6]||""}},normalizePath:function(t){t=t.split("").reverse().join("").replace(n,"");while(t.length!==(t=t.replace(s,"")).length){}return t.split("").reverse().join("")},buildURLFromParts:function(t){return t.scheme+t.netLoc+t.path+t.params+t.query+t.fragment}};t.exports=a})()},"./node_modules/webworkify-webpack/index.js":
|
|
10
|
+
/*!**************************************************!*\
|
|
11
|
+
!*** ./node_modules/webworkify-webpack/index.js ***!
|
|
12
|
+
\**************************************************/
|
|
13
|
+
/*! no static exports found */function(t,i,r){function e(t){var i={};function r(e){if(i[e])return i[e].exports;var n=i[e]={i:e,l:false,exports:{}};t[e].call(n.exports,n,n.exports,r);n.l=true;return n.exports}r.m=t;r.c=i;r.i=function(t){return t};r.d=function(t,i,e){if(!r.o(t,i)){Object.defineProperty(t,i,{configurable:false,enumerable:true,get:e})}};r.r=function(t){Object.defineProperty(t,"__esModule",{value:true})};r.n=function(t){var i=t&&t.__esModule?function i(){return t["default"]}:function i(){return t};r.d(i,"a",i);return i};r.o=function(t,i){return Object.prototype.hasOwnProperty.call(t,i)};r.p="/";r.oe=function(t){console.error(t);throw t};var e=r(r.s=ENTRY_MODULE);return e.default||e}var n="[\\.|\\-|\\+|\\w|/|@]+";var s="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+n+").*?\\)";function a(t){return(t+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function u(t){return!isNaN(1*t)}function o(t,i,e){var o={};o[e]=[];var f=i.toString();var h=f.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!h)return o;var l=h[1];var c=new RegExp("(\\\\n|\\W)"+a(l)+s,"g");var v;while(v=c.exec(f)){if(v[3]==="dll-reference")continue;o[e].push(v[3])}c=new RegExp("\\("+a(l)+'\\("(dll-reference\\s('+n+'))"\\)\\)'+s,"g");while(v=c.exec(f)){if(!t[v[2]]){o[e].push(v[1]);t[v[2]]=r(v[1]).m}o[v[2]]=o[v[2]]||[];o[v[2]].push(v[4])}var d=Object.keys(o);for(var m=0;m<d.length;m++){for(var p=0;p<o[d[m]].length;p++){if(u(o[d[m]][p])){o[d[m]][p]=1*o[d[m]][p]}}}return o}function f(t){var i=Object.keys(t);return i.reduce((function(i,r){return i||t[r].length>0}),false)}function h(t,i){var r={main:[i]};var e={main:[]};var n={main:{}};while(f(r)){var s=Object.keys(r);for(var a=0;a<s.length;a++){var u=s[a];var h=r[u];var l=h.pop();n[u]=n[u]||{};if(n[u][l]||!t[u][l])continue;n[u][l]=true;e[u]=e[u]||[];e[u].push(l);var c=o(t,t[u][l],u);var v=Object.keys(c);for(var d=0;d<v.length;d++){r[v[d]]=r[v[d]]||[];r[v[d]]=r[v[d]].concat(c[v[d]])}}}return e}t.exports=function(t,i){i=i||{};var n={main:r.m};var s=i.all?{main:Object.keys(n.main)}:h(n,t);var a="";Object.keys(s).filter((function(t){return t!=="main"})).forEach((function(t){var i=0;while(s[t][i]){i++}s[t].push(i);n[t][i]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })";a=a+"var "+t+" = ("+e.toString().replace("ENTRY_MODULE",JSON.stringify(i))+")({"+s[t].map((function(i){return""+JSON.stringify(i)+": "+n[t][i].toString()})).join(",")+"});\n"}));a=a+"new (("+e.toString().replace("ENTRY_MODULE",JSON.stringify(t))+")({"+s.main.map((function(t){return""+JSON.stringify(t)+": "+n.main[t].toString()})).join(",")+"}))(self);";var u=new window.Blob([a],{type:"text/javascript"});if(i.bare){return u}var o=window.URL||window.webkitURL||window.mozURL||window.msURL;var f=o.createObjectURL(u);var l=new window.Worker(f);l.objectURL=f;return l}},"./src/config.ts":
|
|
14
|
+
/*!***********************!*\
|
|
15
|
+
!*** ./src/config.ts ***!
|
|
16
|
+
\***********************/
|
|
17
|
+
/*! exports provided: hlsDefaultConfig, mergeConfig, enableStreamingMode */function(t,i,r){r.r(i);r.d(i,"hlsDefaultConfig",(function(){return T}));r.d(i,"mergeConfig",(function(){return O}));r.d(i,"enableStreamingMode",(function(){return S}));var e=r(/*! ./controller/abr-controller */"./src/controller/abr-controller.ts");var n=r(/*! ./controller/audio-stream-controller */"./src/controller/audio-stream-controller.ts");var s=r(/*! ./controller/audio-track-controller */"./src/controller/audio-track-controller.ts");var a=r(/*! ./controller/subtitle-stream-controller */"./src/controller/subtitle-stream-controller.ts");var u=r(/*! ./controller/subtitle-track-controller */"./src/controller/subtitle-track-controller.ts");var o=r(/*! ./controller/buffer-controller */"./src/controller/buffer-controller.ts");var f=r(/*! ./controller/timeline-controller */"./src/controller/timeline-controller.ts");var h=r(/*! ./controller/cap-level-controller */"./src/controller/cap-level-controller.ts");var l=r(/*! ./controller/fps-controller */"./src/controller/fps-controller.ts");var c=r(/*! ./controller/eme-controller */"./src/controller/eme-controller.ts");var v=r(/*! ./controller/cmcd-controller */"./src/controller/cmcd-controller.ts");var d=r(/*! ./utils/xhr-loader */"./src/utils/xhr-loader.ts");var m=r(/*! ./utils/fetch-loader */"./src/utils/fetch-loader.ts");var p=r(/*! ./utils/cues */"./src/utils/cues.ts");var g=r(/*! ./utils/mediakeys-helper */"./src/utils/mediakeys-helper.ts");var b=r(/*! ./utils/logger */"./src/utils/logger.ts");function y(){y=Object.assign||function(t){for(var i=1;i<arguments.length;i++){var r=arguments[i];for(var e in r){if(Object.prototype.hasOwnProperty.call(r,e)){t[e]=r[e]}}}return t};return y.apply(this,arguments)}function w(t,i){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(t);if(i){e=e.filter((function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable}))}r.push.apply(r,e)}return r}function A(t){for(var i=1;i<arguments.length;i++){var r=arguments[i]!=null?arguments[i]:{};if(i%2){w(Object(r),true).forEach((function(i){k(t,i,r[i])}))}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(t,Object.getOwnPropertyDescriptors(r))}else{w(Object(r)).forEach((function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(r,i))}))}}return t}function k(t,i,r){if(i in t){Object.defineProperty(t,i,{value:r,enumerable:true,configurable:true,writable:true})}else{t[i]=r}return t}var T=A(A({autoStartLoad:true,startPosition:-1,defaultAudioCodec:undefined,debug:false,capLevelOnFPSDrop:false,capLevelToPlayerSize:false,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:Infinity,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:Infinity,liveSyncDuration:undefined,liveMaxLatencyDuration:undefined,maxLiveSyncPlaybackRate:1,liveDurationInfinity:false,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:true,enableSoftwareAES:true,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,startLevel:undefined,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,startFragPrefetch:false,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:d["default"],fLoader:undefined,pLoader:undefined,xhrSetup:undefined,licenseXhrSetup:undefined,licenseResponseCallback:undefined,abrController:e["default"],bufferController:o["default"],capLevelController:h["default"],fpsController:l["default"],stretchShortVideoTrack:false,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:true,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:false,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:false,widevineLicenseUrl:undefined,drmSystemOptions:{},requestMediaKeySystemAccessFunc:g["requestMediaKeySystemAccess"],testBandwidth:true,progressive:false,lowLatencyMode:true,cmcd:undefined},E()),{},{subtitleStreamController:a["SubtitleStreamController"],subtitleTrackController:u["default"],timelineController:f["TimelineController"],audioStreamController:n["default"],audioTrackController:s["default"],emeController:c["default"],cmcdController:v["default"]});function E(){return{cueHandler:p["default"],enableCEA708Captions:true,enableWebVTT:true,enableIMSC1:true,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:true}}function O(t,i){if((i.liveSyncDurationCount||i.liveMaxLatencyDurationCount)&&(i.liveSyncDuration||i.liveMaxLatencyDuration)){throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration")}if(i.liveMaxLatencyDurationCount!==undefined&&(i.liveSyncDurationCount===undefined||i.liveMaxLatencyDurationCount<=i.liveSyncDurationCount)){throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"')}if(i.liveMaxLatencyDuration!==undefined&&(i.liveSyncDuration===undefined||i.liveMaxLatencyDuration<=i.liveSyncDuration)){throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"')}return y({},t,i)}function S(t){var i=t.loader;if(i!==m["default"]&&i!==d["default"]){b["logger"].log("[config]: Custom loader detected, cannot enable progressive streaming");t.progressive=false}else{var r=Object(m["fetchSupported"])();if(r){t.loader=m["default"];t.progressive=true;t.enableSoftwareAES=true;b["logger"].log("[config]: Progressive streaming enabled, using FetchLoader")}}}},"./src/controller/abr-controller.ts":
|
|
18
|
+
/*!******************************************!*\
|
|
19
|
+
!*** ./src/controller/abr-controller.ts ***!
|
|
20
|
+
\******************************************/
|
|
21
|
+
/*! exports provided: default */function(t,i,r){r.r(i);var e=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");var n=r(/*! ../utils/ewma-bandwidth-estimator */"./src/utils/ewma-bandwidth-estimator.ts");var s=r(/*! ../events */"./src/events.ts");var a=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts");var u=r(/*! ../errors */"./src/errors.ts");var o=r(/*! ../types/loader */"./src/types/loader.ts");var f=r(/*! ../utils/logger */"./src/utils/logger.ts");function h(t,i){for(var r=0;r<i.length;r++){var e=i[r];e.enumerable=e.enumerable||false;e.configurable=true;if("value"in e)e.writable=true;Object.defineProperty(t,e.key,e)}}function l(t,i,r){if(i)h(t.prototype,i);if(r)h(t,r);return t}var c=function(){function t(t){this.hls=void 0;this.lastLoadedFragLevel=0;this._nextAutoLevel=-1;this.timer=void 0;this.onCheck=this._abandonRulesCheck.bind(this);this.fragCurrent=null;this.partCurrent=null;this.bitrateTestDelay=0;this.bwEstimator=void 0;this.hls=t;var i=t.config;this.bwEstimator=new n["default"](i.abrEwmaSlowVoD,i.abrEwmaFastVoD,i.abrEwmaDefaultEstimate);this.registerListeners()}var i=t.prototype;i.registerListeners=function t(){var i=this.hls;i.on(s["Events"].FRAG_LOADING,this.onFragLoading,this);i.on(s["Events"].FRAG_LOADED,this.onFragLoaded,this);i.on(s["Events"].FRAG_BUFFERED,this.onFragBuffered,this);i.on(s["Events"].LEVEL_LOADED,this.onLevelLoaded,this);i.on(s["Events"].ERROR,this.onError,this)};i.unregisterListeners=function t(){var i=this.hls;i.off(s["Events"].FRAG_LOADING,this.onFragLoading,this);i.off(s["Events"].FRAG_LOADED,this.onFragLoaded,this);i.off(s["Events"].FRAG_BUFFERED,this.onFragBuffered,this);i.off(s["Events"].LEVEL_LOADED,this.onLevelLoaded,this);i.off(s["Events"].ERROR,this.onError,this)};i.destroy=function t(){this.unregisterListeners();this.clearTimer();this.hls=this.onCheck=null;this.fragCurrent=this.partCurrent=null};i.onFragLoading=function t(i,r){var e=r.frag;if(e.type===o["PlaylistLevelType"].MAIN){if(!this.timer){var n;this.fragCurrent=e;this.partCurrent=(n=r.part)!=null?n:null;this.timer=self.setInterval(this.onCheck,100)}}};i.onLevelLoaded=function t(i,r){var e=this.hls.config;if(r.details.live){this.bwEstimator.update(e.abrEwmaSlowLive,e.abrEwmaFastLive)}else{this.bwEstimator.update(e.abrEwmaSlowVoD,e.abrEwmaFastVoD)}};i._abandonRulesCheck=function t(){var i=this.fragCurrent,r=this.partCurrent,n=this.hls;var u=n.autoLevelEnabled,o=n.config,h=n.media;if(!i||!h){return}var l=r?r.stats:i.stats;var c=r?r.duration:i.duration;if(l.aborted){f["logger"].warn("frag loader destroy or aborted, disarm abandonRules");this.clearTimer();this._nextAutoLevel=-1;return}if(!u||h.paused||!h.playbackRate||!h.readyState){return}var v=performance.now()-l.loading.start;var d=Math.abs(h.playbackRate);if(v<=500*c/d){return}var m=n.levels,p=n.minAutoLevel;var g=m[i.level];var b=l.total||Math.max(l.loaded,Math.round(c*g.maxBitrate/8));var y=Math.max(1,l.bwEstimate?l.bwEstimate/8:l.loaded*1e3/v);var w=(b-l.loaded)/y;var A=h.currentTime;var k=(a["BufferHelper"].bufferInfo(h,A,o.maxBufferHole).end-A)/d;if(k>=2*c/d||w<=k){return}var T=Number.POSITIVE_INFINITY;var E;for(E=i.level-1;E>p;E--){var O=m[E].maxBitrate;T=c*O/(8*.8*y);if(T<k){break}}if(T>=w){return}var S=this.bwEstimator.getEstimate();f["logger"].warn("Fragment "+i.sn+(r?" part "+r.index:"")+" of level "+i.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+E+"\n Current BW estimate: "+(Object(e["isFiniteNumber"])(S)?(S/1024).toFixed(3):"Unknown")+" Kb/s\n Estimated load time for current fragment: "+w.toFixed(3)+" s\n Estimated load time for the next fragment: "+T.toFixed(3)+" s\n Time to underbuffer: "+k.toFixed(3)+" s");n.nextLoadLevel=E;this.bwEstimator.sample(v,l.loaded);this.clearTimer();if(i.loader){this.fragCurrent=this.partCurrent=null;i.loader.abort()}n.trigger(s["Events"].FRAG_LOAD_EMERGENCY_ABORTED,{frag:i,part:r,stats:l})};i.onFragLoaded=function t(i,r){var n=r.frag,a=r.part;if(n.type===o["PlaylistLevelType"].MAIN&&Object(e["isFiniteNumber"])(n.sn)){var u=a?a.stats:n.stats;var f=a?a.duration:n.duration;this.clearTimer();this.lastLoadedFragLevel=n.level;this._nextAutoLevel=-1;if(this.hls.config.abrMaxWithRealBitrate){var h=this.hls.levels[n.level];var l=(h.loaded?h.loaded.bytes:0)+u.loaded;var c=(h.loaded?h.loaded.duration:0)+f;h.loaded={bytes:l,duration:c};h.realBitrate=Math.round(8*l/c)}if(n.bitrateTest){var v={stats:u,frag:n,part:a,id:n.type};this.onFragBuffered(s["Events"].FRAG_BUFFERED,v);n.bitrateTest=false}}};i.onFragBuffered=function t(i,r){var e=r.frag,n=r.part;var s=n?n.stats:e.stats;if(s.aborted){return}if(e.type!==o["PlaylistLevelType"].MAIN||e.sn==="initSegment"){return}var a=s.parsing.end-s.loading.start;this.bwEstimator.sample(a,s.loaded);s.bwEstimate=this.bwEstimator.getEstimate();if(e.bitrateTest){this.bitrateTestDelay=a/1e3}else{this.bitrateTestDelay=0}};i.onError=function t(i,r){switch(r.details){case u["ErrorDetails"].FRAG_LOAD_ERROR:case u["ErrorDetails"].FRAG_LOAD_TIMEOUT:this.clearTimer();break}};i.clearTimer=function t(){self.clearInterval(this.timer);this.timer=undefined};i.getNextABRAutoLevel=function t(){var i=this.fragCurrent,r=this.partCurrent,e=this.hls;var n=e.maxAutoLevel,s=e.config,u=e.minAutoLevel,o=e.media;var h=r?r.duration:i?i.duration:0;var l=o?o.currentTime:0;var c=o&&o.playbackRate!==0?Math.abs(o.playbackRate):1;var v=this.bwEstimator?this.bwEstimator.getEstimate():s.abrEwmaDefaultEstimate;var d=(a["BufferHelper"].bufferInfo(o,l,s.maxBufferHole).end-l)/c;var m=this.findBestLevel(v,u,n,d,s.abrBandWidthFactor,s.abrBandWidthUpFactor);if(m>=0){return m}f["logger"].trace((d?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var p=h?Math.min(h,s.maxStarvationDelay):s.maxStarvationDelay;var g=s.abrBandWidthFactor;var b=s.abrBandWidthUpFactor;if(!d){var y=this.bitrateTestDelay;if(y){var w=h?Math.min(h,s.maxLoadingDelay):s.maxLoadingDelay;p=w-y;f["logger"].trace("bitrate test took "+Math.round(1e3*y)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*p)+" ms");g=b=1}}m=this.findBestLevel(v,u,n,d+p,g,b);return Math.max(m,0)};i.findBestLevel=function t(i,r,e,n,s,a){var u;var o=this.fragCurrent,h=this.partCurrent,l=this.lastLoadedFragLevel;var c=this.hls.levels;var v=c[l];var d=!!(v!==null&&v!==void 0&&(u=v.details)!==null&&u!==void 0&&u.live);var m=v===null||v===void 0?void 0:v.codecSet;var p=h?h.duration:o?o.duration:0;for(var g=e;g>=r;g--){var b=c[g];if(!b||m&&b.codecSet!==m){continue}var y=b.details;var w=(h?y===null||y===void 0?void 0:y.partTarget:y===null||y===void 0?void 0:y.averagetargetduration)||p;var A=void 0;if(g<=l){A=s*i}else{A=a*i}var k=c[g].maxBitrate;var T=k*w/A;f["logger"].trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+g+"/"+Math.round(A)+"/"+k+"/"+w+"/"+n+"/"+T);if(A>k&&(!T||d&&!this.bitrateTestDelay||T<n)){return g}}return-1};l(t,[{key:"nextAutoLevel",get:function t(){var i=this._nextAutoLevel;var r=this.bwEstimator;if(i!==-1&&(!r||!r.canEstimate())){return i}var e=this.getNextABRAutoLevel();if(i!==-1){e=Math.min(i,e)}return e},set:function t(i){this._nextAutoLevel=i}}]);return t}();i["default"]=c},"./src/controller/audio-stream-controller.ts":
|
|
22
|
+
/*!***************************************************!*\
|
|
23
|
+
!*** ./src/controller/audio-stream-controller.ts ***!
|
|
24
|
+
\***************************************************/
|
|
25
|
+
/*! exports provided: default */function(t,i,r){r.r(i);var e=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");var n=r(/*! ./base-stream-controller */"./src/controller/base-stream-controller.ts");var s=r(/*! ../events */"./src/events.ts");var a=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts");var u=r(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts");var o=r(/*! ../types/level */"./src/types/level.ts");var f=r(/*! ../types/loader */"./src/types/loader.ts");var h=r(/*! ../loader/fragment */"./src/loader/fragment.ts");var l=r(/*! ../demux/chunk-cache */"./src/demux/chunk-cache.ts");var c=r(/*! ../demux/transmuxer-interface */"./src/demux/transmuxer-interface.ts");var v=r(/*! ../types/transmuxer */"./src/types/transmuxer.ts");var d=r(/*! ./fragment-finders */"./src/controller/fragment-finders.ts");var m=r(/*! ../utils/discontinuities */"./src/utils/discontinuities.ts");var p=r(/*! ../errors */"./src/errors.ts");var g=r(/*! ../utils/logger */"./src/utils/logger.ts");function b(){b=Object.assign||function(t){for(var i=1;i<arguments.length;i++){var r=arguments[i];for(var e in r){if(Object.prototype.hasOwnProperty.call(r,e)){t[e]=r[e]}}}return t};return b.apply(this,arguments)}function y(t,i){t.prototype=Object.create(i.prototype);t.prototype.constructor=t;w(t,i)}function w(t,i){w=Object.setPrototypeOf||function t(i,r){i.__proto__=r;return i};return w(t,i)}var A=100;var k=function(t){y(i,t);function i(i,r){var e;e=t.call(this,i,r,"[audio-stream-controller]")||this;e.videoBuffer=null;e.videoTrackCC=-1;e.waitingVideoCC=-1;e.audioSwitch=false;e.trackId=-1;e.waitingData=null;e.mainDetails=null;e.bufferFlushed=false;e._registerListeners();return e}var r=i.prototype;r.onHandlerDestroying=function t(){this._unregisterListeners();this.mainDetails=null};r._registerListeners=function t(){var i=this.hls;i.on(s["Events"].MEDIA_ATTACHED,this.onMediaAttached,this);i.on(s["Events"].MEDIA_DETACHING,this.onMediaDetaching,this);i.on(s["Events"].MANIFEST_LOADING,this.onManifestLoading,this);i.on(s["Events"].LEVEL_LOADED,this.onLevelLoaded,this);i.on(s["Events"].AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this);i.on(s["Events"].AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this);i.on(s["Events"].AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this);i.on(s["Events"].ERROR,this.onError,this);i.on(s["Events"].BUFFER_RESET,this.onBufferReset,this);i.on(s["Events"].BUFFER_CREATED,this.onBufferCreated,this);i.on(s["Events"].BUFFER_FLUSHED,this.onBufferFlushed,this);i.on(s["Events"].INIT_PTS_FOUND,this.onInitPtsFound,this);i.on(s["Events"].FRAG_BUFFERED,this.onFragBuffered,this)};r._unregisterListeners=function t(){var i=this.hls;i.off(s["Events"].MEDIA_ATTACHED,this.onMediaAttached,this);i.off(s["Events"].MEDIA_DETACHING,this.onMediaDetaching,this);i.off(s["Events"].MANIFEST_LOADING,this.onManifestLoading,this);i.off(s["Events"].LEVEL_LOADED,this.onLevelLoaded,this);i.off(s["Events"].AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this);i.off(s["Events"].AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this);i.off(s["Events"].AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this);i.off(s["Events"].ERROR,this.onError,this);i.off(s["Events"].BUFFER_RESET,this.onBufferReset,this);i.off(s["Events"].BUFFER_CREATED,this.onBufferCreated,this);i.off(s["Events"].BUFFER_FLUSHED,this.onBufferFlushed,this);i.off(s["Events"].INIT_PTS_FOUND,this.onInitPtsFound,this);i.off(s["Events"].FRAG_BUFFERED,this.onFragBuffered,this)};r.onInitPtsFound=function t(i,r){var e=r.frag,s=r.id,a=r.initPTS;if(s==="main"){var u=e.cc;this.initPTS[e.cc]=a;this.log("InitPTS for cc: "+u+" found from main: "+a);this.videoTrackCC=u;if(this.state===n["State"].WAITING_INIT_PTS){this.tick()}}};r.startLoad=function t(i){if(!this.levels){this.startPosition=i;this.state=n["State"].STOPPED;return}var r=this.lastCurrentTime;this.stopLoad();this.setInterval(A);this.fragLoadError=0;if(r>0&&i===-1){this.log("Override startPosition with lastCurrentTime @"+r.toFixed(3));this.state=n["State"].IDLE}else{this.loadedmetadata=false;this.state=n["State"].WAITING_TRACK}this.nextLoadPosition=this.startPosition=this.lastCurrentTime=i;this.tick()};r.doTick=function i(){switch(this.state){case n["State"].IDLE:this.doTickIdle();break;case n["State"].WAITING_TRACK:{var r;var e=this.levels,s=this.trackId;var u=e===null||e===void 0?void 0:(r=e[s])===null||r===void 0?void 0:r.details;if(u){if(this.waitForCdnTuneIn(u)){break}this.state=n["State"].WAITING_INIT_PTS}break}case n["State"].FRAG_LOADING_WAITING_RETRY:{var o;var f=performance.now();var h=this.retryDate;if(!h||f>=h||(o=this.media)!==null&&o!==void 0&&o.seeking){this.log("RetryDate reached, switch back to IDLE state");this.state=n["State"].IDLE}break}case n["State"].WAITING_INIT_PTS:{var l=this.waitingData;if(l){var c=l.frag,v=l.part,m=l.cache,p=l.complete;if(this.initPTS[c.cc]!==undefined){this.waitingData=null;this.waitingVideoCC=-1;this.state=n["State"].FRAG_LOADING;var b=m.flush();var y={frag:c,part:v,payload:b,networkDetails:null};this._handleFragmentLoadProgress(y);if(p){t.prototype._handleFragmentLoadComplete.call(this,y)}}else if(this.videoTrackCC!==this.waitingVideoCC){g["logger"].log("Waiting fragment cc ("+c.cc+") cancelled because video is at cc "+this.videoTrackCC);this.clearWaitingFragment()}else{var w=this.getLoadPosition();var A=a["BufferHelper"].bufferInfo(this.mediaBuffer,w,this.config.maxBufferHole);var k=Object(d["fragmentWithinToleranceTest"])(A.end,this.config.maxFragLookUpTolerance,c);if(k<0){g["logger"].log("Waiting fragment cc ("+c.cc+") @ "+c.start+" cancelled because another fragment at "+A.end+" is needed");this.clearWaitingFragment()}}}else{this.state=n["State"].IDLE}}}this.onTickEnd()};r.clearWaitingFragment=function t(){var i=this.waitingData;if(i){this.fragmentTracker.removeFragment(i.frag);this.waitingData=null;this.waitingVideoCC=-1;this.state=n["State"].IDLE}};r.onTickEnd=function t(){var i=this.media;if(!i||!i.readyState){return}var r=this.mediaBuffer?this.mediaBuffer:i;var e=r.buffered;if(!this.loadedmetadata&&e.length){this.loadedmetadata=true}this.lastCurrentTime=i.currentTime};r.doTickIdle=function t(){var i,r;var e=this.hls,a=this.levels,u=this.media,o=this.trackId;var l=e.config;if(!a||!a[o]){return}if(!u&&(this.startFragRequested||!l.startFragPrefetch)){return}var c=a[o];var v=c.details;if(!v||v.live&&this.levelLastLoaded!==o||this.waitForCdnTuneIn(v)){this.state=n["State"].WAITING_TRACK;return}if(this.bufferFlushed){this.bufferFlushed=false;this.afterBufferFlushed(this.mediaBuffer?this.mediaBuffer:this.media,h["ElementaryStreamTypes"].AUDIO,f["PlaylistLevelType"].AUDIO)}var d=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,f["PlaylistLevelType"].AUDIO);if(d===null){return}var m=d.len;var p=this.getMaxBufferLength();var g=this.audioSwitch;if(m>=p&&!g){return}if(!g&&this._streamEnded(d,v)){e.trigger(s["Events"].BUFFER_EOS,{type:"audio"});this.state=n["State"].ENDED;return}var b=v.fragments;var y=b[0].start;var w=d.end;if(g){var A=this.getLoadPosition();w=A;if(v.PTSKnown&&A<y){if(d.end>y||d.nextStart){this.log("Alt audio track ahead of main track, seek to start of alt audio track");u.currentTime=y+.05}}}var k=this.getNextFragment(w,v);if(!k){this.bufferFlushed=true;return}if(((i=k.decryptdata)===null||i===void 0?void 0:i.keyFormat)==="identity"&&!((r=k.decryptdata)!==null&&r!==void 0&&r.key)){this.loadKey(k,v)}else{this.loadFragment(k,v,w)}};r.getMaxBufferLength=function i(){var r=t.prototype.getMaxBufferLength.call(this);var e=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,f["PlaylistLevelType"].MAIN);if(e===null){return r}return Math.max(r,e.len)};r.onMediaDetaching=function i(){this.videoBuffer=null;t.prototype.onMediaDetaching.call(this)};r.onAudioTracksUpdated=function t(i,r){var e=r.audioTracks;this.resetTransmuxer();this.levels=e.map((function(t){return new o["Level"](t)}))};r.onAudioTrackSwitching=function t(i,r){var e=!!r.url;this.trackId=r.id;var s=this.fragCurrent;if(s!==null&&s!==void 0&&s.loader){s.loader.abort()}this.fragCurrent=null;this.clearWaitingFragment();if(!e){this.resetTransmuxer()}else{this.setInterval(A)}if(e){this.audioSwitch=true;this.state=n["State"].IDLE}else{this.state=n["State"].STOPPED}this.tick()};r.onManifestLoading=function t(){this.mainDetails=null;this.fragmentTracker.removeAllFragments();this.startPosition=this.lastCurrentTime=0;this.bufferFlushed=false};r.onLevelLoaded=function t(i,r){this.mainDetails=r.details};r.onAudioTrackLoaded=function t(i,r){var e;var s=this.levels;var a=r.details,u=r.id;if(!s){this.warn("Audio tracks were reset while loading level "+u);return}this.log("Track "+u+" loaded ["+a.startSN+","+a.endSN+"],duration:"+a.totalduration);var o=s[u];var f=0;if(a.live||(e=o.details)!==null&&e!==void 0&&e.live){var h=this.mainDetails;if(!a.fragments[0]){a.deltaUpdateFailed=true}if(a.deltaUpdateFailed||!h){return}if(!o.details&&a.hasProgramDateTime&&h.hasProgramDateTime){Object(m["alignMediaPlaylistByPDT"])(a,h);f=a.fragments[0].start}else{f=this.alignPlaylists(a,o.details)}}o.details=a;this.levelLastLoaded=u;if(!this.startFragRequested&&(this.mainDetails||!a.live)){this.setStartPosition(o.details,f)}if(this.state===n["State"].WAITING_TRACK&&!this.waitForCdnTuneIn(a)){this.state=n["State"].IDLE}this.tick()};r._handleFragmentLoadProgress=function t(i){var r;var e=i.frag,s=i.part,a=i.payload;var u=this.config,o=this.trackId,h=this.levels;if(!h){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+e.sn+" of level "+e.level+" will not be buffered");return}var d=h[o];console.assert(d,"Audio track is defined on fragment load progress");var m=d.details;console.assert(m,"Audio track details are defined on fragment load progress");var p=u.defaultAudioCodec||d.audioCodec||"mp4a.40.2";var b=this.transmuxer;if(!b){b=this.transmuxer=new c["default"](this.hls,f["PlaylistLevelType"].AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this))}var y=this.initPTS[e.cc];var w=(r=e.initSegment)===null||r===void 0?void 0:r.data;if(y!==undefined){var A=false;var k=s?s.index:-1;var T=k!==-1;var E=new v["ChunkMetadata"](e.level,e.sn,e.stats.chunkCount,a.byteLength,k,T);b.push(a,w,p,"",e,s,m.totalduration,A,E,y)}else{g["logger"].log("Unknown video PTS for cc "+e.cc+", waiting for video PTS before demuxing audio frag "+e.sn+" of ["+m.startSN+" ,"+m.endSN+"],track "+o);var O=this.waitingData=this.waitingData||{frag:e,part:s,cache:new l["default"],complete:false},S=O.cache;S.push(new Uint8Array(a));this.waitingVideoCC=this.videoTrackCC;this.state=n["State"].WAITING_INIT_PTS}};r._handleFragmentLoadComplete=function i(r){if(this.waitingData){this.waitingData.complete=true;return}t.prototype._handleFragmentLoadComplete.call(this,r)};r.onBufferReset=function t(){this.mediaBuffer=this.videoBuffer=null;this.loadedmetadata=false};r.onBufferCreated=function t(i,r){var e=r.tracks.audio;if(e){this.mediaBuffer=e.buffer}if(r.tracks.video){this.videoBuffer=r.tracks.video.buffer}};r.onFragBuffered=function t(i,r){var e=r.frag,n=r.part;if(e.type!==f["PlaylistLevelType"].AUDIO){return}if(this.fragContextChanged(e)){this.warn("Fragment "+e.sn+(n?" p: "+n.index:"")+" of level "+e.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}if(e.sn!=="initSegment"){this.fragPrevious=e;if(this.audioSwitch){this.audioSwitch=false;this.hls.trigger(s["Events"].AUDIO_TRACK_SWITCHED,{id:this.trackId})}}this.fragBufferedComplete(e,n)};r.onError=function i(r,e){switch(e.details){case p["ErrorDetails"].FRAG_LOAD_ERROR:case p["ErrorDetails"].FRAG_LOAD_TIMEOUT:case p["ErrorDetails"].KEY_LOAD_ERROR:case p["ErrorDetails"].KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(f["PlaylistLevelType"].AUDIO,e);break;case p["ErrorDetails"].AUDIO_TRACK_LOAD_ERROR:case p["ErrorDetails"].AUDIO_TRACK_LOAD_TIMEOUT:if(this.state!==n["State"].ERROR&&this.state!==n["State"].STOPPED){this.state=e.fatal?n["State"].ERROR:n["State"].IDLE;this.warn(e.details+" while loading frag, switching to "+this.state+" state")}break;case p["ErrorDetails"].BUFFER_FULL_ERROR:if(e.parent==="audio"&&(this.state===n["State"].PARSING||this.state===n["State"].PARSED)){var s=true;var a=this.getFwdBufferInfo(this.mediaBuffer,f["PlaylistLevelType"].AUDIO);if(a&&a.len>.5){s=!this.reduceMaxBufferLength(a.len)}if(s){this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer");this.fragCurrent=null;t.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")}this.resetLoadingState()}break}};r.onBufferFlushed=function t(i,r){var e=r.type;if(e===h["ElementaryStreamTypes"].AUDIO){this.bufferFlushed=true}};r._handleTransmuxComplete=function t(i){var r;var e="audio";var a=this.hls;var u=i.remuxResult,o=i.chunkMeta;var f=this.getCurrentContext(o);if(!f){this.warn("The loading context changed while buffering fragment "+o.sn+" of level "+o.level+". This chunk will not be buffered.");this.resetLiveStartWhenNotLoaded(o.level);return}var l=f.frag,c=f.part;var v=u.audio,d=u.text,m=u.id3,p=u.initSegment;if(this.fragContextChanged(l)){return}this.state=n["State"].PARSING;if(this.audioSwitch&&v){this.completeAudioSwitch()}if(p!==null&&p!==void 0&&p.tracks){this._bufferInitSegment(p.tracks,l,o);a.trigger(s["Events"].FRAG_PARSING_INIT_SEGMENT,{frag:l,id:e,tracks:p.tracks})}if(v){var g=v.startPTS,y=v.endPTS,w=v.startDTS,A=v.endDTS;if(c){c.elementaryStreams[h["ElementaryStreamTypes"].AUDIO]={startPTS:g,endPTS:y,startDTS:w,endDTS:A}}l.setElementaryStreamInfo(h["ElementaryStreamTypes"].AUDIO,g,y,w,A);this.bufferFragmentData(v,l,c,o)}if(m!==null&&m!==void 0&&(r=m.samples)!==null&&r!==void 0&&r.length){var k=b({frag:l,id:e},m);a.trigger(s["Events"].FRAG_PARSING_METADATA,k)}if(d){var T=b({frag:l,id:e},d);a.trigger(s["Events"].FRAG_PARSING_USERDATA,T)}};r._bufferInitSegment=function t(i,r,e){if(this.state!==n["State"].PARSING){return}if(i.video){delete i.video}var a=i.audio;if(!a){return}a.levelCodec=a.codec;a.id="audio";this.log("Init audio buffer, container:"+a.container+", codecs[parsed]=["+a.codec+"]");this.hls.trigger(s["Events"].BUFFER_CODECS,i);var u=a.initSegment;if(u!==null&&u!==void 0&&u.byteLength){var o={type:"audio",frag:r,part:null,chunkMeta:e,parent:r.type,data:u};this.hls.trigger(s["Events"].BUFFER_APPENDING,o)}this.tick()};r.loadFragment=function i(r,s,a){var o=this.fragmentTracker.getState(r);this.fragCurrent=r;if(this.audioSwitch||o===u["FragmentState"].NOT_LOADED||o===u["FragmentState"].PARTIAL){if(r.sn==="initSegment"){this._loadInitSegment(r)}else if(s.live&&!Object(e["isFiniteNumber"])(this.initPTS[r.cc])){this.log("Waiting for video PTS in continuity counter "+r.cc+" of live stream before loading audio fragment "+r.sn+" of level "+this.trackId);this.state=n["State"].WAITING_INIT_PTS}else{this.startFragRequested=true;t.prototype.loadFragment.call(this,r,s,a)}}};r.completeAudioSwitch=function i(){var r=this.hls,e=this.media,n=this.trackId;if(e){this.log("Switching audio track : flushing all audio");t.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")}this.audioSwitch=false;r.trigger(s["Events"].AUDIO_TRACK_SWITCHED,{id:n})};return i}(n["default"]);i["default"]=k},"./src/controller/audio-track-controller.ts":
|
|
26
|
+
/*!**************************************************!*\
|
|
27
|
+
!*** ./src/controller/audio-track-controller.ts ***!
|
|
28
|
+
\**************************************************/
|
|
29
|
+
/*! exports provided: default */function(t,i,r){r.r(i);var e=r(/*! ../events */"./src/events.ts");var n=r(/*! ../errors */"./src/errors.ts");var s=r(/*! ./base-playlist-controller */"./src/controller/base-playlist-controller.ts");var a=r(/*! ../types/loader */"./src/types/loader.ts");function u(t,i){for(var r=0;r<i.length;r++){var e=i[r];e.enumerable=e.enumerable||false;e.configurable=true;if("value"in e)e.writable=true;Object.defineProperty(t,e.key,e)}}function o(t,i,r){if(i)u(t.prototype,i);if(r)u(t,r);return t}function f(t,i){t.prototype=Object.create(i.prototype);t.prototype.constructor=t;h(t,i)}function h(t,i){h=Object.setPrototypeOf||function t(i,r){i.__proto__=r;return i};return h(t,i)}var l=function(t){f(i,t);function i(i){var r;r=t.call(this,i,"[audio-track-controller]")||this;r.tracks=[];r.groupId=null;r.tracksInGroup=[];r.trackId=-1;r.trackName="";r.selectDefaultTrack=true;r.registerListeners();return r}var r=i.prototype;r.registerListeners=function t(){var i=this.hls;i.on(e["Events"].MANIFEST_LOADING,this.onManifestLoading,this);i.on(e["Events"].MANIFEST_PARSED,this.onManifestParsed,this);i.on(e["Events"].LEVEL_LOADING,this.onLevelLoading,this);i.on(e["Events"].LEVEL_SWITCHING,this.onLevelSwitching,this);i.on(e["Events"].AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this);i.on(e["Events"].ERROR,this.onError,this)};r.unregisterListeners=function t(){var i=this.hls;i.off(e["Events"].MANIFEST_LOADING,this.onManifestLoading,this);i.off(e["Events"].MANIFEST_PARSED,this.onManifestParsed,this);i.off(e["Events"].LEVEL_LOADING,this.onLevelLoading,this);i.off(e["Events"].LEVEL_SWITCHING,this.onLevelSwitching,this);i.off(e["Events"].AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this);i.off(e["Events"].ERROR,this.onError,this)};r.destroy=function i(){this.unregisterListeners();this.tracks.length=0;this.tracksInGroup.length=0;t.prototype.destroy.call(this)};r.onManifestLoading=function t(){this.tracks=[];this.groupId=null;this.tracksInGroup=[];this.trackId=-1;this.trackName="";this.selectDefaultTrack=true};r.onManifestParsed=function t(i,r){this.tracks=r.audioTracks||[]};r.onAudioTrackLoaded=function t(i,r){var e=r.id,n=r.details;var s=this.tracksInGroup[e];if(!s){this.warn("Invalid audio track id "+e);return}var a=s.details;s.details=r.details;this.log("audioTrack "+e+" loaded ["+n.startSN+"-"+n.endSN+"]");if(e===this.trackId){this.retryCount=0;this.playlistLoaded(e,r,a)}};r.onLevelLoading=function t(i,r){this.switchLevel(r.level)};r.onLevelSwitching=function t(i,r){this.switchLevel(r.level)};r.switchLevel=function t(i){var r=this.hls.levels[i];if(!(r!==null&&r!==void 0&&r.audioGroupIds)){return}var n=r.audioGroupIds[r.urlId];if(this.groupId!==n){this.groupId=n;var s=this.tracks.filter((function(t){return!n||t.groupId===n}));if(this.selectDefaultTrack&&!s.some((function(t){return t.default}))){this.selectDefaultTrack=false}this.tracksInGroup=s;var a={audioTracks:s};this.log("Updating audio tracks, "+s.length+' track(s) found in "'+n+'" group-id');this.hls.trigger(e["Events"].AUDIO_TRACKS_UPDATED,a);this.selectInitialTrack()}};r.onError=function i(r,e){t.prototype.onError.call(this,r,e);if(e.fatal||!e.context){return}if(e.context.type===a["PlaylistContextType"].AUDIO_TRACK&&e.context.id===this.trackId&&e.context.groupId===this.groupId){this.retryLoadingOrFail(e)}};r.setAudioTrack=function t(i){var r=this.tracksInGroup;if(i<0||i>=r.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var n=r[this.trackId];this.log("Now switching to audio-track index "+i);var s=r[i];var a=s.id,u=s.groupId,o=u===void 0?"":u,f=s.name,h=s.type,l=s.url;this.trackId=i;this.trackName=f;this.selectDefaultTrack=false;this.hls.trigger(e["Events"].AUDIO_TRACK_SWITCHING,{id:a,groupId:o,name:f,type:h,url:l});if(s.details&&!s.details.live){return}var c=this.switchParams(s.url,n===null||n===void 0?void 0:n.details);this.loadPlaylist(c)};r.selectInitialTrack=function t(){var i=this.tracksInGroup;console.assert(i.length,"Initial audio track should be selected when tracks are known");var r=this.trackName;var s=this.findTrackId(r)||this.findTrackId();if(s!==-1){this.setAudioTrack(s)}else{this.warn("No track found for running audio group-ID: "+this.groupId);this.hls.trigger(e["Events"].ERROR,{type:n["ErrorTypes"].MEDIA_ERROR,details:n["ErrorDetails"].AUDIO_TRACK_LOAD_ERROR,fatal:true})}};r.findTrackId=function t(i){var r=this.tracksInGroup;for(var e=0;e<r.length;e++){var n=r[e];if(!this.selectDefaultTrack||n.default){if(!i||i===n.name){return n.id}}}return-1};r.loadPlaylist=function t(i){var r=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(r)){var n=r.id;var s=r.groupId;var a=r.url;if(i){try{a=i.addDirectives(a)}catch(t){this.warn("Could not construct new URL with HLS Delivery Directives: "+t)}}this.log("loading audio-track playlist for id: "+n);this.clearTimer();this.hls.trigger(e["Events"].AUDIO_TRACK_LOADING,{url:a,id:n,groupId:s,deliveryDirectives:i||null})}};o(i,[{key:"audioTracks",get:function t(){return this.tracksInGroup}},{key:"audioTrack",get:function t(){return this.trackId},set:function t(i){this.selectDefaultTrack=false;this.setAudioTrack(i)}}]);return i}(s["default"]);i["default"]=l},"./src/controller/base-playlist-controller.ts":
|
|
30
|
+
/*!****************************************************!*\
|
|
31
|
+
!*** ./src/controller/base-playlist-controller.ts ***!
|
|
32
|
+
\****************************************************/
|
|
33
|
+
/*! exports provided: default */function(t,i,r){r.r(i);r.d(i,"default",(function(){return o}));var e=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");var n=r(/*! ../types/level */"./src/types/level.ts");var s=r(/*! ./level-helper */"./src/controller/level-helper.ts");var a=r(/*! ../utils/logger */"./src/utils/logger.ts");var u=r(/*! ../errors */"./src/errors.ts");var o=function(){function t(t,i){this.hls=void 0;this.timer=-1;this.canLoad=false;this.retryCount=0;this.log=void 0;this.warn=void 0;this.log=a["logger"].log.bind(a["logger"],i+":");this.warn=a["logger"].warn.bind(a["logger"],i+":");this.hls=t}var i=t.prototype;i.destroy=function t(){this.clearTimer();this.hls=this.log=this.warn=null};i.onError=function t(i,r){if(r.fatal&&r.type===u["ErrorTypes"].NETWORK_ERROR){this.clearTimer()}};i.clearTimer=function t(){clearTimeout(this.timer);this.timer=-1};i.startLoad=function t(){this.canLoad=true;this.retryCount=0;this.loadPlaylist()};i.stopLoad=function t(){this.canLoad=false;this.clearTimer()};i.switchParams=function t(i,r){var s=r===null||r===void 0?void 0:r.renditionReports;if(s){for(var a=0;a<s.length;a++){var u=s[a];var o=""+u.URI;if(o===i.substr(-o.length)){var f=parseInt(u["LAST-MSN"]);var h=parseInt(u["LAST-PART"]);if(r&&this.hls.config.lowLatencyMode){var l=Math.min(r.age-r.partTarget,r.targetduration);if(h!==undefined&&l>r.partTarget){h+=1}}if(Object(e["isFiniteNumber"])(f)){return new n["HlsUrlParameters"](f,Object(e["isFiniteNumber"])(h)?h:undefined,n["HlsSkip"].No)}}}}};i.loadPlaylist=function t(i){};i.shouldLoadTrack=function t(i){return this.canLoad&&i&&!!i.url&&(!i.details||i.details.live)};i.playlistLoaded=function t(i,r,e){var n=this;var a=r.details,u=r.stats;var o=u.loading.end?Math.max(0,self.performance.now()-u.loading.end):0;a.advancedDateTime=Date.now()-o;if(a.live||e!==null&&e!==void 0&&e.live){a.reloaded(e);if(e){this.log("live playlist "+i+" "+(a.advanced?"REFRESHED "+a.lastPartSn+"-"+a.lastPartIndex:"MISSED"))}if(e&&a.fragments.length>0){Object(s["mergeDetails"])(e,a)}if(!this.canLoad||!a.live){return}var f;var h=undefined;var l=undefined;if(a.canBlockReload&&a.endSN&&a.advanced){var c=this.hls.config.lowLatencyMode;var v=a.lastPartSn;var d=a.endSN;var m=a.lastPartIndex;var p=m!==-1;var g=v===d;var b=c?0:m;if(p){h=g?d+1:v;l=g?b:m+1}else{h=d+1}var y=a.age;var w=y+a.ageHeader;var A=Math.min(w-a.partTarget,a.targetduration*1.5);if(A>0){if(e&&A>e.tuneInGoal){this.warn("CDN Tune-in goal increased from: "+e.tuneInGoal+" to: "+A+" with playlist age: "+a.age);A=0}else{var k=Math.floor(A/a.targetduration);h+=k;if(l!==undefined){var T=Math.round(A%a.targetduration/a.partTarget);l+=T}this.log("CDN Tune-in age: "+a.ageHeader+"s last advanced "+y.toFixed(2)+"s goal: "+A+" skip sn "+k+" to part "+l)}a.tuneInGoal=A}f=this.getDeliveryDirectives(a,r.deliveryDirectives,h,l);if(c||!g){this.loadPlaylist(f);return}}else{f=this.getDeliveryDirectives(a,r.deliveryDirectives,h,l)}var E=Object(s["computeReloadInterval"])(a,u);if(h!==undefined&&a.canBlockReload){E-=a.partTarget||1}this.log("reload live playlist "+i+" in "+Math.round(E)+" ms");this.timer=self.setTimeout((function(){return n.loadPlaylist(f)}),E)}else{this.clearTimer()}};i.getDeliveryDirectives=function t(i,r,e,s){var a=Object(n["getSkipValue"])(i,e);if(r!==null&&r!==void 0&&r.skip&&i.deltaUpdateFailed){e=r.msn;s=r.part;a=n["HlsSkip"].No}return new n["HlsUrlParameters"](e,s,a)};i.retryLoadingOrFail=function t(i){var r=this;var e=this.hls.config;var n=this.retryCount<e.levelLoadingMaxRetry;if(n){var s;this.retryCount++;if(i.details.indexOf("LoadTimeOut")>-1&&(s=i.context)!==null&&s!==void 0&&s.deliveryDirectives){this.warn("retry playlist loading #"+this.retryCount+' after "'+i.details+'"');this.loadPlaylist()}else{var a=Math.min(Math.pow(2,this.retryCount)*e.levelLoadingRetryDelay,e.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout((function(){return r.loadPlaylist()}),a);this.warn("retry playlist loading #"+this.retryCount+" in "+a+' ms after "'+i.details+'"')}}else{this.warn('cannot recover from error "'+i.details+'"');this.clearTimer();i.fatal=true}return n};return t}()},"./src/controller/base-stream-controller.ts":
|
|
34
|
+
/*!**************************************************!*\
|
|
35
|
+
!*** ./src/controller/base-stream-controller.ts ***!
|
|
36
|
+
\**************************************************/
|
|
37
|
+
/*! exports provided: State, default */function(t,i,r){r.r(i);r.d(i,"State",(function(){return E}));r.d(i,"default",(function(){return O}));var e=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");var n=r(/*! ../task-loop */"./src/task-loop.ts");var s=r(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts");var a=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts");var u=r(/*! ../utils/logger */"./src/utils/logger.ts");var o=r(/*! ../events */"./src/events.ts");var f=r(/*! ../errors */"./src/errors.ts");var h=r(/*! ../types/transmuxer */"./src/types/transmuxer.ts");var l=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts");var c=r(/*! ../utils/discontinuities */"./src/utils/discontinuities.ts");var v=r(/*! ./fragment-finders */"./src/controller/fragment-finders.ts");var d=r(/*! ./level-helper */"./src/controller/level-helper.ts");var m=r(/*! ../loader/fragment-loader */"./src/loader/fragment-loader.ts");var p=r(/*! ../crypt/decrypter */"./src/crypt/decrypter.ts");var g=r(/*! ../utils/time-ranges */"./src/utils/time-ranges.ts");var b=r(/*! ../types/loader */"./src/types/loader.ts");function y(t,i){for(var r=0;r<i.length;r++){var e=i[r];e.enumerable=e.enumerable||false;e.configurable=true;if("value"in e)e.writable=true;Object.defineProperty(t,e.key,e)}}function w(t,i,r){if(i)y(t.prototype,i);if(r)y(t,r);return t}function A(t){if(t===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return t}function k(t,i){t.prototype=Object.create(i.prototype);t.prototype.constructor=t;T(t,i)}function T(t,i){T=Object.setPrototypeOf||function t(i,r){i.__proto__=r;return i};return T(t,i)}var E={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",BACKTRACKING:"BACKTRACKING",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"};var O=function(t){k(i,t);function i(i,r,e){var n;n=t.call(this)||this;n.hls=void 0;n.fragPrevious=null;n.fragCurrent=null;n.fragmentTracker=void 0;n.transmuxer=null;n._state=E.STOPPED;n.media=void 0;n.mediaBuffer=void 0;n.config=void 0;n.bitrateTest=false;n.lastCurrentTime=0;n.nextLoadPosition=0;n.startPosition=0;n.loadedmetadata=false;n.fragLoadError=0;n.retryDate=0;n.levels=null;n.fragmentLoader=void 0;n.levelLastLoaded=null;n.startFragRequested=false;n.decrypter=void 0;n.initPTS=[];n.onvseeking=null;n.onvended=null;n.logPrefix="";n.log=void 0;n.warn=void 0;n.logPrefix=e;n.log=u["logger"].log.bind(u["logger"],e+":");n.warn=u["logger"].warn.bind(u["logger"],e+":");n.hls=i;n.fragmentLoader=new m["default"](i.config);n.fragmentTracker=r;n.config=i.config;n.decrypter=new p["default"](i,i.config);i.on(o["Events"].KEY_LOADED,n.onKeyLoaded,A(n));return n}var r=i.prototype;r.doTick=function t(){this.onTickEnd()};r.onTickEnd=function t(){};r.startLoad=function t(i){};r.stopLoad=function t(){this.fragmentLoader.abort();var i=this.fragCurrent;if(i){this.fragmentTracker.removeFragment(i)}this.resetTransmuxer();this.fragCurrent=null;this.fragPrevious=null;this.clearInterval();this.clearNextTick();this.state=E.STOPPED};r._streamEnded=function t(i,r){var e=this.fragCurrent,n=this.fragmentTracker;if(!r.live&&e&&e.sn>=r.endSN&&!i.nextStart){var u=r.partList;if(u!==null&&u!==void 0&&u.length){var o=u[u.length-1];var f=a["BufferHelper"].isBuffered(this.media,o.start+o.duration/2);return f}var h=n.getState(e);return h===s["FragmentState"].PARTIAL||h===s["FragmentState"].OK}return false};r.onMediaAttached=function t(i,r){var e=this.media=this.mediaBuffer=r.media;this.onvseeking=this.onMediaSeeking.bind(this);this.onvended=this.onMediaEnded.bind(this);e.addEventListener("seeking",this.onvseeking);e.addEventListener("ended",this.onvended);var n=this.config;if(this.levels&&n.autoStartLoad&&this.state===E.STOPPED){this.startLoad(n.startPosition)}};r.onMediaDetaching=function t(){var i=this.media;if(i!==null&&i!==void 0&&i.ended){this.log("MSE detaching and video ended, reset startPosition");this.startPosition=this.lastCurrentTime=0}if(i){i.removeEventListener("seeking",this.onvseeking);i.removeEventListener("ended",this.onvended);this.onvseeking=this.onvended=null}this.media=this.mediaBuffer=null;this.loadedmetadata=false;this.fragmentTracker.removeAllFragments();this.stopLoad()};r.onMediaSeeking=function t(){var i=this.config,r=this.fragCurrent,n=this.media,s=this.mediaBuffer,u=this.state;var o=n?n.currentTime:0;var f=a["BufferHelper"].bufferInfo(s||n,o,i.maxBufferHole);this.log("media seeking to "+(Object(e["isFiniteNumber"])(o)?o.toFixed(3):o)+", state: "+u);if(u===E.ENDED){this.resetLoadingState()}else if(r&&!f.len){var h=i.maxFragLookUpTolerance;var l=r.start-h;var c=r.start+r.duration+h;var v=o>c;if(o<l||v){if(v&&r.loader){this.log("seeking outside of buffer while fragment load in progress, cancel fragment load");r.loader.abort()}this.resetLoadingState()}}if(n){this.lastCurrentTime=o}if(!this.loadedmetadata&&!f.len){this.nextLoadPosition=this.startPosition=o}this.tickImmediate()};r.onMediaEnded=function t(){this.startPosition=this.lastCurrentTime=0};r.onKeyLoaded=function t(i,r){if(this.state!==E.KEY_LOADING||r.frag!==this.fragCurrent||!this.levels){return}this.state=E.IDLE;var e=this.levels[r.frag.level].details;if(e){this.loadFragment(r.frag,e,r.frag.start)}};r.onHandlerDestroying=function i(){this.stopLoad();t.prototype.onHandlerDestroying.call(this)};r.onHandlerDestroyed=function i(){this.state=E.STOPPED;this.hls.off(o["Events"].KEY_LOADED,this.onKeyLoaded,this);if(this.fragmentLoader){this.fragmentLoader.destroy()}if(this.decrypter){this.decrypter.destroy()}this.hls=this.log=this.warn=this.decrypter=this.fragmentLoader=this.fragmentTracker=null;t.prototype.onHandlerDestroyed.call(this)};r.loadKey=function t(i,r){this.log("Loading key for "+i.sn+" of ["+r.startSN+"-"+r.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+i.level);this.state=E.KEY_LOADING;this.fragCurrent=i;this.hls.trigger(o["Events"].KEY_LOADING,{frag:i})};r.loadFragment=function t(i,r,e){this._loadFragForPlayback(i,r,e)};r._loadFragForPlayback=function t(i,r,e){var n=this;var s=function t(r){if(n.fragContextChanged(i)){n.warn("Fragment "+i.sn+(r.part?" p: "+r.part.index:"")+" of level "+i.level+" was dropped during download.");n.fragmentTracker.removeFragment(i);return}i.stats.chunkCount++;n._handleFragmentLoadProgress(r)};this._doFragLoad(i,r,e,s).then((function(t){if(!t){return}n.fragLoadError=0;var r=n.state;if(n.fragContextChanged(i)){if(r===E.FRAG_LOADING||r===E.BACKTRACKING||!n.fragCurrent&&r===E.PARSING){n.fragmentTracker.removeFragment(i);n.state=E.IDLE}return}if("payload"in t){n.log("Loaded fragment "+i.sn+" of level "+i.level);n.hls.trigger(o["Events"].FRAG_LOADED,t);if(n.state===E.BACKTRACKING){n.fragmentTracker.backtrack(i,t);n.resetFragmentLoading(i);return}}n._handleFragmentLoadComplete(t)})).catch((function(t){n.warn(t);n.resetFragmentLoading(i)}))};r.flushMainBuffer=function t(i,r,e){if(e===void 0){e=null}if(!(i-r)){return}var n={startOffset:i,endOffset:r,type:e};this.fragLoadError=0;this.hls.trigger(o["Events"].BUFFER_FLUSHING,n)};r._loadInitSegment=function t(i){var r=this;this._doFragLoad(i).then((function(t){if(!t||r.fragContextChanged(i)||!r.levels){throw new Error("init load aborted")}return t})).then((function(t){var e=r.hls;var n=t.payload;var s=i.decryptdata;if(n&&n.byteLength>0&&s&&s.key&&s.iv&&s.method==="AES-128"){var a=self.performance.now();return r.decrypter.webCryptoDecrypt(new Uint8Array(n),s.key.buffer,s.iv.buffer).then((function(r){var n=self.performance.now();e.trigger(o["Events"].FRAG_DECRYPTED,{frag:i,payload:r,stats:{tstart:a,tdecrypt:n}});t.payload=r;return t}))}return t})).then((function(t){var e=r.fragCurrent,n=r.hls,s=r.levels;if(!s){throw new Error("init load aborted, missing levels")}var a=s[i.level].details;console.assert(a,"Level details are defined when init segment is loaded");var u=i.stats;r.state=E.IDLE;r.fragLoadError=0;i.data=new Uint8Array(t.payload);u.parsing.start=u.buffering.start=self.performance.now();u.parsing.end=u.buffering.end=self.performance.now();if(t.frag===e){n.trigger(o["Events"].FRAG_BUFFERED,{stats:u,frag:e,part:null,id:i.type})}r.tick()})).catch((function(t){r.warn(t);r.resetFragmentLoading(i)}))};r.fragContextChanged=function t(i){var r=this.fragCurrent;return!i||!r||i.level!==r.level||i.sn!==r.sn||i.urlId!==r.urlId};r.fragBufferedComplete=function t(i,r){var e=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+i.type+" sn: "+i.sn+(r?" part: "+r.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+i.level+" "+g["default"].toString(a["BufferHelper"].getBuffered(e)));this.state=E.IDLE;this.tick()};r._handleFragmentLoadComplete=function t(i){var r=this.transmuxer;if(!r){return}var e=i.frag,n=i.part,s=i.partsLoaded;var a=!s||s.length===0||s.some((function(t){return!t}));var u=new h["ChunkMetadata"](e.level,e.sn,e.stats.chunkCount+1,0,n?n.index:-1,!a);r.flush(u)};r._handleFragmentLoadProgress=function t(i){};r._doFragLoad=function t(i,r,n,s){var a=this;if(n===void 0){n=null}if(!this.levels){throw new Error("frag load aborted, missing levels")}n=Math.max(i.start,n||0);if(this.config.lowLatencyMode&&r){var u=r.partList;if(u&&s){if(n>i.end&&r.fragmentHint){i=r.fragmentHint}var f=this.getNextPart(u,i,n);if(f>-1){var h=u[f];this.log("Loading part sn: "+i.sn+" p: "+h.index+" cc: "+i.cc+" of playlist ["+r.startSN+"-"+r.endSN+"] parts [0-"+f+"-"+(u.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+i.level+", target: "+parseFloat(n.toFixed(3)));this.nextLoadPosition=h.start+h.duration;this.state=E.FRAG_LOADING;this.hls.trigger(o["Events"].FRAG_LOADING,{frag:i,part:u[f],targetBufferTime:n});return this.doFragPartsLoad(i,u,f,s).catch((function(t){return a.handleFragLoadError(t)}))}else if(!i.url||this.loadedEndOfParts(u,n)){return Promise.resolve(null)}}}this.log("Loading fragment "+i.sn+" cc: "+i.cc+" "+(r?"of ["+r.startSN+"-"+r.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+i.level+", target: "+parseFloat(n.toFixed(3)));if(Object(e["isFiniteNumber"])(i.sn)&&!this.bitrateTest){this.nextLoadPosition=i.start+i.duration}this.state=E.FRAG_LOADING;this.hls.trigger(o["Events"].FRAG_LOADING,{frag:i,targetBufferTime:n});return this.fragmentLoader.load(i,s).catch((function(t){return a.handleFragLoadError(t)}))};r.doFragPartsLoad=function t(i,r,e,n){var s=this;return new Promise((function(t,a){var u=[];var f=function e(f){var h=r[f];s.fragmentLoader.loadPart(i,h,n).then((function(n){u[h.index]=n;var a=n.part;s.hls.trigger(o["Events"].FRAG_LOADED,n);var l=r[f+1];if(l&&l.fragment===i){e(f+1)}else{return t({frag:i,part:a,partsLoaded:u})}})).catch(a)};f(e)}))};r.handleFragLoadError=function t(i){var r=i.data;if(r&&r.details===f["ErrorDetails"].INTERNAL_ABORTED){this.handleFragLoadAborted(r.frag,r.part)}else{this.hls.trigger(o["Events"].ERROR,r)}return null};r._handleTransmuxerFlush=function t(i){var r=this.getCurrentContext(i);if(!r||this.state!==E.PARSING){if(!this.fragCurrent){this.state=E.IDLE}return}var e=r.frag,n=r.part,s=r.level;var a=self.performance.now();e.stats.parsing.end=a;if(n){n.stats.parsing.end=a}this.updateLevelTiming(e,n,s,i.partial)};r.getCurrentContext=function t(i){var r=this.levels;var e=i.level,n=i.sn,s=i.part;if(!r||!r[e]){this.warn("Levels object was unset while buffering fragment "+n+" of level "+e+". The current chunk will not be buffered.");return null}var a=r[e];var u=s>-1?Object(d["getPartWith"])(a,n,s):null;var o=u?u.fragment:Object(d["getFragmentWithSN"])(a,n,this.fragCurrent);if(!o){return null}return{frag:o,part:u,level:a}};r.bufferFragmentData=function t(i,r,e,n){if(!i||this.state!==E.PARSING){return}var s=i.data1,a=i.data2;var u=s;if(s&&a){u=Object(l["appendUint8Array"])(s,a)}if(!u||!u.length){return}var f={type:i.type,frag:r,part:e,chunkMeta:n,parent:r.type,data:u};this.hls.trigger(o["Events"].BUFFER_APPENDING,f);if(i.dropped&&i.independent&&!e){this.flushBufferGap(r)}};r.flushBufferGap=function t(i){var r=this.media;if(!r){return}if(!a["BufferHelper"].isBuffered(r,r.currentTime)){this.flushMainBuffer(0,i.start);return}var e=r.currentTime;var n=a["BufferHelper"].bufferInfo(r,e,0);var s=i.duration;var u=Math.min(this.config.maxFragLookUpTolerance*2,s*.25);var o=Math.max(Math.min(i.start-u,n.end-u),e+u);if(i.start-o>u){this.flushMainBuffer(o,i.start)}};r.getFwdBufferInfo=function t(i,r){var n=this.config;var s=this.getLoadPosition();if(!Object(e["isFiniteNumber"])(s)){return null}var u=a["BufferHelper"].bufferInfo(i,s,n.maxBufferHole);if(u.len===0&&u.nextStart!==undefined){var o=this.fragmentTracker.getBufferedFrag(s,r);if(o&&u.nextStart<o.end){return a["BufferHelper"].bufferInfo(i,s,Math.max(u.nextStart,n.maxBufferHole))}}return u};r.getMaxBufferLength=function t(i){var r=this.config;var e;if(i){e=Math.max(8*r.maxBufferSize/i,r.maxBufferLength)}else{e=r.maxBufferLength}return Math.min(e,r.maxMaxBufferLength)};r.reduceMaxBufferLength=function t(i){var r=this.config;var e=i||r.maxBufferLength;if(r.maxMaxBufferLength>=e){r.maxMaxBufferLength/=2;this.warn("Reduce max buffer length to "+r.maxMaxBufferLength+"s");return true}return false};r.getNextFragment=function t(i,r){var e,n;var s=r.fragments;var a=s.length;if(!a){return null}var u=this.config;var o=s[0].start;var f;if(r.live){var h=u.initialLiveManifestSize;if(a<h){this.warn("Not enough fragments to start playback (have: "+a+", need: "+h+")");return null}if(!r.PTSKnown&&!this.startFragRequested&&this.startPosition===-1){f=this.getInitialLiveFragment(r,s);this.startPosition=f?this.hls.liveSyncPosition||f.start:i}}else if(i<=o){f=s[0]}if(!f){var l=u.lowLatencyMode?r.partEnd:r.fragmentEnd;f=this.getFragmentAtPosition(i,l,r)}if((e=f)!==null&&e!==void 0&&e.initSegment&&!((n=f)!==null&&n!==void 0&&n.initSegment.data)&&!this.bitrateTest){f=f.initSegment}return f};r.getNextPart=function t(i,r,e){var n=-1;var s=false;var a=true;for(var u=0,o=i.length;u<o;u++){var f=i[u];a=a&&!f.independent;if(n>-1&&e<f.start){break}var h=f.loaded;if(!h&&(s||f.independent||a)&&f.fragment===r){n=u}s=h}return n};r.loadedEndOfParts=function t(i,r){var e=i[i.length-1];return e&&r>e.start&&e.loaded};r.getInitialLiveFragment=function t(i,r){var e=this.fragPrevious;var n=null;if(e){if(i.hasProgramDateTime){this.log("Live playlist, switching playlist, load frag with same PDT: "+e.programDateTime);n=Object(v["findFragmentByPDT"])(r,e.endProgramDateTime,this.config.maxFragLookUpTolerance)}if(!n){var s=e.sn+1;if(s>=i.startSN&&s<=i.endSN){var a=r[s-i.startSN];if(e.cc===a.cc){n=a;this.log("Live playlist, switching playlist, load frag with next SN: "+n.sn)}}if(!n){n=Object(v["findFragWithCC"])(r,e.cc);if(n){this.log("Live playlist, switching playlist, load frag with same CC: "+n.sn)}}}}else{var u=this.hls.liveSyncPosition;if(u!==null){n=this.getFragmentAtPosition(u,this.bitrateTest?i.fragmentEnd:i.edge,i)}}return n};r.getFragmentAtPosition=function t(i,r,e){var n=this.config,a=this.fragPrevious;var u=e.fragments,o=e.endSN;var f=e.fragmentHint;var h=n.maxFragLookUpTolerance;var l=!!(n.lowLatencyMode&&e.partList&&f);if(l&&f&&!this.bitrateTest){u=u.concat(f);o=f.sn}var c;if(i<r){var d=i>r-h?0:h;c=Object(v["findFragmentByPTS"])(a,u,i,d)}else{c=u[u.length-1]}if(c){var m=c.sn-e.startSN;var p=a&&c.level===a.level;var g=u[m+1];var b=this.fragmentTracker.getState(c);if(b===s["FragmentState"].BACKTRACKED){c=null;var y=m;while(u[y]&&this.fragmentTracker.getState(u[y])===s["FragmentState"].BACKTRACKED){if(!a){c=u[--y]}else{c=u[y--]}}if(!c){c=g}}else if(a&&c.sn===a.sn&&!l){if(p){if(c.sn<o&&this.fragmentTracker.getState(g)!==s["FragmentState"].OK){this.log("SN "+c.sn+" just loaded, load next one: "+g.sn);c=g}else{c=null}}}}return c};r.synchronizeToLiveEdge=function t(i){var r=this.config,e=this.media;if(!e){return}var n=this.hls.liveSyncPosition;var s=e.currentTime;var a=i.fragments[0].start;var u=i.edge;var o=s>=a-r.maxFragLookUpTolerance&&s<=u;if(n!==null&&e.duration>n&&(s<n||!o)){var f=r.liveMaxLatencyDuration!==undefined?r.liveMaxLatencyDuration:r.liveMaxLatencyDurationCount*i.targetduration;if(!o&&e.readyState<4||s<u-f){if(!this.loadedmetadata){this.nextLoadPosition=n}if(e.readyState){this.warn("Playback: "+s.toFixed(3)+" is located too far from the end of live sliding playlist: "+u+", reset currentTime to : "+n.toFixed(3));e.currentTime=n}}}};r.alignPlaylists=function t(i,r){var n=this.levels,s=this.levelLastLoaded,a=this.fragPrevious;var u=s!==null?n[s]:null;var o=i.fragments.length;if(!o){this.warn("No fragments in live playlist");return 0}var f=i.fragments[0].start;var h=!r;var l=i.alignedSliding&&Object(e["isFiniteNumber"])(f);if(h||!l&&!f){Object(c["alignStream"])(a,u,i);var v=i.fragments[0].start;this.log("Live playlist sliding: "+v.toFixed(2)+" start-sn: "+(r?r.startSN:"na")+"->"+i.startSN+" prev-sn: "+(a?a.sn:"na")+" fragments: "+o);return v}return f};r.waitForCdnTuneIn=function t(i){var r=3;return i.live&&i.canBlockReload&&i.tuneInGoal>Math.max(i.partHoldBack,i.partTarget*r)};r.setStartPosition=function t(i,r){var n=this.startPosition;if(n<r){n=-1}if(n===-1||this.lastCurrentTime===-1){var s=i.startTimeOffset;if(Object(e["isFiniteNumber"])(s)){n=r+s;if(s<0){n+=i.totalduration}n=Math.min(Math.max(r,n),r+i.totalduration);this.log("Start time offset "+s+" found in playlist, adjust startPosition to "+n);this.startPosition=n}else if(i.live){n=this.hls.liveSyncPosition||r}else{this.startPosition=n=0}this.lastCurrentTime=n}this.nextLoadPosition=n};r.getLoadPosition=function t(){var i=this.media;var r=0;if(this.loadedmetadata&&i){r=i.currentTime}else if(this.nextLoadPosition){r=this.nextLoadPosition}return r};r.handleFragLoadAborted=function t(i,r){if(this.transmuxer&&i.sn!=="initSegment"&&i.stats.aborted){this.warn("Fragment "+i.sn+(r?" part"+r.index:"")+" of level "+i.level+" was aborted");this.resetFragmentLoading(i)}};r.resetFragmentLoading=function t(i){if(!this.fragCurrent||!this.fragContextChanged(i)){this.state=E.IDLE}};r.onFragmentOrKeyLoadError=function t(i,r){if(r.fatal){return}var e=r.frag;if(!e||e.type!==i){return}var n=this.fragCurrent;console.assert(n&&e.sn===n.sn&&e.level===n.level&&e.urlId===n.urlId,"Frag load error must match current frag to retry");var s=this.config;if(this.fragLoadError+1<=s.fragLoadingMaxRetry){if(this.resetLiveStartWhenNotLoaded(e.level)){return}var a=Math.min(Math.pow(2,this.fragLoadError)*s.fragLoadingRetryDelay,s.fragLoadingMaxRetryTimeout);this.warn("Fragment "+e.sn+" of "+i+" "+e.level+" failed to load, retrying in "+a+"ms");this.retryDate=self.performance.now()+a;this.fragLoadError++;this.state=E.FRAG_LOADING_WAITING_RETRY}else if(r.levelRetry){if(i===b["PlaylistLevelType"].AUDIO){this.fragCurrent=null}this.fragLoadError=0;this.state=E.IDLE}else{u["logger"].error(r.details+" reaches max retry, redispatch as fatal ...");r.fatal=true;this.hls.stopLoad();this.state=E.ERROR}};r.afterBufferFlushed=function t(i,r,e){if(!i){return}var n=a["BufferHelper"].getBuffered(i);this.fragmentTracker.detectEvictedFragments(r,n,e);if(this.state===E.ENDED){this.resetLoadingState()}};r.resetLoadingState=function t(){this.fragCurrent=null;this.fragPrevious=null;this.state=E.IDLE};r.resetLiveStartWhenNotLoaded=function t(i){if(!this.loadedmetadata){this.startFragRequested=false;var r=this.levels?this.levels[i].details:null;if(r!==null&&r!==void 0&&r.live){this.startPosition=-1;this.setStartPosition(r,0);this.resetLoadingState();return true}this.nextLoadPosition=this.startPosition}return false};r.updateLevelTiming=function t(i,r,e,n){var s=this;var a=e.details;console.assert(!!a,"level.details must be defined");var u=Object.keys(i.elementaryStreams).reduce((function(t,r){var u=i.elementaryStreams[r];if(u){var f=u.endPTS-u.startPTS;if(f<=0){s.warn("Could not parse fragment "+i.sn+" "+r+" duration reliably ("+f+") resetting transmuxer to fallback to playlist timing");s.resetTransmuxer();return t||false}var h=n?0:Object(d["updateFragPTSDTS"])(a,i,u.startPTS,u.endPTS,u.startDTS,u.endDTS);s.hls.trigger(o["Events"].LEVEL_PTS_UPDATED,{details:a,level:e,drift:h,type:r,frag:i,start:u.startPTS,end:u.endPTS});return true}return t}),false);if(u){this.state=E.PARSED;this.hls.trigger(o["Events"].FRAG_PARSED,{frag:i,part:r})}else{this.resetLoadingState()}};r.resetTransmuxer=function t(){if(this.transmuxer){this.transmuxer.destroy();this.transmuxer=null}};w(i,[{key:"state",get:function t(){return this._state},set:function t(i){var r=this._state;if(r!==i){this._state=i;this.log(r+"->"+i)}}}]);return i}(n["default"])},"./src/controller/buffer-controller.ts":
|
|
38
|
+
/*!*********************************************!*\
|
|
39
|
+
!*** ./src/controller/buffer-controller.ts ***!
|
|
40
|
+
\*********************************************/
|
|
41
|
+
/*! exports provided: default */function(t,i,r){r.r(i);r.d(i,"default",(function(){return v}));var e=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");var n=r(/*! ../events */"./src/events.ts");var s=r(/*! ../utils/logger */"./src/utils/logger.ts");var a=r(/*! ../errors */"./src/errors.ts");var u=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts");var o=r(/*! ../utils/mediasource-helper */"./src/utils/mediasource-helper.ts");var f=r(/*! ../loader/fragment */"./src/loader/fragment.ts");var h=r(/*! ./buffer-operation-queue */"./src/controller/buffer-operation-queue.ts");var l=Object(o["getMediaSource"])();var c=/([ha]vc.)(?:\.[^.,]+)+/;var v=function(){function t(t){var i=this;this.details=null;this._objectUrl=null;this.operationQueue=void 0;this.listeners=void 0;this.hls=void 0;this.bufferCodecEventsExpected=0;this._bufferCodecEventsTotal=0;this.media=null;this.mediaSource=null;this.appendError=0;this.tracks={};this.pendingTracks={};this.sourceBuffer=void 0;this._onMediaSourceOpen=function(){var t=i.hls,r=i.media,e=i.mediaSource;s["logger"].log("[buffer-controller]: Media source opened");if(r){i.updateMediaElementDuration();t.trigger(n["Events"].MEDIA_ATTACHED,{media:r})}if(e){e.removeEventListener("sourceopen",i._onMediaSourceOpen)}i.checkPendingTracks()};this._onMediaSourceClose=function(){s["logger"].log("[buffer-controller]: Media source closed")};this._onMediaSourceEnded=function(){s["logger"].log("[buffer-controller]: Media source ended")};this.hls=t;this._initSourceBuffer();this.registerListeners()}var i=t.prototype;i.hasSourceTypes=function t(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0};i.destroy=function t(){this.unregisterListeners();this.details=null};i.registerListeners=function t(){var i=this.hls;i.on(n["Events"].MEDIA_ATTACHING,this.onMediaAttaching,this);i.on(n["Events"].MEDIA_DETACHING,this.onMediaDetaching,this);i.on(n["Events"].MANIFEST_PARSED,this.onManifestParsed,this);i.on(n["Events"].BUFFER_RESET,this.onBufferReset,this);i.on(n["Events"].BUFFER_APPENDING,this.onBufferAppending,this);i.on(n["Events"].BUFFER_CODECS,this.onBufferCodecs,this);i.on(n["Events"].BUFFER_EOS,this.onBufferEos,this);i.on(n["Events"].BUFFER_FLUSHING,this.onBufferFlushing,this);i.on(n["Events"].LEVEL_UPDATED,this.onLevelUpdated,this);i.on(n["Events"].FRAG_PARSED,this.onFragParsed,this);i.on(n["Events"].FRAG_CHANGED,this.onFragChanged,this)};i.unregisterListeners=function t(){var i=this.hls;i.off(n["Events"].MEDIA_ATTACHING,this.onMediaAttaching,this);i.off(n["Events"].MEDIA_DETACHING,this.onMediaDetaching,this);i.off(n["Events"].MANIFEST_PARSED,this.onManifestParsed,this);i.off(n["Events"].BUFFER_RESET,this.onBufferReset,this);i.off(n["Events"].BUFFER_APPENDING,this.onBufferAppending,this);i.off(n["Events"].BUFFER_CODECS,this.onBufferCodecs,this);i.off(n["Events"].BUFFER_EOS,this.onBufferEos,this);i.off(n["Events"].BUFFER_FLUSHING,this.onBufferFlushing,this);i.off(n["Events"].LEVEL_UPDATED,this.onLevelUpdated,this);i.off(n["Events"].FRAG_PARSED,this.onFragParsed,this);i.off(n["Events"].FRAG_CHANGED,this.onFragChanged,this)};i._initSourceBuffer=function t(){this.sourceBuffer={};this.operationQueue=new h["default"](this.sourceBuffer);this.listeners={audio:[],video:[],audiovideo:[]}};i.onManifestParsed=function t(i,r){var e=2;if(r.audio&&!r.video||!r.altAudio){e=1}this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=e;this.details=null;s["logger"].log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")};i.onMediaAttaching=function t(i,r){var e=this.media=r.media;if(e&&l){var n=this.mediaSource=new l;n.addEventListener("sourceopen",this._onMediaSourceOpen);n.addEventListener("sourceended",this._onMediaSourceEnded);n.addEventListener("sourceclose",this._onMediaSourceClose);e.src=self.URL.createObjectURL(n);this._objectUrl=e.src}};i.onMediaDetaching=function t(){var i=this.media,r=this.mediaSource,e=this._objectUrl;if(r){s["logger"].log("[buffer-controller]: media source detaching");if(r.readyState==="open"){try{r.endOfStream()}catch(t){s["logger"].warn("[buffer-controller]: onMediaDetaching: "+t.message+" while calling endOfStream")}}this.onBufferReset();r.removeEventListener("sourceopen",this._onMediaSourceOpen);r.removeEventListener("sourceended",this._onMediaSourceEnded);r.removeEventListener("sourceclose",this._onMediaSourceClose);if(i){if(e){self.URL.revokeObjectURL(e)}if(i.src===e){i.removeAttribute("src");i.load()}else{s["logger"].warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")}}this.mediaSource=null;this.media=null;this._objectUrl=null;this.bufferCodecEventsExpected=this._bufferCodecEventsTotal;this.pendingTracks={};this.tracks={}}this.hls.trigger(n["Events"].MEDIA_DETACHED,undefined)};i.onBufferReset=function t(){var i=this;this.getSourceBufferTypes().forEach((function(t){var r=i.sourceBuffer[t];try{if(r){i.removeBufferListeners(t);if(i.mediaSource){i.mediaSource.removeSourceBuffer(r)}i.sourceBuffer[t]=undefined}}catch(i){s["logger"].warn("[buffer-controller]: Failed to reset the "+t+" buffer",i)}}));this._initSourceBuffer()};i.onBufferCodecs=function t(i,r){var e=this;var n=this.getSourceBufferTypes().length;Object.keys(r).forEach((function(t){if(n){var i=e.tracks[t];if(i&&typeof i.buffer.changeType==="function"){var s=r[t],a=s.codec,u=s.levelCodec,o=s.container;var f=(i.levelCodec||i.codec).replace(c,"$1");var h=(u||a).replace(c,"$1");if(f!==h){var l=o+";codecs="+(u||a);e.appendChangeType(t,l)}}}else{e.pendingTracks[t]=r[t]}}));if(n){return}this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0);if(this.mediaSource&&this.mediaSource.readyState==="open"){this.checkPendingTracks()}};i.appendChangeType=function t(i,r){var e=this;var n=this.operationQueue;var a={execute:function t(){var a=e.sourceBuffer[i];if(a){s["logger"].log("[buffer-controller]: changing "+i+" sourceBuffer type to "+r);a.changeType(r)}n.shiftAndExecuteNext(i)},onStart:function t(){},onComplete:function t(){},onError:function t(r){s["logger"].warn("[buffer-controller]: Failed to change "+i+" SourceBuffer type",r)}};n.append(a,i)};i.onBufferAppending=function t(i,r){var e=this;var o=this.hls,f=this.operationQueue,h=this.tracks;var l=r.data,c=r.type,v=r.frag,d=r.part,m=r.chunkMeta;var p=m.buffering[c];var g=self.performance.now();p.start=g;var b=v.stats.buffering;var y=d?d.stats.buffering:null;if(b.start===0){b.start=g}if(y&&y.start===0){y.start=g}var w=h.audio;var A=c==="audio"&&m.id===1&&(w===null||w===void 0?void 0:w.container)==="audio/mpeg";var k={execute:function t(){p.executeStart=self.performance.now();if(A){var i=e.sourceBuffer[c];if(i){var r=v.start-i.timestampOffset;if(Math.abs(r)>=.1){s["logger"].log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+v.start+" (delta: "+r+") sn: "+v.sn+")");i.timestampOffset=v.start}}}e.appendExecutor(l,c)},onStart:function t(){},onComplete:function t(){var i=self.performance.now();p.executeEnd=p.end=i;if(b.first===0){b.first=i}if(y&&y.first===0){y.first=i}var r=e.sourceBuffer;var s={};for(var a in r){s[a]=u["BufferHelper"].getBuffered(r[a])}e.appendError=0;e.hls.trigger(n["Events"].BUFFER_APPENDED,{type:c,frag:v,part:d,chunkMeta:m,parent:v.type,timeRanges:s})},onError:function t(i){s["logger"].error("[buffer-controller]: Error encountered while trying to append to the "+c+" SourceBuffer",i);var r={type:a["ErrorTypes"].MEDIA_ERROR,parent:v.type,details:a["ErrorDetails"].BUFFER_APPEND_ERROR,err:i,fatal:false};if(i.code===DOMException.QUOTA_EXCEEDED_ERR){r.details=a["ErrorDetails"].BUFFER_FULL_ERROR}else{e.appendError++;r.details=a["ErrorDetails"].BUFFER_APPEND_ERROR;if(e.appendError>o.config.appendErrorMaxRetry){s["logger"].error("[buffer-controller]: Failed "+o.config.appendErrorMaxRetry+" times to append segment in sourceBuffer");r.fatal=true}}o.trigger(n["Events"].ERROR,r)}};f.append(k,c)};i.onBufferFlushing=function t(i,r){var e=this;var a=this.operationQueue;var u=function t(i){return{execute:e.removeExecutor.bind(e,i,r.startOffset,r.endOffset),onStart:function t(){},onComplete:function t(){e.hls.trigger(n["Events"].BUFFER_FLUSHED,{type:i})},onError:function t(r){s["logger"].warn("[buffer-controller]: Failed to remove from "+i+" SourceBuffer",r)}}};if(r.type){a.append(u(r.type),r.type)}else{this.getSourceBufferTypes().forEach((function(t){a.append(u(t),t)}))}};i.onFragParsed=function t(i,r){var e=this;var a=r.frag,u=r.part;var o=[];var h=u?u.elementaryStreams:a.elementaryStreams;if(h[f["ElementaryStreamTypes"].AUDIOVIDEO]){o.push("audiovideo")}else{if(h[f["ElementaryStreamTypes"].AUDIO]){o.push("audio")}if(h[f["ElementaryStreamTypes"].VIDEO]){o.push("video")}}var l=function t(){var i=self.performance.now();a.stats.buffering.end=i;if(u){u.stats.buffering.end=i}var r=u?u.stats:a.stats;e.hls.trigger(n["Events"].FRAG_BUFFERED,{frag:a,part:u,stats:r,id:a.type})};if(o.length===0){s["logger"].warn("Fragments must have at least one ElementaryStreamType set. type: "+a.type+" level: "+a.level+" sn: "+a.sn)}this.blockBuffers(l,o)};i.onFragChanged=function t(i,r){this.flushBackBuffer()};i.onBufferEos=function t(i,r){var e=this;var n=this.getSourceBufferTypes().reduce((function(t,i){var n=e.sourceBuffer[i];if(!r.type||r.type===i){if(n&&!n.ended){n.ended=true;s["logger"].log("[buffer-controller]: "+i+" sourceBuffer now EOS")}}return t&&!!(!n||n.ended)}),true);if(n){this.blockBuffers((function(){var t=e.mediaSource;if(!t||t.readyState!=="open"){return}t.endOfStream()}))}};i.onLevelUpdated=function t(i,r){var e=r.details;if(!e.fragments.length){return}this.details=e;if(this.getSourceBufferTypes().length){this.blockBuffers(this.updateMediaElementDuration.bind(this))}else{this.updateMediaElementDuration()}};i.flushBackBuffer=function t(){var i=this.hls,r=this.details,s=this.media,a=this.sourceBuffer;if(!s||r===null){return}var o=this.getSourceBufferTypes();if(!o.length){return}var f=r.live&&i.config.liveBackBufferLength!==null?i.config.liveBackBufferLength:i.config.backBufferLength;if(!Object(e["isFiniteNumber"])(f)||f<0){return}var h=s.currentTime;var l=r.levelTargetDuration;var c=Math.max(f,l);var v=Math.floor(h/l)*l-c;o.forEach((function(t){var e=a[t];if(e){var s=u["BufferHelper"].getBuffered(e);if(s.length>0&&v>s.start(0)){i.trigger(n["Events"].BACK_BUFFER_REACHED,{bufferEnd:v});if(r.live){i.trigger(n["Events"].LIVE_BACK_BUFFER_REACHED,{bufferEnd:v})}i.trigger(n["Events"].BUFFER_FLUSHING,{startOffset:0,endOffset:v,type:t})}}}))};i.updateMediaElementDuration=function t(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open"){return}var i=this.details,r=this.hls,n=this.media,a=this.mediaSource;var u=i.fragments[0].start+i.totalduration;var o=n.duration;var f=Object(e["isFiniteNumber"])(a.duration)?a.duration:0;if(i.live&&r.config.liveDurationInfinity){s["logger"].log("[buffer-controller]: Media Source duration is set to Infinity");a.duration=Infinity;this.updateSeekableRange(i)}else if(u>f&&u>o||!Object(e["isFiniteNumber"])(o)){s["logger"].log("[buffer-controller]: Updating Media Source duration to "+u.toFixed(3));a.duration=u}};i.updateSeekableRange=function t(i){var r=this.mediaSource;var e=i.fragments;var n=e.length;if(n&&i.live&&r!==null&&r!==void 0&&r.setLiveSeekableRange){var s=Math.max(0,e[0].start);var a=Math.max(s,s+i.totalduration);r.setLiveSeekableRange(s,a)}};i.checkPendingTracks=function t(){var i=this.bufferCodecEventsExpected,r=this.operationQueue,e=this.pendingTracks;var s=Object.keys(e).length;if(s&&!i||s===2){this.createSourceBuffers(e);this.pendingTracks={};var u=this.getSourceBufferTypes();if(u.length===0){this.hls.trigger(n["Events"].ERROR,{type:a["ErrorTypes"].MEDIA_ERROR,details:a["ErrorDetails"].BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:true,reason:"could not create source buffer for media codec(s)"});return}u.forEach((function(t){r.executeNext(t)}))}};i.createSourceBuffers=function t(i){var r=this.sourceBuffer,e=this.mediaSource;if(!e){throw Error("createSourceBuffers called when mediaSource was null")}var u=0;for(var o in i){if(!r[o]){var f=i[o];if(!f){throw Error("source buffer exists for track "+o+", however track does not")}var h=f.levelCodec||f.codec;var l=f.container+";codecs="+h;s["logger"].log("[buffer-controller]: creating sourceBuffer("+l+")");try{var c=r[o]=e.addSourceBuffer(l);var v=o;this.addBufferListener(v,"updatestart",this._onSBUpdateStart);this.addBufferListener(v,"updateend",this._onSBUpdateEnd);this.addBufferListener(v,"error",this._onSBUpdateError);this.tracks[o]={buffer:c,codec:h,container:f.container,levelCodec:f.levelCodec,id:f.id};u++}catch(t){s["logger"].error("[buffer-controller]: error while trying to add sourceBuffer: "+t.message);this.hls.trigger(n["Events"].ERROR,{type:a["ErrorTypes"].MEDIA_ERROR,details:a["ErrorDetails"].BUFFER_ADD_CODEC_ERROR,fatal:false,error:t,mimeType:l})}}}if(u){this.hls.trigger(n["Events"].BUFFER_CREATED,{tracks:this.tracks})}};i._onSBUpdateStart=function t(i){var r=this.operationQueue;var e=r.current(i);e.onStart()};i._onSBUpdateEnd=function t(i){var r=this.operationQueue;var e=r.current(i);e.onComplete();r.shiftAndExecuteNext(i)};i._onSBUpdateError=function t(i,r){s["logger"].error("[buffer-controller]: "+i+" SourceBuffer error",r);this.hls.trigger(n["Events"].ERROR,{type:a["ErrorTypes"].MEDIA_ERROR,details:a["ErrorDetails"].BUFFER_APPENDING_ERROR,fatal:false});var e=this.operationQueue.current(i);if(e){e.onError(r)}};i.removeExecutor=function t(i,r,n){var a=this.media,u=this.mediaSource,o=this.operationQueue,f=this.sourceBuffer;var h=f[i];if(!a||!u||!h){s["logger"].warn("[buffer-controller]: Attempting to remove from the "+i+" SourceBuffer, but it does not exist");o.shiftAndExecuteNext(i);return}var l=Object(e["isFiniteNumber"])(a.duration)?a.duration:Infinity;var c=Object(e["isFiniteNumber"])(u.duration)?u.duration:Infinity;var v=Math.max(0,r);var d=Math.min(n,l,c);if(d>v){s["logger"].log("[buffer-controller]: Removing ["+v+","+d+"] from the "+i+" SourceBuffer");console.assert(!h.updating,i+" sourceBuffer must not be updating");h.remove(v,d)}else{o.shiftAndExecuteNext(i)}};i.appendExecutor=function t(i,r){var e=this.operationQueue,n=this.sourceBuffer;var a=n[r];if(!a){s["logger"].warn("[buffer-controller]: Attempting to append to the "+r+" SourceBuffer, but it does not exist");e.shiftAndExecuteNext(r);return}a.ended=false;console.assert(!a.updating,r+" sourceBuffer must not be updating");a.appendBuffer(i)};i.blockBuffers=function t(i,r){var e=this;if(r===void 0){r=this.getSourceBufferTypes()}if(!r.length){s["logger"].log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist");return}var n=this.operationQueue;var a=r.map((function(t){return n.appendBlocker(t)}));Promise.all(a).then((function(){i();r.forEach((function(t){var i=e.sourceBuffer[t];if(!i||!i.updating){n.shiftAndExecuteNext(t)}}))}))};i.getSourceBufferTypes=function t(){return Object.keys(this.sourceBuffer)};i.addBufferListener=function t(i,r,e){var n=this.sourceBuffer[i];if(!n){return}var s=e.bind(this,i);this.listeners[i].push({event:r,listener:s});n.addEventListener(r,s)};i.removeBufferListeners=function t(i){var r=this.sourceBuffer[i];if(!r){return}this.listeners[i].forEach((function(t){r.removeEventListener(t.event,t.listener)}))};return t}()},"./src/controller/buffer-operation-queue.ts":
|
|
42
|
+
/*!**************************************************!*\
|
|
43
|
+
!*** ./src/controller/buffer-operation-queue.ts ***!
|
|
44
|
+
\**************************************************/
|
|
45
|
+
/*! exports provided: default */function(t,i,r){r.r(i);r.d(i,"default",(function(){return n}));var e=r(/*! ../utils/logger */"./src/utils/logger.ts");var n=function(){function t(t){this.buffers=void 0;this.queues={video:[],audio:[],audiovideo:[]};this.buffers=t}var i=t.prototype;i.append=function t(i,r){var e=this.queues[r];e.push(i);if(e.length===1&&this.buffers[r]){this.executeNext(r)}};i.insertAbort=function t(i,r){var e=this.queues[r];e.unshift(i);this.executeNext(r)};i.appendBlocker=function t(i){var r;var e=new Promise((function(t){r=t}));var n={execute:r,onStart:function t(){},onComplete:function t(){},onError:function t(){}};this.append(n,i);return e};i.executeNext=function t(i){var r=this.buffers,n=this.queues;var s=r[i];var a=n[i];if(a.length){var u=a[0];try{u.execute()}catch(t){e["logger"].warn("[buffer-operation-queue]: Unhandled exception executing the current operation");u.onError(t);if(!s||!s.updating){a.shift();this.executeNext(i)}}}};i.shiftAndExecuteNext=function t(i){this.queues[i].shift();this.executeNext(i)};i.current=function t(i){return this.queues[i][0]};return t}()},"./src/controller/cap-level-controller.ts":
|
|
46
|
+
/*!************************************************!*\
|
|
47
|
+
!*** ./src/controller/cap-level-controller.ts ***!
|
|
48
|
+
\************************************************/
|
|
49
|
+
/*! exports provided: default */function(t,i,r){r.r(i);var e=r(/*! ../events */"./src/events.ts");function n(t,i){for(var r=0;r<i.length;r++){var e=i[r];e.enumerable=e.enumerable||false;e.configurable=true;if("value"in e)e.writable=true;Object.defineProperty(t,e.key,e)}}function s(t,i,r){if(i)n(t.prototype,i);if(r)n(t,r);return t}var a=function(){function t(t){this.autoLevelCapping=void 0;this.firstLevel=void 0;this.media=void 0;this.restrictedLevels=void 0;this.timer=void 0;this.hls=void 0;this.streamController=void 0;this.clientRect=void 0;this.hls=t;this.autoLevelCapping=Number.POSITIVE_INFINITY;this.firstLevel=-1;this.media=null;this.restrictedLevels=[];this.timer=undefined;this.clientRect=null;this.registerListeners()}var i=t.prototype;i.setStreamController=function t(i){this.streamController=i};i.destroy=function t(){this.unregisterListener();if(this.hls.config.capLevelToPlayerSize){this.stopCapping()}this.media=null;this.clientRect=null;this.hls=this.streamController=null};i.registerListeners=function t(){var i=this.hls;i.on(e["Events"].FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this);i.on(e["Events"].MEDIA_ATTACHING,this.onMediaAttaching,this);i.on(e["Events"].MANIFEST_PARSED,this.onManifestParsed,this);i.on(e["Events"].BUFFER_CODECS,this.onBufferCodecs,this);i.on(e["Events"].MEDIA_DETACHING,this.onMediaDetaching,this)};i.unregisterListener=function t(){var i=this.hls;i.off(e["Events"].FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this);i.off(e["Events"].MEDIA_ATTACHING,this.onMediaAttaching,this);i.off(e["Events"].MANIFEST_PARSED,this.onManifestParsed,this);i.off(e["Events"].BUFFER_CODECS,this.onBufferCodecs,this);i.off(e["Events"].MEDIA_DETACHING,this.onMediaDetaching,this)};i.onFpsDropLevelCapping=function i(r,e){if(t.isLevelAllowed(e.droppedLevel,this.restrictedLevels)){this.restrictedLevels.push(e.droppedLevel)}};i.onMediaAttaching=function t(i,r){this.media=r.media instanceof HTMLVideoElement?r.media:null};i.onManifestParsed=function t(i,r){var e=this.hls;this.restrictedLevels=[];this.firstLevel=r.firstLevel;if(e.config.capLevelToPlayerSize&&r.video){this.startCapping()}};i.onBufferCodecs=function t(i,r){var e=this.hls;if(e.config.capLevelToPlayerSize&&r.video){this.startCapping()}};i.onMediaDetaching=function t(){this.stopCapping()};i.detectPlayerSize=function t(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var i=this.hls.levels;if(i.length){var r=this.hls;r.autoLevelCapping=this.getMaxLevel(i.length-1);if(r.autoLevelCapping>this.autoLevelCapping&&this.streamController){this.streamController.nextLevelSwitch()}this.autoLevelCapping=r.autoLevelCapping}}};i.getMaxLevel=function i(r){var e=this;var n=this.hls.levels;if(!n.length){return-1}var s=n.filter((function(i,n){return t.isLevelAllowed(n,e.restrictedLevels)&&n<=r}));this.clientRect=null;return t.getMaxLevelByMediaSize(s,this.mediaWidth,this.mediaHeight)};i.startCapping=function t(){if(this.timer){return}this.autoLevelCapping=Number.POSITIVE_INFINITY;this.hls.firstLevel=this.getMaxLevel(this.firstLevel);self.clearInterval(this.timer);this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3);this.detectPlayerSize()};i.stopCapping=function t(){this.restrictedLevels=[];this.firstLevel=-1;this.autoLevelCapping=Number.POSITIVE_INFINITY;if(this.timer){self.clearInterval(this.timer);this.timer=undefined}};i.getDimensions=function t(){if(this.clientRect){return this.clientRect}var i=this.media;var r={width:0,height:0};if(i){var e=i.getBoundingClientRect();r.width=e.width;r.height=e.height;if(!r.width&&!r.height){r.width=e.right-e.left||i.width||0;r.height=e.bottom-e.top||i.height||0}}this.clientRect=r;return r};t.isLevelAllowed=function t(i,r){if(r===void 0){r=[]}return r.indexOf(i)===-1};t.getMaxLevelByMediaSize=function t(i,r,e){if(!i||!i.length){return-1}var n=function t(i,r){if(!r){return true}return i.width!==r.width||i.height!==r.height};var s=i.length-1;for(var a=0;a<i.length;a+=1){var u=i[a];if((u.width>=r||u.height>=e)&&n(u,i[a+1])){s=a;break}}return s};s(t,[{key:"mediaWidth",get:function i(){return this.getDimensions().width*t.contentScaleFactor}},{key:"mediaHeight",get:function i(){return this.getDimensions().height*t.contentScaleFactor}}],[{key:"contentScaleFactor",get:function t(){var i=1;try{i=self.devicePixelRatio}catch(t){}return i}}]);return t}();i["default"]=a},"./src/controller/cmcd-controller.ts":
|
|
50
|
+
/*!*******************************************!*\
|
|
51
|
+
!*** ./src/controller/cmcd-controller.ts ***!
|
|
52
|
+
\*******************************************/
|
|
53
|
+
/*! exports provided: default */function(t,i,r){r.r(i);r.d(i,"default",(function(){return v}));var e=r(/*! ../events */"./src/events.ts");var n=r(/*! ../types/cmcd */"./src/types/cmcd.ts");var s=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts");var a=r(/*! ../utils/logger */"./src/utils/logger.ts");function u(t,i){for(var r=0;r<i.length;r++){var e=i[r];e.enumerable=e.enumerable||false;e.configurable=true;if("value"in e)e.writable=true;Object.defineProperty(t,e.key,e)}}function o(t,i,r){if(i)u(t.prototype,i);if(r)u(t,r);return t}function f(t,i){var r=typeof Symbol!=="undefined"&&t[Symbol.iterator]||t["@@iterator"];if(r)return(r=r.call(t)).next.bind(r);if(Array.isArray(t)||(r=h(t))||i&&t&&typeof t.length==="number"){if(r)t=r;var e=0;return function(){if(e>=t.length)return{done:true};return{done:false,value:t[e++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function h(t,i){if(!t)return;if(typeof t==="string")return l(t,i);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor)r=t.constructor.name;if(r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return l(t,i)}function l(t,i){if(i==null||i>t.length)i=t.length;for(var r=0,e=new Array(i);r<i;r++){e[r]=t[r]}return e}function c(){c=Object.assign||function(t){for(var i=1;i<arguments.length;i++){var r=arguments[i];for(var e in r){if(Object.prototype.hasOwnProperty.call(r,e)){t[e]=r[e]}}}return t};return c.apply(this,arguments)}var v=function(){function t(i){var r=this;this.hls=void 0;this.config=void 0;this.media=void 0;this.sid=void 0;this.cid=void 0;this.useHeaders=false;this.initialized=false;this.starved=false;this.buffering=true;this.audioBuffer=void 0;this.videoBuffer=void 0;this.onWaiting=function(){if(r.initialized){r.starved=true}r.buffering=true};this.onPlaying=function(){if(!r.initialized){r.initialized=true}r.buffering=false};this.applyPlaylistData=function(t){try{r.apply(t,{ot:n["CMCDObjectType"].MANIFEST,su:!r.initialized})}catch(t){a["logger"].warn("Could not generate manifest CMCD data.",t)}};this.applyFragmentData=function(t){try{var i=t.frag;var e=r.hls.levels[i.level];var s=r.getObjectType(i);var u={d:i.duration*1e3,ot:s};if(s===n["CMCDObjectType"].VIDEO||s===n["CMCDObjectType"].AUDIO||s==n["CMCDObjectType"].MUXED){u.br=e.bitrate/1e3;u.tb=r.getTopBandwidth(s)/1e3;u.bl=r.getBufferLength(s)}r.apply(t,u)}catch(t){a["logger"].warn("Could not generate segment CMCD data.",t)}};this.hls=i;var e=this.config=i.config;var s=e.cmcd;if(s!=null){e.pLoader=this.createPlaylistLoader();e.fLoader=this.createFragmentLoader();this.sid=s.sessionId||t.uuid();this.cid=s.contentId;this.useHeaders=s.useHeaders===true;this.registerListeners()}}var i=t.prototype;i.registerListeners=function t(){var i=this.hls;i.on(e["Events"].MEDIA_ATTACHED,this.onMediaAttached,this);i.on(e["Events"].MEDIA_DETACHED,this.onMediaDetached,this);i.on(e["Events"].BUFFER_CREATED,this.onBufferCreated,this)};i.unregisterListeners=function t(){var i=this.hls;i.off(e["Events"].MEDIA_ATTACHED,this.onMediaAttached,this);i.off(e["Events"].MEDIA_DETACHED,this.onMediaDetached,this);i.off(e["Events"].BUFFER_CREATED,this.onBufferCreated,this);this.onMediaDetached()};i.destroy=function t(){this.unregisterListeners();this.hls=this.config=this.audioBuffer=this.videoBuffer=null};i.onMediaAttached=function t(i,r){this.media=r.media;this.media.addEventListener("waiting",this.onWaiting);this.media.addEventListener("playing",this.onPlaying)};i.onMediaDetached=function t(){if(!this.media){return}this.media.removeEventListener("waiting",this.onWaiting);this.media.removeEventListener("playing",this.onPlaying);this.media=null};i.onBufferCreated=function t(i,r){var e,n;this.audioBuffer=(e=r.tracks.audio)===null||e===void 0?void 0:e.buffer;this.videoBuffer=(n=r.tracks.video)===null||n===void 0?void 0:n.buffer};i.createData=function t(){var i;return{v:n["CMCDVersion"],sf:n["CMCDStreamingFormat"].HLS,sid:this.sid,cid:this.cid,pr:(i=this.media)===null||i===void 0?void 0:i.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}};i.apply=function i(r,e){if(e===void 0){e={}}c(e,this.createData());var s=e.ot===n["CMCDObjectType"].INIT||e.ot===n["CMCDObjectType"].VIDEO||e.ot===n["CMCDObjectType"].MUXED;if(this.starved&&s){e.bs=true;e.su=true;this.starved=false}if(e.su==null){e.su=this.buffering}if(this.useHeaders){var a=t.toHeaders(e);if(!Object.keys(a).length){return}if(!r.headers){r.headers={}}c(r.headers,a)}else{var u=t.toQuery(e);if(!u){return}r.url=t.appendQueryToUri(r.url,u)}};i.getObjectType=function t(i){var r=i.type;if(r==="subtitle"){return n["CMCDObjectType"].TIMED_TEXT}if(i.sn==="initSegment"){return n["CMCDObjectType"].INIT}if(r==="audio"){return n["CMCDObjectType"].AUDIO}if(r==="main"){if(!this.hls.audioTracks.length){return n["CMCDObjectType"].MUXED}return n["CMCDObjectType"].VIDEO}return undefined};i.getTopBandwidth=function t(i){var r=0;var e;var s=this.hls;if(i===n["CMCDObjectType"].AUDIO){e=s.audioTracks}else{var a=s.maxAutoLevel;var u=a>-1?a+1:s.levels.length;e=s.levels.slice(0,u)}for(var o=f(e),h;!(h=o()).done;){var l=h.value;if(l.bitrate>r){r=l.bitrate}}return r>0?r:NaN};i.getBufferLength=function t(i){var r=this.hls.media;var e=i===n["CMCDObjectType"].AUDIO?this.audioBuffer:this.videoBuffer;if(!e||!r){return NaN}var a=s["BufferHelper"].bufferInfo(e,r.currentTime,this.config.maxBufferHole);return a.len*1e3};i.createPlaylistLoader=function t(){var i=this.config.pLoader;var r=this.applyPlaylistData;var e=i||this.config.loader;return function(){function t(t){this.loader=void 0;this.loader=new e(t)}var i=t.prototype;i.destroy=function t(){this.loader.destroy()};i.abort=function t(){this.loader.abort()};i.load=function t(i,e,n){r(i);this.loader.load(i,e,n)};o(t,[{key:"stats",get:function t(){return this.loader.stats}},{key:"context",get:function t(){return this.loader.context}}]);return t}()};i.createFragmentLoader=function t(){var i=this.config.fLoader;var r=this.applyFragmentData;var e=i||this.config.loader;return function(){function t(t){this.loader=void 0;this.loader=new e(t)}var i=t.prototype;i.destroy=function t(){this.loader.destroy()};i.abort=function t(){this.loader.abort()};i.load=function t(i,e,n){r(i);this.loader.load(i,e,n)};o(t,[{key:"stats",get:function t(){return this.loader.stats}},{key:"context",get:function t(){return this.loader.context}}]);return t}()};t.uuid=function t(){var i=URL.createObjectURL(new Blob);var t=i.toString();URL.revokeObjectURL(i);return t.substr(t.lastIndexOf("/")+1)};t.serialize=function t(i){var r=[];var e=function t(i){return!Number.isNaN(i)&&i!=null&&i!==""&&i!==false};var n=function t(i){return Math.round(i)};var s=function t(i){return n(i/100)*100};var a=function t(i){return encodeURIComponent(i)};var u={br:n,d:n,bl:s,dl:s,mtp:s,nor:a,rtp:s,tb:n};var o=Object.keys(i||{}).sort();for(var h=f(o),l;!(l=h()).done;){var c=l.value;var v=i[c];if(!e(v)){continue}if(c==="v"&&v===1){continue}if(c=="pr"&&v===1){continue}var d=u[c];if(d){v=d(v)}var m=typeof v;var p=void 0;if(c==="ot"||c==="sf"||c==="st"){p=c+"="+v}else if(m==="boolean"){p=c}else if(m==="number"){p=c+"="+v}else{p=c+"="+JSON.stringify(v)}r.push(p)}return r.join(",")};t.toHeaders=function i(r){var e=Object.keys(r);var n={};var s=["Object","Request","Session","Status"];var a=[{},{},{},{}];var u={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3};for(var o=0,f=e;o<f.length;o++){var h=f[o];var l=u[h]!=null?u[h]:1;a[l][h]=r[h]}for(var c=0;c<a.length;c++){var v=t.serialize(a[c]);if(v){n["CMCD-"+s[c]]=v}}return n};t.toQuery=function i(r){return"CMCD="+encodeURIComponent(t.serialize(r))};t.appendQueryToUri=function t(i,r){if(!r){return i}var e=i.includes("?")?"&":"?";return""+i+e+r};return t}()},"./src/controller/eme-controller.ts":
|
|
54
|
+
/*!******************************************!*\
|
|
55
|
+
!*** ./src/controller/eme-controller.ts ***!
|
|
56
|
+
\******************************************/
|
|
57
|
+
/*! exports provided: default */function(t,i,r){r.r(i);var e=r(/*! ../events */"./src/events.ts");var n=r(/*! ../errors */"./src/errors.ts");var s=r(/*! ../utils/logger */"./src/utils/logger.ts");var a=r(/*! ../utils/mediakeys-helper */"./src/utils/mediakeys-helper.ts");function u(t,i){for(var r=0;r<i.length;r++){var e=i[r];e.enumerable=e.enumerable||false;e.configurable=true;if("value"in e)e.writable=true;Object.defineProperty(t,e.key,e)}}function o(t,i,r){if(i)u(t.prototype,i);if(r)u(t,r);return t}var f=3;var h=function t(i,r,e){var n={audioCapabilities:[],videoCapabilities:[]};i.forEach((function(t){n.audioCapabilities.push({contentType:'audio/mp4; codecs="'+t+'"',robustness:e.audioRobustness||""})}));r.forEach((function(t){n.videoCapabilities.push({contentType:'video/mp4; codecs="'+t+'"',robustness:e.videoRobustness||""})}));return[n]};var l=function t(i,r,e,n){switch(i){case a["KeySystems"].WIDEVINE:return h(r,e,n);default:throw new Error("Unknown key-system: "+i)}};var c=function(){function t(t){this.hls=void 0;this._widevineLicenseUrl=void 0;this._licenseXhrSetup=void 0;this._licenseResponseCallback=void 0;this._emeEnabled=void 0;this._requestMediaKeySystemAccess=void 0;this._drmSystemOptions=void 0;this._config=void 0;this._mediaKeysList=[];this._media=null;this._hasSetMediaKeys=false;this._requestLicenseFailureCount=0;this.mediaKeysPromise=null;this._onMediaEncrypted=this.onMediaEncrypted.bind(this);this.hls=t;this._config=t.config;this._widevineLicenseUrl=this._config.widevineLicenseUrl;this._licenseXhrSetup=this._config.licenseXhrSetup;this._licenseResponseCallback=this._config.licenseResponseCallback;this._emeEnabled=this._config.emeEnabled;this._requestMediaKeySystemAccess=this._config.requestMediaKeySystemAccessFunc;this._drmSystemOptions=this._config.drmSystemOptions;this._registerListeners()}var i=t.prototype;i.destroy=function t(){this._unregisterListeners();this.hls=this._onMediaEncrypted=null;this._requestMediaKeySystemAccess=null};i._registerListeners=function t(){this.hls.on(e["Events"].MEDIA_ATTACHED,this.onMediaAttached,this);this.hls.on(e["Events"].MEDIA_DETACHED,this.onMediaDetached,this);this.hls.on(e["Events"].MANIFEST_PARSED,this.onManifestParsed,this)};i._unregisterListeners=function t(){this.hls.off(e["Events"].MEDIA_ATTACHED,this.onMediaAttached,this);this.hls.off(e["Events"].MEDIA_DETACHED,this.onMediaDetached,this);this.hls.off(e["Events"].MANIFEST_PARSED,this.onManifestParsed,this)};i.getLicenseServerUrl=function t(i){switch(i){case a["KeySystems"].WIDEVINE:if(!this._widevineLicenseUrl){break}return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+i+'"')};i._attemptKeySystemAccess=function t(i,r,e){var n=this;var a=l(i,r,e,this._drmSystemOptions);s["logger"].log("Requesting encrypted media key-system access");var u=this.requestMediaKeySystemAccess(i,a);this.mediaKeysPromise=u.then((function(t){return n._onMediaKeySystemAccessObtained(i,t)}));u.catch((function(t){s["logger"].error('Failed to obtain key-system "'+i+'" access:',t)}))};i._onMediaKeySystemAccessObtained=function t(i,r){var e=this;s["logger"].log('Access for key-system "'+i+'" obtained');var n={mediaKeysSessionInitialized:false,mediaKeySystemAccess:r,mediaKeySystemDomain:i};this._mediaKeysList.push(n);var a=Promise.resolve().then((function(){return r.createMediaKeys()})).then((function(t){n.mediaKeys=t;s["logger"].log('Media-keys created for key-system "'+i+'"');e._onMediaKeysCreated();return t}));a.catch((function(t){s["logger"].error("Failed to create media-keys:",t)}));return a};i._onMediaKeysCreated=function t(){var i=this;this._mediaKeysList.forEach((function(t){if(!t.mediaKeysSession){t.mediaKeysSession=t.mediaKeys.createSession();i._onNewMediaKeySession(t.mediaKeysSession)}}))};i._onNewMediaKeySession=function t(i){var r=this;s["logger"].log("New key-system session "+i.sessionId);i.addEventListener("message",(function(t){r._onKeySessionMessage(i,t.message)}),false)};i._onKeySessionMessage=function t(i,r){s["logger"].log("Got EME message event, creating license request");this._requestLicense(r,(function(t){s["logger"].log("Received license data (length: "+(t?t.byteLength:t)+"), updating key-session");i.update(t)}))};i.onMediaEncrypted=function t(i){var r=this;s["logger"].log('Media is encrypted using "'+i.initDataType+'" init data type');if(!this.mediaKeysPromise){s["logger"].error("Fatal: Media is encrypted but no CDM access or no keys have been requested");this.hls.trigger(e["Events"].ERROR,{type:n["ErrorTypes"].KEY_SYSTEM_ERROR,details:n["ErrorDetails"].KEY_SYSTEM_NO_KEYS,fatal:true});return}var a=function t(e){if(!r._media){return}r._attemptSetMediaKeys(e);r._generateRequestWithPreferredKeySession(i.initDataType,i.initData)};this.mediaKeysPromise.then(a).catch(a)};i._attemptSetMediaKeys=function t(i){if(!this._media){throw new Error("Attempted to set mediaKeys without first attaching a media element")}if(!this._hasSetMediaKeys){var r=this._mediaKeysList[0];if(!r||!r.mediaKeys){s["logger"].error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet");this.hls.trigger(e["Events"].ERROR,{type:n["ErrorTypes"].KEY_SYSTEM_ERROR,details:n["ErrorDetails"].KEY_SYSTEM_NO_KEYS,fatal:true});return}s["logger"].log("Setting keys for encrypted media");this._media.setMediaKeys(r.mediaKeys);this._hasSetMediaKeys=true}};i._generateRequestWithPreferredKeySession=function t(i,r){var a=this;var u=this._mediaKeysList[0];if(!u){s["logger"].error("Fatal: Media is encrypted but not any key-system access has been obtained yet");this.hls.trigger(e["Events"].ERROR,{type:n["ErrorTypes"].KEY_SYSTEM_ERROR,details:n["ErrorDetails"].KEY_SYSTEM_NO_ACCESS,fatal:true});return}if(u.mediaKeysSessionInitialized){s["logger"].warn("Key-Session already initialized but requested again");return}var o=u.mediaKeysSession;if(!o){s["logger"].error("Fatal: Media is encrypted but no key-session existing");this.hls.trigger(e["Events"].ERROR,{type:n["ErrorTypes"].KEY_SYSTEM_ERROR,details:n["ErrorDetails"].KEY_SYSTEM_NO_SESSION,fatal:true});return}if(!r){s["logger"].warn("Fatal: initData required for generating a key session is null");this.hls.trigger(e["Events"].ERROR,{type:n["ErrorTypes"].KEY_SYSTEM_ERROR,details:n["ErrorDetails"].KEY_SYSTEM_NO_INIT_DATA,fatal:true});return}s["logger"].log('Generating key-session request for "'+i+'" init data type');u.mediaKeysSessionInitialized=true;o.generateRequest(i,r).then((function(){s["logger"].debug("Key-session generation succeeded")})).catch((function(t){s["logger"].error("Error generating key-session request:",t);a.hls.trigger(e["Events"].ERROR,{type:n["ErrorTypes"].KEY_SYSTEM_ERROR,details:n["ErrorDetails"].KEY_SYSTEM_NO_SESSION,fatal:false})}))};i._createLicenseXhr=function t(i,r,e){var n=new XMLHttpRequest;n.responseType="arraybuffer";n.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,n,i,r,e);var a=this._licenseXhrSetup;if(a){try{a.call(this.hls,n,i);a=undefined}catch(t){s["logger"].error(t)}}try{if(!n.readyState){n.open("POST",i,true)}if(a){a.call(this.hls,n,i)}}catch(t){throw new Error("issue setting up KeySystem license XHR "+t)}return n};i._onLicenseRequestReadyStageChange=function t(i,r,a,u){switch(i.readyState){case 4:if(i.status===200){this._requestLicenseFailureCount=0;s["logger"].log("License request succeeded");var o=i.response;var h=this._licenseResponseCallback;if(h){try{o=h.call(this.hls,i,r)}catch(t){s["logger"].error(t)}}u(o)}else{s["logger"].error("License Request XHR failed ("+r+"). Status: "+i.status+" ("+i.statusText+")");this._requestLicenseFailureCount++;if(this._requestLicenseFailureCount>f){this.hls.trigger(e["Events"].ERROR,{type:n["ErrorTypes"].KEY_SYSTEM_ERROR,details:n["ErrorDetails"].KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:true});return}var l=f-this._requestLicenseFailureCount+1;s["logger"].warn("Retrying license request, "+l+" attempts left");this._requestLicense(a,u)}break}};i._generateLicenseRequestChallenge=function t(i,r){switch(i.mediaKeySystemDomain){case a["KeySystems"].WIDEVINE:return r}throw new Error("unsupported key-system: "+i.mediaKeySystemDomain)};i._requestLicense=function t(i,r){s["logger"].log("Requesting content license for key-system");var a=this._mediaKeysList[0];if(!a){s["logger"].error("Fatal error: Media is encrypted but no key-system access has been obtained yet");this.hls.trigger(e["Events"].ERROR,{type:n["ErrorTypes"].KEY_SYSTEM_ERROR,details:n["ErrorDetails"].KEY_SYSTEM_NO_ACCESS,fatal:true});return}try{var u=this.getLicenseServerUrl(a.mediaKeySystemDomain);var o=this._createLicenseXhr(u,i,r);s["logger"].log("Sending license request to URL: "+u);var f=this._generateLicenseRequestChallenge(a,i);o.send(f)}catch(t){s["logger"].error("Failure requesting DRM license: "+t);this.hls.trigger(e["Events"].ERROR,{type:n["ErrorTypes"].KEY_SYSTEM_ERROR,details:n["ErrorDetails"].KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:true})}};i.onMediaAttached=function t(i,r){if(!this._emeEnabled){return}var e=r.media;this._media=e;e.addEventListener("encrypted",this._onMediaEncrypted)};i.onMediaDetached=function t(){var i=this._media;var r=this._mediaKeysList;if(!i){return}i.removeEventListener("encrypted",this._onMediaEncrypted);this._media=null;this._mediaKeysList=[];Promise.all(r.map((function(t){if(t.mediaKeysSession){return t.mediaKeysSession.close().catch((function(){}))}}))).then((function(){return i.setMediaKeys(null)})).catch((function(){}))};i.onManifestParsed=function t(i,r){if(!this._emeEnabled){return}var e=r.levels.map((function(t){return t.audioCodec})).filter((function(t){return!!t}));var n=r.levels.map((function(t){return t.videoCodec})).filter((function(t){return!!t}));this._attemptKeySystemAccess(a["KeySystems"].WIDEVINE,e,n)};o(t,[{key:"requestMediaKeySystemAccess",get:function t(){if(!this._requestMediaKeySystemAccess){throw new Error("No requestMediaKeySystemAccess function configured")}return this._requestMediaKeySystemAccess}}]);return t}();i["default"]=c},"./src/controller/fps-controller.ts":
|
|
58
|
+
/*!******************************************!*\
|
|
59
|
+
!*** ./src/controller/fps-controller.ts ***!
|
|
60
|
+
\******************************************/
|
|
61
|
+
/*! exports provided: default */function(t,i,r){r.r(i);var e=r(/*! ../events */"./src/events.ts");var n=r(/*! ../utils/logger */"./src/utils/logger.ts");var s=function(){function t(t){this.hls=void 0;this.isVideoPlaybackQualityAvailable=false;this.timer=void 0;this.media=null;this.lastTime=void 0;this.lastDroppedFrames=0;this.lastDecodedFrames=0;this.streamController=void 0;this.hls=t;this.registerListeners()}var i=t.prototype;i.setStreamController=function t(i){this.streamController=i};i.registerListeners=function t(){this.hls.on(e["Events"].MEDIA_ATTACHING,this.onMediaAttaching,this)};i.unregisterListeners=function t(){this.hls.off(e["Events"].MEDIA_ATTACHING,this.onMediaAttaching)};i.destroy=function t(){if(this.timer){clearInterval(this.timer)}this.unregisterListeners();this.isVideoPlaybackQualityAvailable=false;this.media=null};i.onMediaAttaching=function t(i,r){var e=this.hls.config;if(e.capLevelOnFPSDrop){var n=r.media instanceof self.HTMLVideoElement?r.media:null;this.media=n;if(n&&typeof n.getVideoPlaybackQuality==="function"){this.isVideoPlaybackQualityAvailable=true}self.clearInterval(this.timer);this.timer=self.setInterval(this.checkFPSInterval.bind(this),e.fpsDroppedMonitoringPeriod)}};i.checkFPS=function t(i,r,s){var a=performance.now();if(r){if(this.lastTime){var u=a-this.lastTime;var o=s-this.lastDroppedFrames;var f=r-this.lastDecodedFrames;var h=1e3*o/u;var l=this.hls;l.trigger(e["Events"].FPS_DROP,{currentDropped:o,currentDecoded:f,totalDroppedFrames:s});if(h>0){if(o>l.config.fpsDroppedMonitoringThreshold*f){var c=l.currentLevel;n["logger"].warn("drop FPS ratio greater than max allowed value for currentLevel: "+c);if(c>0&&(l.autoLevelCapping===-1||l.autoLevelCapping>=c)){c=c-1;l.trigger(e["Events"].FPS_DROP_LEVEL_CAPPING,{level:c,droppedLevel:l.currentLevel});l.autoLevelCapping=c;this.streamController.nextLevelSwitch()}}}}this.lastTime=a;this.lastDroppedFrames=s;this.lastDecodedFrames=r}};i.checkFPSInterval=function t(){var i=this.media;if(i){if(this.isVideoPlaybackQualityAvailable){var r=i.getVideoPlaybackQuality();this.checkFPS(i,r.totalVideoFrames,r.droppedVideoFrames)}else{this.checkFPS(i,i.webkitDecodedFrameCount,i.webkitDroppedFrameCount)}}};return t}();i["default"]=s},"./src/controller/fragment-finders.ts":
|
|
62
|
+
/*!********************************************!*\
|
|
63
|
+
!*** ./src/controller/fragment-finders.ts ***!
|
|
64
|
+
\********************************************/
|
|
65
|
+
/*! exports provided: findFragmentByPDT, findFragmentByPTS, fragmentWithinToleranceTest, pdtWithinToleranceTest, findFragWithCC */function(t,i,r){r.r(i);r.d(i,"findFragmentByPDT",(function(){return s}));r.d(i,"findFragmentByPTS",(function(){return a}));r.d(i,"fragmentWithinToleranceTest",(function(){return u}));r.d(i,"pdtWithinToleranceTest",(function(){return o}));r.d(i,"findFragWithCC",(function(){return f}));var e=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");var n=r(/*! ../utils/binary-search */"./src/utils/binary-search.ts");function s(t,i,r){if(i===null||!Array.isArray(t)||!t.length||!Object(e["isFiniteNumber"])(i)){return null}var n=t[0].programDateTime;if(i<(n||0)){return null}var s=t[t.length-1].endProgramDateTime;if(i>=(s||0)){return null}r=r||0;for(var a=0;a<t.length;++a){var u=t[a];if(o(i,r,u)){return u}}return null}function a(t,i,r,e){if(r===void 0){r=0}if(e===void 0){e=0}var s=null;if(t){s=i[t.sn-i[0].sn+1]||null}else if(r===0&&i[0].start===0){s=i[0]}if(s&&u(r,e,s)===0){return s}var a=n["default"].search(i,u.bind(null,r,e));if(a){return a}return s}function u(t,i,r){if(t===void 0){t=0}if(i===void 0){i=0}var e=Math.min(i,r.duration+(r.deltaPTS?r.deltaPTS:0));if(r.start+r.duration-e<=t){return 1}else if(r.start-e>t&&r.start){return-1}return 0}function o(t,i,r){var e=Math.min(i,r.duration+(r.deltaPTS?r.deltaPTS:0))*1e3;var n=r.endProgramDateTime||0;return n-e>t}function f(t,i){return n["default"].search(t,(function(t){if(t.cc<i){return 1}else if(t.cc>i){return-1}else{return 0}}))}},"./src/controller/fragment-tracker.ts":
|
|
66
|
+
/*!********************************************!*\
|
|
67
|
+
!*** ./src/controller/fragment-tracker.ts ***!
|
|
68
|
+
\********************************************/
|
|
69
|
+
/*! exports provided: FragmentState, FragmentTracker */function(t,i,r){r.r(i);r.d(i,"FragmentState",(function(){return s}));r.d(i,"FragmentTracker",(function(){return a}));var e=r(/*! ../events */"./src/events.ts");var n=r(/*! ../types/loader */"./src/types/loader.ts");var s;(function(t){t["NOT_LOADED"]="NOT_LOADED";t["BACKTRACKED"]="BACKTRACKED";t["APPENDING"]="APPENDING";t["PARTIAL"]="PARTIAL";t["OK"]="OK"})(s||(s={}));var a=function(){function t(t){this.activeFragment=null;this.activeParts=null;this.fragments=Object.create(null);this.timeRanges=Object.create(null);this.bufferPadding=.2;this.hls=void 0;this.hls=t;this._registerListeners()}var i=t.prototype;i._registerListeners=function t(){var i=this.hls;i.on(e["Events"].BUFFER_APPENDED,this.onBufferAppended,this);i.on(e["Events"].FRAG_BUFFERED,this.onFragBuffered,this);i.on(e["Events"].FRAG_LOADED,this.onFragLoaded,this)};i._unregisterListeners=function t(){var i=this.hls;i.off(e["Events"].BUFFER_APPENDED,this.onBufferAppended,this);i.off(e["Events"].FRAG_BUFFERED,this.onFragBuffered,this);i.off(e["Events"].FRAG_LOADED,this.onFragLoaded,this)};i.destroy=function t(){this._unregisterListeners();this.fragments=this.timeRanges=null};i.getAppendedFrag=function t(i,r){if(r===n["PlaylistLevelType"].MAIN){var e=this.activeFragment,s=this.activeParts;if(!e){return null}if(s){for(var a=s.length;a--;){var u=s[a];var o=u?u.end:e.appendedPTS;if(u.start<=i&&o!==undefined&&i<=o){if(a>9){this.activeParts=s.slice(a-9)}return u}}}else if(e.start<=i&&e.appendedPTS!==undefined&&i<=e.appendedPTS){return e}}return this.getBufferedFrag(i,r)};i.getBufferedFrag=function t(i,r){var e=this.fragments;var n=Object.keys(e);for(var s=n.length;s--;){var a=e[n[s]];if((a===null||a===void 0?void 0:a.body.type)===r&&a.buffered){var u=a.body;if(u.start<=i&&i<=u.end){return u}}}return null};i.detectEvictedFragments=function t(i,r,e){var n=this;Object.keys(this.fragments).forEach((function(t){var s=n.fragments[t];if(!s){return}if(!s.buffered){if(s.body.type===e){n.removeFragment(s.body)}return}var a=s.range[i];if(!a){return}a.time.some((function(t){var i=!n.isTimeBuffered(t.startPTS,t.endPTS,r);if(i){n.removeFragment(s.body)}return i}))}))};i.detectPartialFragments=function t(i){var r=this;var e=this.timeRanges;var n=i.frag,s=i.part;if(!e||n.sn==="initSegment"){return}var a=o(n);var u=this.fragments[a];if(!u){return}Object.keys(e).forEach((function(t){var i=n.elementaryStreams[t];if(!i){return}var a=e[t];var o=s!==null||i.partial===true;u.range[t]=r.getBufferedTimes(n,s,o,a)}));u.backtrack=u.loaded=null;if(Object.keys(u.range).length){u.buffered=true}else{this.removeFragment(u.body)}};i.fragBuffered=function t(i){var r=o(i);var e=this.fragments[r];if(e){e.backtrack=e.loaded=null;e.buffered=true}};i.getBufferedTimes=function t(i,r,e,n){var s={time:[],partial:e};var a=r?r.start:i.start;var u=r?r.end:i.end;var o=i.minEndPTS||u;var f=i.maxStartPTS||a;for(var h=0;h<n.length;h++){var l=n.start(h)-this.bufferPadding;var c=n.end(h)+this.bufferPadding;if(f>=l&&o<=c){s.time.push({startPTS:Math.max(a,n.start(h)),endPTS:Math.min(u,n.end(h))});break}else if(a<c&&u>l){s.partial=true;s.time.push({startPTS:Math.max(a,n.start(h)),endPTS:Math.min(u,n.end(h))})}else if(u<=l){break}}return s};i.getPartialFragment=function t(i){var r=null;var e;var n;var s;var a=0;var o=this.bufferPadding,f=this.fragments;Object.keys(f).forEach((function(t){var h=f[t];if(!h){return}if(u(h)){n=h.body.start-o;s=h.body.end+o;if(i>=n&&i<=s){e=Math.min(i-n,s-i);if(a<=e){r=h.body;a=e}}}}));return r};i.getState=function t(i){var r=o(i);var e=this.fragments[r];if(e){if(!e.buffered){if(e.backtrack){return s.BACKTRACKED}return s.APPENDING}else if(u(e)){return s.PARTIAL}else{return s.OK}}return s.NOT_LOADED};i.backtrack=function t(i,r){var e=o(i);var n=this.fragments[e];if(!n||n.backtrack){return null}var t=n.backtrack=r?r:n.loaded;n.loaded=null;return t};i.getBacktrackData=function t(i){var r=o(i);var e=this.fragments[r];if(e){var n;var s=e.backtrack;if(s!==null&&s!==void 0&&(n=s.payload)!==null&&n!==void 0&&n.byteLength){return s}else{this.removeFragment(i)}}return null};i.isTimeBuffered=function t(i,r,e){var n;var s;for(var a=0;a<e.length;a++){n=e.start(a)-this.bufferPadding;s=e.end(a)+this.bufferPadding;if(i>=n&&r<=s){return true}if(r<=n){return false}}return false};i.onFragLoaded=function t(i,r){var e=r.frag,n=r.part;if(e.sn==="initSegment"||e.bitrateTest||n){return}var s=o(e);this.fragments[s]={body:e,loaded:r,backtrack:null,buffered:false,range:Object.create(null)}};i.onBufferAppended=function t(i,r){var e=this;var s=r.frag,a=r.part,u=r.timeRanges;if(s.type===n["PlaylistLevelType"].MAIN){this.activeFragment=s;if(a){var o=this.activeParts;if(!o){this.activeParts=o=[]}o.push(a)}else{this.activeParts=null}}this.timeRanges=u;Object.keys(u).forEach((function(t){var i=u[t];e.detectEvictedFragments(t,i);if(!a){for(var r=0;r<i.length;r++){s.appendedPTS=Math.max(i.end(r),s.appendedPTS||0)}}}))};i.onFragBuffered=function t(i,r){this.detectPartialFragments(r)};i.hasFragment=function t(i){var r=o(i);return!!this.fragments[r]};i.removeFragmentsInRange=function t(i,r,e){var n=this;Object.keys(this.fragments).forEach((function(t){var s=n.fragments[t];if(!s){return}if(s.buffered){var a=s.body;if(a.type===e&&a.start<r&&a.end>i){n.removeFragment(a)}}}))};i.removeFragment=function t(i){var r=o(i);i.stats.loaded=0;i.clearElementaryStreamInfo();delete this.fragments[r]};i.removeAllFragments=function t(){this.fragments=Object.create(null);this.activeFragment=null;this.activeParts=null};return t}();function u(t){var i,r;return t.buffered&&(((i=t.range.video)===null||i===void 0?void 0:i.partial)||((r=t.range.audio)===null||r===void 0?void 0:r.partial))}function o(t){return t.type+"_"+t.level+"_"+t.urlId+"_"+t.sn}},"./src/controller/gap-controller.ts":
|
|
70
|
+
/*!******************************************!*\
|
|
71
|
+
!*** ./src/controller/gap-controller.ts ***!
|
|
72
|
+
\******************************************/
|
|
73
|
+
/*! exports provided: STALL_MINIMUM_DURATION_MS, MAX_START_GAP_JUMP, SKIP_BUFFER_HOLE_STEP_SECONDS, SKIP_BUFFER_RANGE_START, default */function(t,i,r){r.r(i);r.d(i,"STALL_MINIMUM_DURATION_MS",(function(){return u}));r.d(i,"MAX_START_GAP_JUMP",(function(){return o}));r.d(i,"SKIP_BUFFER_HOLE_STEP_SECONDS",(function(){return f}));r.d(i,"SKIP_BUFFER_RANGE_START",(function(){return h}));r.d(i,"default",(function(){return l}));var e=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts");var n=r(/*! ../errors */"./src/errors.ts");var s=r(/*! ../events */"./src/events.ts");var a=r(/*! ../utils/logger */"./src/utils/logger.ts");var u=250;var o=2;var f=.1;var h=.05;var l=function(){function t(t,i,r,e){this.config=void 0;this.media=void 0;this.fragmentTracker=void 0;this.hls=void 0;this.nudgeRetry=0;this.stallReported=false;this.stalled=null;this.moved=false;this.seeking=false;this.config=t;this.media=i;this.fragmentTracker=r;this.hls=e}var i=t.prototype;i.destroy=function t(){this.hls=this.fragmentTracker=this.media=null};i.poll=function t(i){var r=this.config,n=this.media,s=this.stalled;var f=n.currentTime,h=n.seeking;var l=this.seeking&&!h;var c=!this.seeking&&h;this.seeking=h;if(f!==i){this.moved=true;if(s!==null){if(this.stallReported){var v=self.performance.now()-s;a["logger"].warn("playback not stuck anymore @"+f+", after "+Math.round(v)+"ms");this.stallReported=false}this.stalled=null;this.nudgeRetry=0}return}if(c||l){this.stalled=null}if(n.paused||n.ended||n.playbackRate===0||!e["BufferHelper"].getBuffered(n).length){return}var d=e["BufferHelper"].bufferInfo(n,f,0);var m=d.len>0;var p=d.nextStart||0;if(!m&&!p){return}if(h){var g=d.len>o;var b=!p||p-f>o&&!this.fragmentTracker.getPartialFragment(f);if(g||b){return}this.moved=false}if(!this.moved&&this.stalled!==null){var y;var w=Math.max(p,d.start||0)-f;var A=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null;var k=A===null||A===void 0?void 0:(y=A.details)===null||y===void 0?void 0:y.live;var T=k?A.details.targetduration*2:o;if(w>0&&w<=T){this._trySkipBufferHole(null);return}}var E=self.performance.now();if(s===null){this.stalled=E;return}var O=E-s;if(!h&&O>=u){this._reportStall(d.len)}var S=e["BufferHelper"].bufferInfo(n,f,r.maxBufferHole);this._tryFixBufferStall(S,O)};i._tryFixBufferStall=function t(i,r){var e=this.config,n=this.fragmentTracker,s=this.media;var u=s.currentTime;var o=n.getPartialFragment(u);if(o){var f=this._trySkipBufferHole(o);if(f){return}}if(i.len>e.maxBufferHole&&r>e.highBufferWatchdogPeriod*1e3){a["logger"].warn("Trying to nudge playhead over buffer-hole");this.stalled=null;this._tryNudgeBuffer()}};i._reportStall=function t(i){var r=this.hls,e=this.media,u=this.stallReported;if(!u){this.stallReported=true;a["logger"].warn("Playback stalling at @"+e.currentTime+" due to low buffer (buffer="+i+")");r.trigger(s["Events"].ERROR,{type:n["ErrorTypes"].MEDIA_ERROR,details:n["ErrorDetails"].BUFFER_STALLED_ERROR,fatal:false,buffer:i})}};i._trySkipBufferHole=function t(i){var r=this.config,u=this.hls,o=this.media;var l=o.currentTime;var c=0;var v=e["BufferHelper"].getBuffered(o);for(var d=0;d<v.length;d++){var m=v.start(d);if(l+r.maxBufferHole>=c&&l<m){var p=Math.max(m+h,o.currentTime+f);a["logger"].warn("skipping hole, adjusting currentTime from "+l+" to "+p);this.moved=true;this.stalled=null;o.currentTime=p;if(i){u.trigger(s["Events"].ERROR,{type:n["ErrorTypes"].MEDIA_ERROR,details:n["ErrorDetails"].BUFFER_SEEK_OVER_HOLE,fatal:false,reason:"fragment loaded with buffer holes, seeking from "+l+" to "+p,frag:i})}return p}c=v.end(d)}return 0};i._tryNudgeBuffer=function t(){var i=this.config,r=this.hls,e=this.media;var u=e.currentTime;var o=(this.nudgeRetry||0)+1;this.nudgeRetry=o;if(o<i.nudgeMaxRetry){var f=u+o*i.nudgeOffset;a["logger"].warn("Nudging 'currentTime' from "+u+" to "+f);e.currentTime=f;r.trigger(s["Events"].ERROR,{type:n["ErrorTypes"].MEDIA_ERROR,details:n["ErrorDetails"].BUFFER_NUDGE_ON_STALL,fatal:false})}else{a["logger"].error("Playhead still not moving while enough data buffered @"+u+" after "+i.nudgeMaxRetry+" nudges");r.trigger(s["Events"].ERROR,{type:n["ErrorTypes"].MEDIA_ERROR,details:n["ErrorDetails"].BUFFER_STALLED_ERROR,fatal:true})}};return t}()},"./src/controller/id3-track-controller.ts":
|
|
74
|
+
/*!************************************************!*\
|
|
75
|
+
!*** ./src/controller/id3-track-controller.ts ***!
|
|
76
|
+
\************************************************/
|
|
77
|
+
/*! exports provided: default */function(t,i,r){r.r(i);var e=r(/*! ../events */"./src/events.ts");var n=r(/*! ../utils/texttrack-utils */"./src/utils/texttrack-utils.ts");var s=r(/*! ../demux/id3 */"./src/demux/id3.ts");var a=.25;var u=function(){function t(t){this.hls=void 0;this.id3Track=null;this.media=null;this.hls=t;this._registerListeners()}var i=t.prototype;i.destroy=function t(){this._unregisterListeners()};i._registerListeners=function t(){var i=this.hls;i.on(e["Events"].MEDIA_ATTACHED,this.onMediaAttached,this);i.on(e["Events"].MEDIA_DETACHING,this.onMediaDetaching,this);i.on(e["Events"].FRAG_PARSING_METADATA,this.onFragParsingMetadata,this);i.on(e["Events"].BUFFER_FLUSHING,this.onBufferFlushing,this)};i._unregisterListeners=function t(){var i=this.hls;i.off(e["Events"].MEDIA_ATTACHED,this.onMediaAttached,this);i.off(e["Events"].MEDIA_DETACHING,this.onMediaDetaching,this);i.off(e["Events"].FRAG_PARSING_METADATA,this.onFragParsingMetadata,this);i.off(e["Events"].BUFFER_FLUSHING,this.onBufferFlushing,this)};i.onMediaAttached=function t(i,r){this.media=r.media};i.onMediaDetaching=function t(){if(!this.id3Track){return}Object(n["clearCurrentCues"])(this.id3Track);this.id3Track=null;this.media=null};i.getID3Track=function t(i){if(!this.media){return}for(var r=0;r<i.length;r++){var e=i[r];if(e.kind==="metadata"&&e.label==="id3"){Object(n["sendAddTrackEvent"])(e,this.media);return e}}return this.media.addTextTrack("metadata","id3")};i.onFragParsingMetadata=function t(i,r){if(!this.media){return}var e=r.frag;var n=r.samples;if(!this.id3Track){this.id3Track=this.getID3Track(this.media.textTracks);this.id3Track.mode="hidden"}var u=self.WebKitDataCue||self.VTTCue||self.TextTrackCue;for(var o=0;o<n.length;o++){var f=s["getID3Frames"](n[o].data);if(f){var h=n[o].pts;var l=o<n.length-1?n[o+1].pts:e.end;var c=l-h;if(c<=0){l=h+a}for(var v=0;v<f.length;v++){var d=f[v];if(!s["isTimeStampFrame"](d)){var m=new u(h,l,"");m.value=d;this.id3Track.addCue(m)}}}}};i.onBufferFlushing=function t(i,r){var e=r.startOffset,s=r.endOffset,a=r.type;if(!a||a==="audio"){var u=this.id3Track;if(u){Object(n["removeCuesInRange"])(u,e,s)}}};return t}();i["default"]=u},"./src/controller/latency-controller.ts":
|
|
78
|
+
/*!**********************************************!*\
|
|
79
|
+
!*** ./src/controller/latency-controller.ts ***!
|
|
80
|
+
\**********************************************/
|
|
81
|
+
/*! exports provided: default */function(t,i,r){r.r(i);r.d(i,"default",(function(){return o}));var e=r(/*! ../errors */"./src/errors.ts");var n=r(/*! ../events */"./src/events.ts");var s=r(/*! ../utils/logger */"./src/utils/logger.ts");function a(t,i){for(var r=0;r<i.length;r++){var e=i[r];e.enumerable=e.enumerable||false;e.configurable=true;if("value"in e)e.writable=true;Object.defineProperty(t,e.key,e)}}function u(t,i,r){if(i)a(t.prototype,i);if(r)a(t,r);return t}var o=function(){function t(t){var i=this;this.hls=void 0;this.config=void 0;this.media=null;this.levelDetails=null;this.currentTime=0;this.stallCount=0;this._latency=null;this.timeupdateHandler=function(){return i.timeupdate()};this.hls=t;this.config=t.config;this.registerListeners()}var i=t.prototype;i.destroy=function t(){this.unregisterListeners();this.onMediaDetaching();this.levelDetails=null;this.hls=this.timeupdateHandler=null};i.registerListeners=function t(){this.hls.on(n["Events"].MEDIA_ATTACHED,this.onMediaAttached,this);this.hls.on(n["Events"].MEDIA_DETACHING,this.onMediaDetaching,this);this.hls.on(n["Events"].MANIFEST_LOADING,this.onManifestLoading,this);this.hls.on(n["Events"].LEVEL_UPDATED,this.onLevelUpdated,this);this.hls.on(n["Events"].ERROR,this.onError,this)};i.unregisterListeners=function t(){this.hls.off(n["Events"].MEDIA_ATTACHED,this.onMediaAttached);this.hls.off(n["Events"].MEDIA_DETACHING,this.onMediaDetaching);this.hls.off(n["Events"].MANIFEST_LOADING,this.onManifestLoading);this.hls.off(n["Events"].LEVEL_UPDATED,this.onLevelUpdated);this.hls.off(n["Events"].ERROR,this.onError)};i.onMediaAttached=function t(i,r){this.media=r.media;this.media.addEventListener("timeupdate",this.timeupdateHandler)};i.onMediaDetaching=function t(){if(this.media){this.media.removeEventListener("timeupdate",this.timeupdateHandler);this.media=null}};i.onManifestLoading=function t(){this.levelDetails=null;this._latency=null;this.stallCount=0};i.onLevelUpdated=function t(i,r){var e=r.details;this.levelDetails=e;if(e.advanced){this.timeupdate()}if(!e.live&&this.media){this.media.removeEventListener("timeupdate",this.timeupdateHandler)}};i.onError=function t(i,r){if(r.details!==e["ErrorDetails"].BUFFER_STALLED_ERROR){return}this.stallCount++;s["logger"].warn("[playback-rate-controller]: Stall detected, adjusting target latency")};i.timeupdate=function t(){var i=this.media,r=this.levelDetails;if(!i||!r){return}this.currentTime=i.currentTime;var e=this.computeLatency();if(e===null){return}this._latency=e;var n=this.config,s=n.lowLatencyMode,a=n.maxLiveSyncPlaybackRate;if(!s||a===1){return}var u=this.targetLatency;if(u===null){return}var o=e-u;var f=Math.min(this.maxLatency,u+r.targetduration);var h=o<f;if(r.live&&h&&o>.05&&this.forwardBufferLength>1){var l=Math.min(2,Math.max(1,a));var c=Math.round(2/(1+Math.exp(-.75*o-this.edgeStalled))*20)/20;i.playbackRate=Math.min(l,Math.max(1,c))}else if(i.playbackRate!==1&&i.playbackRate!==0){i.playbackRate=1}};i.estimateLiveEdge=function t(){var i=this.levelDetails;if(i===null){return null}return i.edge+i.age};i.computeLatency=function t(){var i=this.estimateLiveEdge();if(i===null){return null}return i-this.currentTime};u(t,[{key:"latency",get:function t(){return this._latency||0}},{key:"maxLatency",get:function t(){var i=this.config,r=this.levelDetails;if(i.liveMaxLatencyDuration!==undefined){return i.liveMaxLatencyDuration}return r?i.liveMaxLatencyDurationCount*r.targetduration:0}},{key:"targetLatency",get:function t(){var i=this.levelDetails;if(i===null){return null}var r=i.holdBack,e=i.partHoldBack,n=i.targetduration;var s=this.config,a=s.liveSyncDuration,u=s.liveSyncDurationCount,o=s.lowLatencyMode;var f=this.hls.userConfig;var h=o?e||r:r;if(f.liveSyncDuration||f.liveSyncDurationCount||h===0){h=a!==undefined?a:u*n}var l=n;var c=1;return h+Math.min(this.stallCount*c,l)}},{key:"liveSyncPosition",get:function t(){var i=this.estimateLiveEdge();var r=this.targetLatency;var e=this.levelDetails;if(i===null||r===null||e===null){return null}var n=e.edge;var s=i-r-this.edgeStalled;var a=n-e.totalduration;var u=n-(this.config.lowLatencyMode&&e.partTarget||e.targetduration);return Math.min(Math.max(a,s),u)}},{key:"drift",get:function t(){var i=this.levelDetails;if(i===null){return 1}return i.drift}},{key:"edgeStalled",get:function t(){var i=this.levelDetails;if(i===null){return 0}var r=(this.config.lowLatencyMode&&i.partTarget||i.targetduration)*3;return Math.max(i.age-r,0)}},{key:"forwardBufferLength",get:function t(){var i=this.media,r=this.levelDetails;if(!i||!r){return 0}var e=i.buffered.length;return e?i.buffered.end(e-1):r.edge-this.currentTime}}]);return t}()},"./src/controller/level-controller.ts":
|
|
82
|
+
/*!********************************************!*\
|
|
83
|
+
!*** ./src/controller/level-controller.ts ***!
|
|
84
|
+
\********************************************/
|
|
85
|
+
/*! exports provided: default */function(t,i,r){r.r(i);r.d(i,"default",(function(){return p}));var e=r(/*! ../types/level */"./src/types/level.ts");var n=r(/*! ../events */"./src/events.ts");var s=r(/*! ../errors */"./src/errors.ts");var a=r(/*! ../utils/codecs */"./src/utils/codecs.ts");var u=r(/*! ./level-helper */"./src/controller/level-helper.ts");var o=r(/*! ./base-playlist-controller */"./src/controller/base-playlist-controller.ts");var f=r(/*! ../types/loader */"./src/types/loader.ts");function h(){h=Object.assign||function(t){for(var i=1;i<arguments.length;i++){var r=arguments[i];for(var e in r){if(Object.prototype.hasOwnProperty.call(r,e)){t[e]=r[e]}}}return t};return h.apply(this,arguments)}function l(t,i){for(var r=0;r<i.length;r++){var e=i[r];e.enumerable=e.enumerable||false;e.configurable=true;if("value"in e)e.writable=true;Object.defineProperty(t,e.key,e)}}function c(t,i,r){if(i)l(t.prototype,i);if(r)l(t,r);return t}function v(t,i){t.prototype=Object.create(i.prototype);t.prototype.constructor=t;d(t,i)}function d(t,i){d=Object.setPrototypeOf||function t(i,r){i.__proto__=r;return i};return d(t,i)}var m=/chrome|firefox/.test(navigator.userAgent.toLowerCase());var p=function(t){v(i,t);function i(i){var r;r=t.call(this,i,"[level-controller]")||this;r._levels=[];r._firstLevel=-1;r._startLevel=void 0;r.currentLevelIndex=-1;r.manualLevelIndex=-1;r.onParsedComplete=void 0;r._registerListeners();return r}var r=i.prototype;r._registerListeners=function t(){var i=this.hls;i.on(n["Events"].MANIFEST_LOADED,this.onManifestLoaded,this);i.on(n["Events"].LEVEL_LOADED,this.onLevelLoaded,this);i.on(n["Events"].AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this);i.on(n["Events"].FRAG_LOADED,this.onFragLoaded,this);i.on(n["Events"].ERROR,this.onError,this)};r._unregisterListeners=function t(){var i=this.hls;i.off(n["Events"].MANIFEST_LOADED,this.onManifestLoaded,this);i.off(n["Events"].LEVEL_LOADED,this.onLevelLoaded,this);i.off(n["Events"].AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this);i.off(n["Events"].FRAG_LOADED,this.onFragLoaded,this);i.off(n["Events"].ERROR,this.onError,this)};r.destroy=function i(){this._unregisterListeners();this.manualLevelIndex=-1;this._levels.length=0;t.prototype.destroy.call(this)};r.startLoad=function i(){var r=this._levels;r.forEach((function(t){t.loadError=0}));t.prototype.startLoad.call(this)};r.onManifestLoaded=function t(i,r){var o=[];var f=[];var h=[];var l;var c={};var v;var d=false;var p=false;var g=false;r.levels.forEach((function(t){var i=t.attrs;d=d||!!(t.width&&t.height);p=p||!!t.videoCodec;g=g||!!t.audioCodec;if(m&&t.audioCodec&&t.audioCodec.indexOf("mp4a.40.34")!==-1){t.audioCodec=undefined}var r=t.bitrate+"-"+t.attrs.RESOLUTION+"-"+t.attrs.CODECS;v=c[r];if(!v){v=new e["Level"](t);c[r]=v;o.push(v)}else{v.url.push(t.url)}if(i){if(i.AUDIO){Object(u["addGroupId"])(v,"audio",i.AUDIO)}if(i.SUBTITLES){Object(u["addGroupId"])(v,"text",i.SUBTITLES)}}}));if((d||p)&&g){o=o.filter((function(t){var i=t.videoCodec,r=t.width,e=t.height;return!!i||!!(r&&e)}))}o=o.filter((function(t){var i=t.audioCodec,r=t.videoCodec;return(!i||Object(a["isCodecSupportedInMp4"])(i,"audio"))&&(!r||Object(a["isCodecSupportedInMp4"])(r,"video"))}));if(r.audioTracks){f=r.audioTracks.filter((function(t){return!t.audioCodec||Object(a["isCodecSupportedInMp4"])(t.audioCodec,"audio")}));Object(u["assignTrackIdsByGroup"])(f)}if(r.subtitles){h=r.subtitles;Object(u["assignTrackIdsByGroup"])(h)}if(o.length>0){l=o[0].bitrate;o.sort((function(t,i){return t.bitrate-i.bitrate}));this._levels=o;for(var b=0;b<o.length;b++){if(o[b].bitrate===l){this._firstLevel=b;this.log("manifest loaded, "+o.length+" level(s) found, first bitrate: "+l);break}}var y=g&&!p;var w={levels:o,audioTracks:f,subtitleTracks:h,firstLevel:this._firstLevel,stats:r.stats,audio:g,video:p,altAudio:!y&&f.some((function(t){return!!t.url}))};this.hls.trigger(n["Events"].MANIFEST_PARSED,w);if(this.hls.config.autoStartLoad||this.hls.forceStartLoad){this.hls.startLoad(this.hls.config.startPosition)}}else{this.hls.trigger(n["Events"].ERROR,{type:s["ErrorTypes"].MEDIA_ERROR,details:s["ErrorDetails"].MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:true,url:r.url,reason:"no level with compatible codecs found in manifest"})}};r.onError=function i(r,e){t.prototype.onError.call(this,r,e);if(e.fatal){return}var n=e.context;var a=this._levels[this.currentLevelIndex];if(n&&(n.type===f["PlaylistContextType"].AUDIO_TRACK&&a.audioGroupIds&&n.groupId===a.audioGroupIds[a.urlId]||n.type===f["PlaylistContextType"].SUBTITLE_TRACK&&a.textGroupIds&&n.groupId===a.textGroupIds[a.urlId])){this.redundantFailover(this.currentLevelIndex);return}var u=false;var o=true;var h;switch(e.details){case s["ErrorDetails"].FRAG_LOAD_ERROR:case s["ErrorDetails"].FRAG_LOAD_TIMEOUT:case s["ErrorDetails"].KEY_LOAD_ERROR:case s["ErrorDetails"].KEY_LOAD_TIMEOUT:if(e.frag){var l=this._levels[e.frag.level];if(l){l.fragmentError++;if(l.fragmentError>this.hls.config.fragLoadingMaxRetry){h=e.frag.level}}else{h=e.frag.level}}break;case s["ErrorDetails"].LEVEL_LOAD_ERROR:case s["ErrorDetails"].LEVEL_LOAD_TIMEOUT:if(n){if(n.deliveryDirectives){o=false}h=n.level}u=true;break;case s["ErrorDetails"].REMUX_ALLOC_ERROR:h=e.level;u=true;break}if(h!==undefined){this.recoverLevel(e,h,u,o)}};r.recoverLevel=function t(i,r,e,n){var s=i.details;var a=this._levels[r];a.loadError++;if(e){var u=this.retryLoadingOrFail(i);if(u){i.levelRetry=true}else{this.currentLevelIndex=-1;return}}if(n){var o=a.url.length;if(o>1&&a.loadError<o){i.levelRetry=true;this.redundantFailover(r)}else if(this.manualLevelIndex===-1){var f=r===0?this._levels.length-1:r-1;if(this.currentLevelIndex!==f&&this._levels[f].loadError===0){this.warn(s+": switch to "+f);i.levelRetry=true;this.hls.nextAutoLevel=f}}}};r.redundantFailover=function t(i){var r=this._levels[i];var e=r.url.length;if(e>1){var n=(r.urlId+1)%e;this.warn("Switching to redundant URL-id "+n);this._levels.forEach((function(t){t.urlId=n}));this.level=i}};r.onFragLoaded=function t(i,r){var e=r.frag;if(e!==undefined&&e.type===f["PlaylistLevelType"].MAIN){var n=this._levels[e.level];if(n!==undefined){n.fragmentError=0;n.loadError=0}}};r.onLevelLoaded=function t(i,r){var e;var n=r.level,s=r.details;var a=this._levels[n];if(!a){var u;this.warn("Invalid level index "+n);if((u=r.deliveryDirectives)!==null&&u!==void 0&&u.skip){s.deltaUpdateFailed=true}return}if(n===this.currentLevelIndex){if(a.fragmentError===0){a.loadError=0;this.retryCount=0}this.playlistLoaded(n,r,a.details)}else if((e=r.deliveryDirectives)!==null&&e!==void 0&&e.skip){s.deltaUpdateFailed=true}};r.onAudioTrackSwitched=function t(i,r){var e=this.hls.levels[this.currentLevelIndex];if(!e){return}if(e.audioGroupIds){var n=-1;var s=this.hls.audioTracks[r.id].groupId;for(var a=0;a<e.audioGroupIds.length;a++){if(e.audioGroupIds[a]===s){n=a;break}}if(n!==e.urlId){e.urlId=n;this.startLoad()}}};r.loadPlaylist=function t(i){var r=this.currentLevelIndex;var e=this._levels[r];if(this.canLoad&&e&&e.url.length>0){var s=e.urlId;var a=e.url[s];if(i){try{a=i.addDirectives(a)}catch(t){this.warn("Could not construct new URL with HLS Delivery Directives: "+t)}}this.log("Attempt loading level index "+r+(i?" at sn "+i.msn+" part "+i.part:"")+" with URL-id "+s+" "+a);this.clearTimer();this.hls.trigger(n["Events"].LEVEL_LOADING,{url:a,level:r,id:s,deliveryDirectives:i||null})}};r.removeLevel=function t(i,r){var e=function t(i,e){return e!==r};var s=this._levels.filter((function(t,n){if(n!==i){return true}if(t.url.length>1&&r!==undefined){t.url=t.url.filter(e);if(t.audioGroupIds){t.audioGroupIds=t.audioGroupIds.filter(e)}if(t.textGroupIds){t.textGroupIds=t.textGroupIds.filter(e)}t.urlId=0;return true}return false})).map((function(t,i){var r=t.details;if(r!==null&&r!==void 0&&r.fragments){r.fragments.forEach((function(t){t.level=i}))}return t}));this._levels=s;this.hls.trigger(n["Events"].LEVELS_UPDATED,{levels:s})};c(i,[{key:"levels",get:function t(){if(this._levels.length===0){return null}return this._levels}},{key:"level",get:function t(){return this.currentLevelIndex},set:function t(i){var r;var e=this._levels;if(e.length===0){return}if(this.currentLevelIndex===i&&(r=e[i])!==null&&r!==void 0&&r.details){return}if(i<0||i>=e.length){var a=i<0;this.hls.trigger(n["Events"].ERROR,{type:s["ErrorTypes"].OTHER_ERROR,details:s["ErrorDetails"].LEVEL_SWITCH_ERROR,level:i,fatal:a,reason:"invalid level idx"});if(a){return}i=Math.min(i,e.length-1)}this.clearTimer();var u=this.currentLevelIndex;var o=e[u];var f=e[i];this.log("switching to level "+i+" from "+u);this.currentLevelIndex=i;var l=h({},f,{level:i,maxBitrate:f.maxBitrate,uri:f.uri,urlId:f.urlId});delete l._urlId;this.hls.trigger(n["Events"].LEVEL_SWITCHING,l);var c=f.details;if(!c||c.live){var v=this.switchParams(f.uri,o===null||o===void 0?void 0:o.details);this.loadPlaylist(v)}}},{key:"manualLevel",get:function t(){return this.manualLevelIndex},set:function t(i){this.manualLevelIndex=i;if(this._startLevel===undefined){this._startLevel=i}if(i!==-1){this.level=i}}},{key:"firstLevel",get:function t(){return this._firstLevel},set:function t(i){this._firstLevel=i}},{key:"startLevel",get:function t(){if(this._startLevel===undefined){var i=this.hls.config.startLevel;if(i!==undefined){return i}else{return this._firstLevel}}else{return this._startLevel}},set:function t(i){this._startLevel=i}},{key:"nextLoadLevel",get:function t(){if(this.manualLevelIndex!==-1){return this.manualLevelIndex}else{return this.hls.nextAutoLevel}},set:function t(i){this.level=i;if(this.manualLevelIndex===-1){this.hls.nextAutoLevel=i}}}]);return i}(o["default"])},"./src/controller/level-helper.ts":
|
|
86
|
+
/*!****************************************!*\
|
|
87
|
+
!*** ./src/controller/level-helper.ts ***!
|
|
88
|
+
\****************************************/
|
|
89
|
+
/*! exports provided: addGroupId, assignTrackIdsByGroup, updatePTS, updateFragPTSDTS, mergeDetails, mapPartIntersection, mapFragmentIntersection, adjustSliding, addSliding, computeReloadInterval, getFragmentWithSN, getPartWith */function(t,i,r){r.r(i);r.d(i,"addGroupId",(function(){return s}));r.d(i,"assignTrackIdsByGroup",(function(){return a}));r.d(i,"updatePTS",(function(){return u}));r.d(i,"updateFragPTSDTS",(function(){return f}));r.d(i,"mergeDetails",(function(){return h}));r.d(i,"mapPartIntersection",(function(){return l}));r.d(i,"mapFragmentIntersection",(function(){return c}));r.d(i,"adjustSliding",(function(){return v}));r.d(i,"addSliding",(function(){return d}));r.d(i,"computeReloadInterval",(function(){return m}));r.d(i,"getFragmentWithSN",(function(){return p}));r.d(i,"getPartWith",(function(){return g}));var e=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");var n=r(/*! ../utils/logger */"./src/utils/logger.ts");function s(t,i,r){switch(i){case"audio":if(!t.audioGroupIds){t.audioGroupIds=[]}t.audioGroupIds.push(r);break;case"text":if(!t.textGroupIds){t.textGroupIds=[]}t.textGroupIds.push(r);break}}function a(t){var i={};t.forEach((function(t){var r=t.groupId||"";t.id=i[r]=i[r]||0;i[r]++}))}function u(t,i,r){var e=t[i];var n=t[r];o(e,n)}function o(t,i){var r=i.startPTS;if(Object(e["isFiniteNumber"])(r)){var n=0;var s;if(i.sn>t.sn){n=r-t.start;s=t}else{n=t.start-r;s=i}if(s.duration!==n){s.duration=n}}else if(i.sn>t.sn){var a=t.cc===i.cc;if(a&&t.minEndPTS){i.start=t.start+(t.minEndPTS-t.start)}else{i.start=t.start+t.duration}}else{i.start=Math.max(t.start-i.duration,0)}}function f(t,i,r,s,a,u){var f=s-r;if(f<=0){n["logger"].warn("Fragment should have a positive duration",i);s=r+i.duration;u=a+i.duration}var h=r;var l=s;var c=i.startPTS;var v=i.endPTS;if(Object(e["isFiniteNumber"])(c)){var d=Math.abs(c-r);if(!Object(e["isFiniteNumber"])(i.deltaPTS)){i.deltaPTS=d}else{i.deltaPTS=Math.max(d,i.deltaPTS)}h=Math.max(r,c);r=Math.min(r,c);a=Math.min(a,i.startDTS);l=Math.min(s,v);s=Math.max(s,v);u=Math.max(u,i.endDTS)}i.duration=s-r;var m=r-i.start;i.appendedPTS=s;i.start=i.startPTS=r;i.maxStartPTS=h;i.startDTS=a;i.endPTS=s;i.minEndPTS=l;i.endDTS=u;var p=i.sn;if(!t||p<t.startSN||p>t.endSN){return 0}var g;var b=p-t.startSN;var y=t.fragments;y[b]=i;for(g=b;g>0;g--){o(y[g],y[g-1])}for(g=b;g<y.length-1;g++){o(y[g],y[g+1])}if(t.fragmentHint){o(y[y.length-1],t.fragmentHint)}t.PTSKnown=t.alignedSliding=true;return m}function h(t,i){var r=null;var s=t.fragments;for(var a=s.length-1;a>=0;a--){var u=s[a].initSegment;if(u){r=u;break}}if(t.fragmentHint){delete t.fragmentHint.endPTS}var o=0;var h;c(t,i,(function(t,n){if(t.relurl){o=t.cc-n.cc}if(Object(e["isFiniteNumber"])(t.startPTS)&&Object(e["isFiniteNumber"])(t.endPTS)){n.start=n.startPTS=t.startPTS;n.startDTS=t.startDTS;n.appendedPTS=t.appendedPTS;n.maxStartPTS=t.maxStartPTS;n.endPTS=t.endPTS;n.endDTS=t.endDTS;n.minEndPTS=t.minEndPTS;n.duration=t.endPTS-t.startPTS;if(n.duration){h=n}i.PTSKnown=i.alignedSliding=true}n.elementaryStreams=t.elementaryStreams;n.loader=t.loader;n.stats=t.stats;n.urlId=t.urlId;if(t.initSegment){n.initSegment=t.initSegment;r=t.initSegment}}));if(r){var d=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments;d.forEach((function(t){var i;if(!t.initSegment||t.initSegment.relurl===((i=r)===null||i===void 0?void 0:i.relurl)){t.initSegment=r}}))}if(i.skippedSegments){i.deltaUpdateFailed=i.fragments.some((function(t){return!t}));if(i.deltaUpdateFailed){n["logger"].warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var m=i.skippedSegments;m--;){i.fragments.shift()}i.startSN=i.fragments[0].sn;i.startCC=i.fragments[0].cc}}var p=i.fragments;if(o){n["logger"].warn("discontinuity sliding from playlist, take drift into account");for(var g=0;g<p.length;g++){p[g].cc+=o}}if(i.skippedSegments){i.startCC=i.fragments[0].cc}l(t.partList,i.partList,(function(t,i){i.elementaryStreams=t.elementaryStreams;i.stats=t.stats}));if(h){f(i,h,h.startPTS,h.endPTS,h.startDTS,h.endDTS)}else{v(t,i)}if(p.length){i.totalduration=i.edge-p[0].start}i.driftStartTime=t.driftStartTime;i.driftStart=t.driftStart;var b=i.advancedDateTime;if(i.advanced&&b){var y=i.edge;if(!i.driftStart){i.driftStartTime=b;i.driftStart=y}i.driftEndTime=b;i.driftEnd=y}else{i.driftEndTime=t.driftEndTime;i.driftEnd=t.driftEnd;i.advancedDateTime=t.advancedDateTime}}function l(t,i,r){if(t&&i){var e=0;for(var n=0,s=t.length;n<=s;n++){var a=t[n];var u=i[n+e];if(a&&u&&a.index===u.index&&a.fragment.sn===u.fragment.sn){r(a,u)}else{e--}}}}function c(t,i,r){var e=i.skippedSegments;var n=Math.max(t.startSN,i.startSN)-i.startSN;var s=(t.fragmentHint?1:0)+(e?i.endSN:Math.min(t.endSN,i.endSN))-i.startSN;var a=i.startSN-t.startSN;var u=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments;var o=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments;for(var f=n;f<=s;f++){var h=o[a+f];var l=u[f];if(e&&!l&&f<e){l=i.fragments[f]=h}if(h&&l){r(h,l)}}}function v(t,i){var r=i.startSN+i.skippedSegments-t.startSN;var e=t.fragments;if(r<0||r>=e.length){return}d(i,e[r].start)}function d(t,i){if(i){var r=t.fragments;for(var e=t.skippedSegments;e<r.length;e++){r[e].start+=i}if(t.fragmentHint){t.fragmentHint.start+=i}}}function m(t,i){var r=1e3*t.levelTargetDuration;var e=r/2;var n=t.age;var s=n>0&&n<r*3;var a=i.loading.end-i.loading.start;var u;var o=t.availabilityDelay;if(t.updated===false){if(s){var f=333*t.misses;u=Math.max(Math.min(e,a*2),f);t.availabilityDelay=(t.availabilityDelay||0)+u}else{u=e}}else if(s){o=Math.min(o||r/2,n);t.availabilityDelay=o;u=o+r-n}else{u=r-a}return Math.round(u)}function p(t,i,r){if(!t||!t.details){return null}var e=t.details;var n=e.fragments[i-e.startSN];if(n){return n}n=e.fragmentHint;if(n&&n.sn===i){return n}if(i<e.startSN&&r&&r.sn===i){return r}return null}function g(t,i,r){if(!t||!t.details){return null}var e=t.details.partList;if(e){for(var n=e.length;n--;){var s=e[n];if(s.index===r&&s.fragment.sn===i){return s}}}return null}},"./src/controller/stream-controller.ts":
|
|
90
|
+
/*!*********************************************!*\
|
|
91
|
+
!*** ./src/controller/stream-controller.ts ***!
|
|
92
|
+
\*********************************************/
|
|
93
|
+
/*! exports provided: default */function(t,i,r){r.r(i);r.d(i,"default",(function(){return A}));var e=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");var n=r(/*! ./base-stream-controller */"./src/controller/base-stream-controller.ts");var s=r(/*! ../is-supported */"./src/is-supported.ts");var a=r(/*! ../events */"./src/events.ts");var u=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts");var o=r(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts");var f=r(/*! ../types/loader */"./src/types/loader.ts");var h=r(/*! ../loader/fragment */"./src/loader/fragment.ts");var l=r(/*! ../demux/transmuxer-interface */"./src/demux/transmuxer-interface.ts");var c=r(/*! ../types/transmuxer */"./src/types/transmuxer.ts");var v=r(/*! ./gap-controller */"./src/controller/gap-controller.ts");var d=r(/*! ../errors */"./src/errors.ts");var m=r(/*! ../utils/logger */"./src/utils/logger.ts");function p(t,i){for(var r=0;r<i.length;r++){var e=i[r];e.enumerable=e.enumerable||false;e.configurable=true;if("value"in e)e.writable=true;Object.defineProperty(t,e.key,e)}}function g(t,i,r){if(i)p(t.prototype,i);if(r)p(t,r);return t}function b(t,i){t.prototype=Object.create(i.prototype);t.prototype.constructor=t;y(t,i)}function y(t,i){y=Object.setPrototypeOf||function t(i,r){i.__proto__=r;return i};return y(t,i)}var w=100;var A=function(t){b(i,t);function i(i,r){var e;e=t.call(this,i,r,"[stream-controller]")||this;e.audioCodecSwap=false;e.gapController=null;e.level=-1;e._forceStartLoad=false;e.altAudio=false;e.audioOnly=false;e.fragPlaying=null;e.onvplaying=null;e.onvseeked=null;e.fragLastKbps=0;e.stalled=false;e.couldBacktrack=false;e.audioCodecSwitch=false;e.videoBuffer=null;e._registerListeners();return e}var r=i.prototype;r._registerListeners=function t(){var i=this.hls;i.on(a["Events"].MEDIA_ATTACHED,this.onMediaAttached,this);i.on(a["Events"].MEDIA_DETACHING,this.onMediaDetaching,this);i.on(a["Events"].MANIFEST_LOADING,this.onManifestLoading,this);i.on(a["Events"].MANIFEST_PARSED,this.onManifestParsed,this);i.on(a["Events"].LEVEL_LOADING,this.onLevelLoading,this);i.on(a["Events"].LEVEL_LOADED,this.onLevelLoaded,this);i.on(a["Events"].FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this);i.on(a["Events"].ERROR,this.onError,this);i.on(a["Events"].AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this);i.on(a["Events"].AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this);i.on(a["Events"].BUFFER_CREATED,this.onBufferCreated,this);i.on(a["Events"].BUFFER_FLUSHED,this.onBufferFlushed,this);i.on(a["Events"].LEVELS_UPDATED,this.onLevelsUpdated,this);i.on(a["Events"].FRAG_BUFFERED,this.onFragBuffered,this)};r._unregisterListeners=function t(){var i=this.hls;i.off(a["Events"].MEDIA_ATTACHED,this.onMediaAttached,this);i.off(a["Events"].MEDIA_DETACHING,this.onMediaDetaching,this);i.off(a["Events"].MANIFEST_LOADING,this.onManifestLoading,this);i.off(a["Events"].MANIFEST_PARSED,this.onManifestParsed,this);i.off(a["Events"].LEVEL_LOADED,this.onLevelLoaded,this);i.off(a["Events"].FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this);i.off(a["Events"].ERROR,this.onError,this);i.off(a["Events"].AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this);i.off(a["Events"].AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this);i.off(a["Events"].BUFFER_CREATED,this.onBufferCreated,this);i.off(a["Events"].BUFFER_FLUSHED,this.onBufferFlushed,this);i.off(a["Events"].LEVELS_UPDATED,this.onLevelsUpdated,this);i.off(a["Events"].FRAG_BUFFERED,this.onFragBuffered,this)};r.onHandlerDestroying=function t(){this._unregisterListeners();this.onMediaDetaching()};r.startLoad=function t(i){if(this.levels){var r=this.lastCurrentTime,e=this.hls;this.stopLoad();this.setInterval(w);this.level=-1;this.fragLoadError=0;if(!this.startFragRequested){var s=e.startLevel;if(s===-1){if(e.config.testBandwidth){s=0;this.bitrateTest=true}else{s=e.nextAutoLevel}}this.level=e.nextLoadLevel=s;this.loadedmetadata=false}if(r>0&&i===-1){this.log("Override startPosition with lastCurrentTime @"+r.toFixed(3));i=r}this.state=n["State"].IDLE;this.nextLoadPosition=this.startPosition=this.lastCurrentTime=i;this.tick()}else{this._forceStartLoad=true;this.state=n["State"].STOPPED}};r.stopLoad=function i(){this._forceStartLoad=false;t.prototype.stopLoad.call(this)};r.doTick=function t(){switch(this.state){case n["State"].IDLE:this.doTickIdle();break;case n["State"].WAITING_LEVEL:{var i;var r=this.levels,e=this.level;var s=r===null||r===void 0?void 0:(i=r[e])===null||i===void 0?void 0:i.details;if(s&&(!s.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(s)){break}this.state=n["State"].IDLE;break}break}case n["State"].FRAG_LOADING_WAITING_RETRY:{var a;var u=self.performance.now();var o=this.retryDate;if(!o||u>=o||(a=this.media)!==null&&a!==void 0&&a.seeking){this.log("retryDate reached, switch back to IDLE state");this.state=n["State"].IDLE}}break}this.onTickEnd()};r.onTickEnd=function i(){t.prototype.onTickEnd.call(this);this.checkBuffer();this.checkFragmentChanged()};r.doTickIdle=function t(){var i,r;var e=this.hls,s=this.levelLastLoaded,u=this.levels,l=this.media;var c=e.config,v=e.nextLoadLevel;if(s===null||!l&&(this.startFragRequested||!c.startFragPrefetch)){return}if(this.altAudio&&this.audioOnly){return}if(!u||!u[v]){return}var d=u[v];this.level=e.nextLoadLevel=v;var m=d.details;if(!m||this.state===n["State"].WAITING_LEVEL||m.live&&this.levelLastLoaded!==v){this.state=n["State"].WAITING_LEVEL;return}var p=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:l,f["PlaylistLevelType"].MAIN);if(p===null){return}var g=p.len;var b=this.getMaxBufferLength(d.maxBitrate);if(g>=b){return}if(this._streamEnded(p,m)){var y={};if(this.altAudio){y.type="video"}this.hls.trigger(a["Events"].BUFFER_EOS,y);this.state=n["State"].ENDED;return}var w=p.end;var A=this.getNextFragment(w,m);if(this.couldBacktrack&&!this.fragPrevious&&A&&A.sn!=="initSegment"){var k=A.sn-m.startSN;if(k>1){A=m.fragments[k-1];this.fragmentTracker.removeFragment(A)}}if(A&&this.fragmentTracker.getState(A)===o["FragmentState"].OK&&this.nextLoadPosition>w){var T=this.audioOnly&&!this.altAudio?h["ElementaryStreamTypes"].AUDIO:h["ElementaryStreamTypes"].VIDEO;this.afterBufferFlushed(l,T,f["PlaylistLevelType"].MAIN);A=this.getNextFragment(this.nextLoadPosition,m)}if(!A){return}if(A.initSegment&&!A.initSegment.data&&!this.bitrateTest){A=A.initSegment}if(((i=A.decryptdata)===null||i===void 0?void 0:i.keyFormat)==="identity"&&!((r=A.decryptdata)!==null&&r!==void 0&&r.key)){this.loadKey(A,m)}else{this.loadFragment(A,m,w)}};r.loadFragment=function i(r,e,n){var s;var a=this.fragmentTracker.getState(r);this.fragCurrent=r;if(a===o["FragmentState"].BACKTRACKED){var u=this.fragmentTracker.getBacktrackData(r);if(u){this._handleFragmentLoadProgress(u);this._handleFragmentLoadComplete(u);return}else{a=o["FragmentState"].NOT_LOADED}}if(a===o["FragmentState"].NOT_LOADED||a===o["FragmentState"].PARTIAL){if(r.sn==="initSegment"){this._loadInitSegment(r)}else if(this.bitrateTest){r.bitrateTest=true;this.log("Fragment "+r.sn+" of level "+r.level+" is being downloaded to test bitrate and will not be buffered");this._loadBitrateTestFrag(r)}else{this.startFragRequested=true;t.prototype.loadFragment.call(this,r,e,n)}}else if(a===o["FragmentState"].APPENDING){if(this.reduceMaxBufferLength(r.duration)){this.fragmentTracker.removeFragment(r)}}else if(((s=this.media)===null||s===void 0?void 0:s.buffered.length)===0){this.fragmentTracker.removeAllFragments()}};r.getAppendedFrag=function t(i){var r=this.fragmentTracker.getAppendedFrag(i,f["PlaylistLevelType"].MAIN);if(r&&"fragment"in r){return r.fragment}return r};r.getBufferedFrag=function t(i){return this.fragmentTracker.getBufferedFrag(i,f["PlaylistLevelType"].MAIN)};r.followingBufferedFrag=function t(i){if(i){return this.getBufferedFrag(i.end+.5)}return null};r.immediateLevelSwitch=function t(){this.abortCurrentFrag();this.flushMainBuffer(0,Number.POSITIVE_INFINITY)};r.nextLevelSwitch=function t(){var i=this.levels,r=this.media;if(r!==null&&r!==void 0&&r.readyState){var e;var n=this.getAppendedFrag(r.currentTime);if(n&&n.start>1){this.flushMainBuffer(0,n.start-1)}if(!r.paused&&i){var s=this.hls.nextLoadLevel;var a=i[s];var u=this.fragLastKbps;if(u&&this.fragCurrent){e=this.fragCurrent.duration*a.maxBitrate/(1e3*u)+1}else{e=0}}else{e=0}var o=this.getBufferedFrag(r.currentTime+e);if(o){var f=this.followingBufferedFrag(o);if(f){this.abortCurrentFrag();var h=f.maxStartPTS?f.maxStartPTS:f.start;var l=f.duration;var c=Math.max(o.end,h+Math.min(Math.max(l-this.config.maxFragLookUpTolerance,l*.5),l*.75));this.flushMainBuffer(c,Number.POSITIVE_INFINITY)}}}};r.abortCurrentFrag=function t(){var i=this.fragCurrent;this.fragCurrent=null;if(i!==null&&i!==void 0&&i.loader){i.loader.abort()}if(this.state===n["State"].KEY_LOADING){this.state=n["State"].IDLE}this.nextLoadPosition=this.getLoadPosition()};r.flushMainBuffer=function i(r,e){t.prototype.flushMainBuffer.call(this,r,e,this.altAudio?"video":null)};r.onMediaAttached=function i(r,e){t.prototype.onMediaAttached.call(this,r,e);var n=e.media;this.onvplaying=this.onMediaPlaying.bind(this);this.onvseeked=this.onMediaSeeked.bind(this);n.addEventListener("playing",this.onvplaying);n.addEventListener("seeked",this.onvseeked);this.gapController=new v["default"](this.config,n,this.fragmentTracker,this.hls)};r.onMediaDetaching=function i(){var r=this.media;if(r){r.removeEventListener("playing",this.onvplaying);r.removeEventListener("seeked",this.onvseeked);this.onvplaying=this.onvseeked=null;this.videoBuffer=null}this.fragPlaying=null;if(this.gapController){this.gapController.destroy();this.gapController=null}t.prototype.onMediaDetaching.call(this)};r.onMediaPlaying=function t(){this.tick()};r.onMediaSeeked=function t(){var i=this.media;var r=i?i.currentTime:null;if(Object(e["isFiniteNumber"])(r)){this.log("Media seeked to "+r.toFixed(3))}this.tick()};r.onManifestLoading=function t(){this.log("Trigger BUFFER_RESET");this.hls.trigger(a["Events"].BUFFER_RESET,undefined);this.fragmentTracker.removeAllFragments();this.couldBacktrack=this.stalled=false;this.startPosition=this.lastCurrentTime=0;this.fragPlaying=null};r.onManifestParsed=function t(i,r){var e=false;var n=false;var a;r.levels.forEach((function(t){a=t.audioCodec;if(a){if(a.indexOf("mp4a.40.2")!==-1){e=true}if(a.indexOf("mp4a.40.5")!==-1){n=true}}}));this.audioCodecSwitch=e&&n&&!Object(s["changeTypeSupported"])();if(this.audioCodecSwitch){this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC")}this.levels=r.levels;this.startFragRequested=false};r.onLevelLoading=function t(i,r){var e=this.levels;if(!e||this.state!==n["State"].IDLE){return}var s=e[r.level];if(!s.details||s.details.live&&this.levelLastLoaded!==r.level||this.waitForCdnTuneIn(s.details)){this.state=n["State"].WAITING_LEVEL}};r.onLevelLoaded=function t(i,r){var e;var s=this.levels;var u=r.level;var o=r.details;var f=o.totalduration;if(!s){this.warn("Levels were reset while loading level "+u);return}this.log("Level "+u+" loaded ["+o.startSN+","+o.endSN+"], cc ["+o.startCC+", "+o.endCC+"] duration:"+f);var h=this.fragCurrent;if(h&&(this.state===n["State"].FRAG_LOADING||this.state===n["State"].FRAG_LOADING_WAITING_RETRY)){if(h.level!==r.level&&h.loader){this.state=n["State"].IDLE;h.loader.abort()}}var l=s[u];var c=0;if(o.live||(e=l.details)!==null&&e!==void 0&&e.live){if(!o.fragments[0]){o.deltaUpdateFailed=true}if(o.deltaUpdateFailed){return}c=this.alignPlaylists(o,l.details)}l.details=o;this.levelLastLoaded=u;this.hls.trigger(a["Events"].LEVEL_UPDATED,{details:o,level:u});if(this.state===n["State"].WAITING_LEVEL){if(this.waitForCdnTuneIn(o)){return}this.state=n["State"].IDLE}if(!this.startFragRequested){this.setStartPosition(o,c)}else if(o.live){this.synchronizeToLiveEdge(o)}this.tick()};r._handleFragmentLoadProgress=function t(i){var r;var e=i.frag,n=i.part,s=i.payload;var a=this.levels;if(!a){this.warn("Levels were reset while fragment load was in progress. Fragment "+e.sn+" of level "+e.level+" will not be buffered");return}var u=a[e.level];var o=u.details;if(!o){this.warn("Dropping fragment "+e.sn+" of level "+e.level+" after level details were reset");return}var h=u.videoCodec;var v=o.PTSKnown||!o.live;var d=(r=e.initSegment)===null||r===void 0?void 0:r.data;var m=this._getAudioCodec(u);var p=this.transmuxer=this.transmuxer||new l["default"](this.hls,f["PlaylistLevelType"].MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this));var g=n?n.index:-1;var b=g!==-1;var y=new c["ChunkMetadata"](e.level,e.sn,e.stats.chunkCount,s.byteLength,g,b);var w=this.initPTS[e.cc];p.push(s,d,m,h,e,n,o.totalduration,v,y,w)};r.onAudioTrackSwitching=function t(i,r){var e=this.altAudio;var n=!!r.url;var s=r.id;if(!n){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading");this.mediaBuffer=this.media;var u=this.fragCurrent;if(u!==null&&u!==void 0&&u.loader){this.log("Switching to main audio track, cancel main fragment load");u.loader.abort()}this.resetTransmuxer();this.resetLoadingState()}else if(this.audioOnly){this.resetTransmuxer()}var o=this.hls;if(e){o.trigger(a["Events"].BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"})}o.trigger(a["Events"].AUDIO_TRACK_SWITCHED,{id:s})}};r.onAudioTrackSwitched=function t(i,r){var e=r.id;var n=!!this.hls.audioTracks[e].url;if(n){var s=this.videoBuffer;if(s&&this.mediaBuffer!==s){this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading");this.mediaBuffer=s}}this.altAudio=n;this.tick()};r.onBufferCreated=function t(i,r){var e=r.tracks;var n;var s;var a=false;for(var u in e){var o=e[u];if(o.id==="main"){s=u;n=o;if(u==="video"){var f=e[u];if(f){this.videoBuffer=f.buffer}}}else{a=true}}if(a&&n){this.log("Alternate track found, use "+s+".buffered to schedule main fragment loading");this.mediaBuffer=n.buffer}else{this.mediaBuffer=this.media}};r.onFragBuffered=function t(i,r){var e=r.frag,s=r.part;if(e&&e.type!==f["PlaylistLevelType"].MAIN){return}if(this.fragContextChanged(e)){this.warn("Fragment "+e.sn+(s?" p: "+s.index:"")+" of level "+e.level+" finished buffering, but was aborted. state: "+this.state);if(this.state===n["State"].PARSED){this.state=n["State"].IDLE}return}var a=s?s.stats:e.stats;this.fragLastKbps=Math.round(8*a.total/(a.buffering.end-a.loading.first));if(e.sn!=="initSegment"){this.fragPrevious=e}this.fragBufferedComplete(e,s)};r.onError=function t(i,r){switch(r.details){case d["ErrorDetails"].FRAG_LOAD_ERROR:case d["ErrorDetails"].FRAG_LOAD_TIMEOUT:case d["ErrorDetails"].KEY_LOAD_ERROR:case d["ErrorDetails"].KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(f["PlaylistLevelType"].MAIN,r);break;case d["ErrorDetails"].LEVEL_LOAD_ERROR:case d["ErrorDetails"].LEVEL_LOAD_TIMEOUT:if(this.state!==n["State"].ERROR){if(r.fatal){this.warn(""+r.details);this.state=n["State"].ERROR}else{if(!r.levelRetry&&this.state===n["State"].WAITING_LEVEL){this.state=n["State"].IDLE}}}break;case d["ErrorDetails"].BUFFER_FULL_ERROR:if(r.parent==="main"&&(this.state===n["State"].PARSING||this.state===n["State"].PARSED)){var e=true;var s=this.getFwdBufferInfo(this.media,f["PlaylistLevelType"].MAIN);if(s&&s.len>.5){e=!this.reduceMaxBufferLength(s.len)}if(e){this.warn("buffer full error also media.currentTime is not buffered, flush main");this.immediateLevelSwitch()}this.resetLoadingState()}break}};r.checkBuffer=function t(){var i=this.media,r=this.gapController;if(!i||!r||!i.readyState){return}var e=u["BufferHelper"].getBuffered(i);if(!this.loadedmetadata&&e.length){this.loadedmetadata=true;this.seekToStartPos()}else{r.poll(this.lastCurrentTime)}this.lastCurrentTime=i.currentTime};r.onFragLoadEmergencyAborted=function t(){this.state=n["State"].IDLE;if(!this.loadedmetadata){this.startFragRequested=false;this.nextLoadPosition=this.startPosition}this.tickImmediate()};r.onBufferFlushed=function t(i,r){var e=r.type;if(e!==h["ElementaryStreamTypes"].AUDIO||this.audioOnly&&!this.altAudio){var n=(e===h["ElementaryStreamTypes"].VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(n,e,f["PlaylistLevelType"].MAIN)}};r.onLevelsUpdated=function t(i,r){this.levels=r.levels};r.swapAudioCodec=function t(){this.audioCodecSwap=!this.audioCodecSwap};r.seekToStartPos=function t(){var i=this.media;var r=i.currentTime;var e=this.startPosition;if(e>=0&&r<e){if(i.seeking){m["logger"].log("could not seek to "+e+", already seeking at "+r);return}var n=u["BufferHelper"].getBuffered(i);var s=n.length?n.start(0):0;var a=s-e;if(a>0&&(a<this.config.maxBufferHole||a<this.config.maxFragLookUpTolerance)){m["logger"].log("adjusting start position by "+a+" to match buffer start");e+=a;this.startPosition=e}this.log("seek to target start position "+e+" from current time "+r);i.currentTime=e}};r._getAudioCodec=function t(i){var r=this.config.defaultAudioCodec||i.audioCodec;if(this.audioCodecSwap&&r){this.log("Swapping audio codec");if(r.indexOf("mp4a.40.5")!==-1){r="mp4a.40.2"}else{r="mp4a.40.5"}}return r};r._loadBitrateTestFrag=function t(i){var r=this;this._doFragLoad(i).then((function(t){var e=r.hls;if(!t||e.nextLoadLevel||r.fragContextChanged(i)){return}r.fragLoadError=0;r.state=n["State"].IDLE;r.startFragRequested=false;r.bitrateTest=false;var s=i.stats;s.parsing.start=s.parsing.end=s.buffering.start=s.buffering.end=self.performance.now();e.trigger(a["Events"].FRAG_LOADED,t)}))};r._handleTransmuxComplete=function t(i){var r;var s="main";var u=this.hls;var o=i.remuxResult,f=i.chunkMeta;var l=this.getCurrentContext(f);if(!l){this.warn("The loading context changed while buffering fragment "+f.sn+" of level "+f.level+". This chunk will not be buffered.");this.resetLiveStartWhenNotLoaded(f.level);return}var c=l.frag,v=l.part,d=l.level;var m=o.video,p=o.text,g=o.id3,b=o.initSegment;var y=this.altAudio?undefined:o.audio;if(this.fragContextChanged(c)){return}this.state=n["State"].PARSING;if(b){if(b.tracks){this._bufferInitSegment(d,b.tracks,c,f);u.trigger(a["Events"].FRAG_PARSING_INIT_SEGMENT,{frag:c,id:s,tracks:b.tracks})}var w=b.initPTS;var A=b.timescale;if(Object(e["isFiniteNumber"])(w)){this.initPTS[c.cc]=w;u.trigger(a["Events"].INIT_PTS_FOUND,{frag:c,id:s,initPTS:w,timescale:A})}}if(m&&o.independent!==false){if(d.details){var k=m.startPTS,T=m.endPTS,E=m.startDTS,O=m.endDTS;if(v){v.elementaryStreams[m.type]={startPTS:k,endPTS:T,startDTS:E,endDTS:O}}else{if(m.firstKeyFrame&&m.independent){this.couldBacktrack=true}if(m.dropped&&m.independent){var S=this.getLoadPosition()+this.config.maxBufferHole;if(S<k){this.backtrack(c);return}c.setElementaryStreamInfo(m.type,c.start,T,c.start,O,true)}}c.setElementaryStreamInfo(m.type,k,T,E,O);this.bufferFragmentData(m,c,v,f)}}else if(o.independent===false){this.backtrack(c);return}if(y){var M=y.startPTS,x=y.endPTS,j=y.startDTS,D=y.endDTS;if(v){v.elementaryStreams[h["ElementaryStreamTypes"].AUDIO]={startPTS:M,endPTS:x,startDTS:j,endDTS:D}}c.setElementaryStreamInfo(h["ElementaryStreamTypes"].AUDIO,M,x,j,D);this.bufferFragmentData(y,c,v,f)}if(g!==null&&g!==void 0&&(r=g.samples)!==null&&r!==void 0&&r.length){var I={frag:c,id:s,samples:g.samples};u.trigger(a["Events"].FRAG_PARSING_METADATA,I)}if(p){var L={frag:c,id:s,samples:p.samples};u.trigger(a["Events"].FRAG_PARSING_USERDATA,L)}};r._bufferInitSegment=function t(i,r,e,s){var u=this;if(this.state!==n["State"].PARSING){return}this.audioOnly=!!r.audio&&!r.video;if(this.altAudio&&!this.audioOnly){delete r.audio}var o=r.audio,f=r.video,h=r.audiovideo;if(o){var l=i.audioCodec;var c=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){if(l){if(l.indexOf("mp4a.40.5")!==-1){l="mp4a.40.2"}else{l="mp4a.40.5"}}if(o.metadata.channelCount!==1&&c.indexOf("firefox")===-1){l="mp4a.40.5"}}if(c.indexOf("android")!==-1&&o.container!=="audio/mpeg"){l="mp4a.40.2";this.log("Android: force audio codec to "+l)}if(i.audioCodec&&i.audioCodec!==l){this.log('Swapping manifest audio codec "'+i.audioCodec+'" for "'+l+'"')}o.levelCodec=l;o.id="main";this.log("Init audio buffer, container:"+o.container+", codecs[selected/level/parsed]=["+(l||"")+"/"+(i.audioCodec||"")+"/"+o.codec+"]")}if(f){f.levelCodec=i.videoCodec;f.id="main";this.log("Init video buffer, container:"+f.container+", codecs[level/parsed]=["+(i.videoCodec||"")+"/"+f.codec+"]")}if(h){this.log("Init audiovideo buffer, container:"+h.container+", codecs[level/parsed]=["+(i.attrs.CODECS||"")+"/"+h.codec+"]")}this.hls.trigger(a["Events"].BUFFER_CODECS,r);Object.keys(r).forEach((function(t){var i=r[t];var n=i.initSegment;if(n!==null&&n!==void 0&&n.byteLength){u.hls.trigger(a["Events"].BUFFER_APPENDING,{type:t,data:n,frag:e,part:null,chunkMeta:s,parent:e.type})}}));this.tick()};r.backtrack=function t(i){this.couldBacktrack=true;this.resetTransmuxer();this.flushBufferGap(i);var r=this.fragmentTracker.backtrack(i);this.fragPrevious=null;this.nextLoadPosition=i.start;if(r){this.resetFragmentLoading(i)}else{this.state=n["State"].BACKTRACKING}};r.checkFragmentChanged=function t(){var i=this.media;var r=null;if(i&&i.readyState>1&&i.seeking===false){var e=i.currentTime;if(u["BufferHelper"].isBuffered(i,e)){r=this.getAppendedFrag(e)}else if(u["BufferHelper"].isBuffered(i,e+.1)){r=this.getAppendedFrag(e+.1)}if(r){var n=this.fragPlaying;var s=r.level;if(!n||r.sn!==n.sn||n.level!==s||r.urlId!==n.urlId){this.hls.trigger(a["Events"].FRAG_CHANGED,{frag:r});if(!n||n.level!==s){this.hls.trigger(a["Events"].LEVEL_SWITCHED,{level:s})}this.fragPlaying=r}}}};g(i,[{key:"nextLevel",get:function t(){var i=this.nextBufferedFrag;if(i){return i.level}else{return-1}}},{key:"currentLevel",get:function t(){var i=this.media;if(i){var r=this.getAppendedFrag(i.currentTime);if(r){return r.level}}return-1}},{key:"nextBufferedFrag",get:function t(){var i=this.media;if(i){var r=this.getAppendedFrag(i.currentTime);return this.followingBufferedFrag(r)}else{return null}}},{key:"forceStartLoad",get:function t(){return this._forceStartLoad}}]);return i}(n["default"])},"./src/controller/subtitle-stream-controller.ts":
|
|
94
|
+
/*!******************************************************!*\
|
|
95
|
+
!*** ./src/controller/subtitle-stream-controller.ts ***!
|
|
96
|
+
\******************************************************/
|
|
97
|
+
/*! exports provided: SubtitleStreamController */function(t,i,r){r.r(i);r.d(i,"SubtitleStreamController",(function(){return g}));var e=r(/*! ../events */"./src/events.ts");var n=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts");var s=r(/*! ./fragment-finders */"./src/controller/fragment-finders.ts");var a=r(/*! ../utils/discontinuities */"./src/utils/discontinuities.ts");var u=r(/*! ./level-helper */"./src/controller/level-helper.ts");var o=r(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts");var f=r(/*! ./base-stream-controller */"./src/controller/base-stream-controller.ts");var h=r(/*! ../types/loader */"./src/types/loader.ts");var l=r(/*! ../types/level */"./src/types/level.ts");function c(t,i){for(var r=0;r<i.length;r++){var e=i[r];e.enumerable=e.enumerable||false;e.configurable=true;if("value"in e)e.writable=true;Object.defineProperty(t,e.key,e)}}function v(t,i,r){if(i)c(t.prototype,i);if(r)c(t,r);return t}function d(t,i){t.prototype=Object.create(i.prototype);t.prototype.constructor=t;m(t,i)}function m(t,i){m=Object.setPrototypeOf||function t(i,r){i.__proto__=r;return i};return m(t,i)}var p=500;var g=function(t){d(i,t);function i(i,r){var e;e=t.call(this,i,r,"[subtitle-stream-controller]")||this;e.levels=[];e.currentTrackId=-1;e.tracksBuffered=[];e.mainDetails=null;e._registerListeners();return e}var r=i.prototype;r.onHandlerDestroying=function t(){this._unregisterListeners();this.mainDetails=null};r._registerListeners=function t(){var i=this.hls;i.on(e["Events"].MEDIA_ATTACHED,this.onMediaAttached,this);i.on(e["Events"].MEDIA_DETACHING,this.onMediaDetaching,this);i.on(e["Events"].MANIFEST_LOADING,this.onManifestLoading,this);i.on(e["Events"].LEVEL_LOADED,this.onLevelLoaded,this);i.on(e["Events"].ERROR,this.onError,this);i.on(e["Events"].SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this);i.on(e["Events"].SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this);i.on(e["Events"].SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this);i.on(e["Events"].SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this);i.on(e["Events"].BUFFER_FLUSHING,this.onBufferFlushing,this)};r._unregisterListeners=function t(){var i=this.hls;i.off(e["Events"].MEDIA_ATTACHED,this.onMediaAttached,this);i.off(e["Events"].MEDIA_DETACHING,this.onMediaDetaching,this);i.off(e["Events"].MANIFEST_LOADING,this.onManifestLoading,this);i.off(e["Events"].LEVEL_LOADED,this.onLevelLoaded,this);i.off(e["Events"].ERROR,this.onError,this);i.off(e["Events"].SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this);i.off(e["Events"].SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this);i.off(e["Events"].SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this);i.off(e["Events"].SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this);i.off(e["Events"].BUFFER_FLUSHING,this.onBufferFlushing,this)};r.startLoad=function t(){this.stopLoad();this.state=f["State"].IDLE;this.setInterval(p);this.tick()};r.onManifestLoading=function t(){this.mainDetails=null;this.fragmentTracker.removeAllFragments()};r.onLevelLoaded=function t(i,r){this.mainDetails=r.details};r.onSubtitleFragProcessed=function t(i,r){var e=r.frag,n=r.success;this.fragPrevious=e;this.state=f["State"].IDLE;if(!n){return}var s=this.tracksBuffered[this.currentTrackId];if(!s){return}var a;var u=e.start;for(var o=0;o<s.length;o++){if(u>=s[o].start&&u<=s[o].end){a=s[o];break}}var h=e.start+e.duration;if(a){a.end=h}else{a={start:u,end:h};s.push(a)}this.fragmentTracker.fragBuffered(e)};r.onBufferFlushing=function t(i,r){var e=r.startOffset,n=r.endOffset;if(e===0&&n!==Number.POSITIVE_INFINITY){var s=this.currentTrackId,a=this.levels;if(!a.length||!a[s]||!a[s].details){return}var u=a[s].details;var o=u.targetduration;var f=n-o;if(f<=0){return}r.endOffsetSubtitles=Math.max(0,f);this.tracksBuffered.forEach((function(t){for(var i=0;i<t.length;){if(t[i].end<=f){t.shift();continue}else if(t[i].start<f){t[i].start=f}else{break}i++}}));this.fragmentTracker.removeFragmentsInRange(e,f,h["PlaylistLevelType"].SUBTITLE)}};r.onError=function t(i,r){var e;var n=r.frag;if(!n||n.type!==h["PlaylistLevelType"].SUBTITLE){return}if((e=this.fragCurrent)!==null&&e!==void 0&&e.loader){this.fragCurrent.loader.abort()}this.state=f["State"].IDLE};r.onSubtitleTracksUpdated=function t(i,r){var e=this;var n=r.subtitleTracks;this.tracksBuffered=[];this.levels=n.map((function(t){return new l["Level"](t)}));this.fragmentTracker.removeAllFragments();this.fragPrevious=null;this.levels.forEach((function(t){e.tracksBuffered[t.id]=[]}));this.mediaBuffer=null};r.onSubtitleTrackSwitch=function t(i,r){this.currentTrackId=r.id;if(!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}var e=this.levels[this.currentTrackId];if(e!==null&&e!==void 0&&e.details){this.mediaBuffer=this.mediaBufferTimeRanges}else{this.mediaBuffer=null}if(e){this.setInterval(p)}};r.onSubtitleTrackLoaded=function t(i,r){var e;var n=r.details,o=r.id;var h=this.currentTrackId,l=this.levels;if(!l.length){return}var c=l[h];if(o>=l.length||o!==h||!c){return}this.mediaBuffer=this.mediaBufferTimeRanges;if(n.live||(e=c.details)!==null&&e!==void 0&&e.live){var v=this.mainDetails;if(n.deltaUpdateFailed||!v){return}var d=v.fragments[0];if(!c.details){if(n.hasProgramDateTime&&v.hasProgramDateTime){Object(a["alignMediaPlaylistByPDT"])(n,v)}else if(d){Object(u["addSliding"])(n,d.start)}}else{var m=this.alignPlaylists(n,c.details);if(m===0&&d){Object(u["addSliding"])(n,d.start)}}}c.details=n;this.levelLastLoaded=o;this.tick();if(n.live&&!this.fragCurrent&&this.media&&this.state===f["State"].IDLE){var p=Object(s["findFragmentByPTS"])(null,n.fragments,this.media.currentTime,0);if(!p){this.warn("Subtitle playlist not aligned with playback");c.details=undefined}}};r._handleFragmentLoadComplete=function t(i){var r=i.frag,n=i.payload;var s=r.decryptdata;var a=this.hls;if(this.fragContextChanged(r)){return}if(n&&n.byteLength>0&&s&&s.key&&s.iv&&s.method==="AES-128"){var u=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(n),s.key.buffer,s.iv.buffer).then((function(t){var i=performance.now();a.trigger(e["Events"].FRAG_DECRYPTED,{frag:r,payload:t,stats:{tstart:u,tdecrypt:i}})}))}};r.doTick=function t(){if(!this.media){this.state=f["State"].IDLE;return}if(this.state===f["State"].IDLE){var i;var r=this.currentTrackId,e=this.levels;if(!e.length||!e[r]||!e[r].details){return}var a=e[r].details;var u=a.targetduration;var h=this.config,l=this.media;var c=n["BufferHelper"].bufferedInfo(this.mediaBufferTimeRanges,l.currentTime-u,h.maxBufferHole);var v=c.end,d=c.len;var m=this.getMaxBufferLength()+u;if(d>m){return}console.assert(a,"Subtitle track details are defined on idle subtitle stream controller tick");var p=a.fragments;var g=p.length;var b=a.edge;var y;var w=this.fragPrevious;if(v<b){var A=h.maxFragLookUpTolerance;y=Object(s["findFragmentByPTS"])(w,p,v,A);if(!y&&w&&w.start<p[0].start){y=p[0]}}else{y=p[g-1]}if((i=y)!==null&&i!==void 0&&i.encrypted){this.loadKey(y,a)}else if(y&&this.fragmentTracker.getState(y)===o["FragmentState"].NOT_LOADED){this.loadFragment(y,a,v)}}};r.loadFragment=function i(r,e,n){this.fragCurrent=r;t.prototype.loadFragment.call(this,r,e,n)};v(i,[{key:"mediaBufferTimeRanges",get:function t(){return this.tracksBuffered[this.currentTrackId]||[]}}]);return i}(f["default"])},"./src/controller/subtitle-track-controller.ts":
|
|
98
|
+
/*!*****************************************************!*\
|
|
99
|
+
!*** ./src/controller/subtitle-track-controller.ts ***!
|
|
100
|
+
\*****************************************************/
|
|
101
|
+
/*! exports provided: default */function(t,i,r){r.r(i);var e=r(/*! ../events */"./src/events.ts");var n=r(/*! ../utils/texttrack-utils */"./src/utils/texttrack-utils.ts");var s=r(/*! ./base-playlist-controller */"./src/controller/base-playlist-controller.ts");var a=r(/*! ../types/loader */"./src/types/loader.ts");function u(t,i){for(var r=0;r<i.length;r++){var e=i[r];e.enumerable=e.enumerable||false;e.configurable=true;if("value"in e)e.writable=true;Object.defineProperty(t,e.key,e)}}function o(t,i,r){if(i)u(t.prototype,i);if(r)u(t,r);return t}function f(t,i){t.prototype=Object.create(i.prototype);t.prototype.constructor=t;h(t,i)}function h(t,i){h=Object.setPrototypeOf||function t(i,r){i.__proto__=r;return i};return h(t,i)}var l=function(t){f(i,t);function i(i){var r;r=t.call(this,i,"[subtitle-track-controller]")||this;r.media=null;r.tracks=[];r.groupId=null;r.tracksInGroup=[];r.trackId=-1;r.selectDefaultTrack=true;r.queuedDefaultTrack=-1;r.trackChangeListener=function(){return r.onTextTracksChanged()};r.asyncPollTrackChange=function(){return r.pollTrackChange(0)};r.useTextTrackPolling=false;r.subtitlePollingInterval=-1;r.subtitleDisplay=true;r.registerListeners();return r}var r=i.prototype;r.destroy=function i(){this.unregisterListeners();this.tracks.length=0;this.tracksInGroup.length=0;this.trackChangeListener=this.asyncPollTrackChange=null;t.prototype.destroy.call(this)};r.registerListeners=function t(){var i=this.hls;i.on(e["Events"].MEDIA_ATTACHED,this.onMediaAttached,this);i.on(e["Events"].MEDIA_DETACHING,this.onMediaDetaching,this);i.on(e["Events"].MANIFEST_LOADING,this.onManifestLoading,this);i.on(e["Events"].MANIFEST_PARSED,this.onManifestParsed,this);i.on(e["Events"].LEVEL_LOADING,this.onLevelLoading,this);i.on(e["Events"].LEVEL_SWITCHING,this.onLevelSwitching,this);i.on(e["Events"].SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this);i.on(e["Events"].ERROR,this.onError,this)};r.unregisterListeners=function t(){var i=this.hls;i.off(e["Events"].MEDIA_ATTACHED,this.onMediaAttached,this);i.off(e["Events"].MEDIA_DETACHING,this.onMediaDetaching,this);i.off(e["Events"].MANIFEST_LOADING,this.onManifestLoading,this);i.off(e["Events"].MANIFEST_PARSED,this.onManifestParsed,this);i.off(e["Events"].LEVEL_LOADING,this.onLevelLoading,this);i.off(e["Events"].LEVEL_SWITCHING,this.onLevelSwitching,this);i.off(e["Events"].SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this);i.off(e["Events"].ERROR,this.onError,this)};r.onMediaAttached=function t(i,r){this.media=r.media;if(!this.media){return}if(this.queuedDefaultTrack>-1){this.subtitleTrack=this.queuedDefaultTrack;this.queuedDefaultTrack=-1}this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks);if(this.useTextTrackPolling){this.pollTrackChange(500)}else{this.media.textTracks.addEventListener("change",this.asyncPollTrackChange)}};r.pollTrackChange=function t(i){self.clearInterval(this.subtitlePollingInterval);this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,i)};r.onMediaDetaching=function t(){if(!this.media){return}self.clearInterval(this.subtitlePollingInterval);if(!this.useTextTrackPolling){this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange)}if(this.trackId>-1){this.queuedDefaultTrack=this.trackId}var i=c(this.media.textTracks);i.forEach((function(t){Object(n["clearCurrentCues"])(t)}));this.subtitleTrack=-1;this.media=null};r.onManifestLoading=function t(){this.tracks=[];this.groupId=null;this.tracksInGroup=[];this.trackId=-1;this.selectDefaultTrack=true};r.onManifestParsed=function t(i,r){this.tracks=r.subtitleTracks};r.onSubtitleTrackLoaded=function t(i,r){var e=r.id,n=r.details;var s=this.trackId;var a=this.tracksInGroup[s];if(!a){this.warn("Invalid subtitle track id "+e);return}var u=a.details;a.details=r.details;this.log("subtitle track "+e+" loaded ["+n.startSN+"-"+n.endSN+"]");if(e===this.trackId){this.retryCount=0;this.playlistLoaded(e,r,u)}};r.onLevelLoading=function t(i,r){this.switchLevel(r.level)};r.onLevelSwitching=function t(i,r){this.switchLevel(r.level)};r.switchLevel=function t(i){var r=this.hls.levels[i];if(!(r!==null&&r!==void 0&&r.textGroupIds)){return}var n=r.textGroupIds[r.urlId];if(this.groupId!==n){var s=this.tracksInGroup?this.tracksInGroup[this.trackId]:undefined;var a=this.tracks.filter((function(t){return!n||t.groupId===n}));this.tracksInGroup=a;var u=this.findTrackId(s===null||s===void 0?void 0:s.name)||this.findTrackId();this.groupId=n;var o={subtitleTracks:a};this.log("Updating subtitle tracks, "+a.length+' track(s) found in "'+n+'" group-id');this.hls.trigger(e["Events"].SUBTITLE_TRACKS_UPDATED,o);if(u!==-1){this.setSubtitleTrack(u,s)}}};r.findTrackId=function t(i){var r=this.tracksInGroup;for(var e=0;e<r.length;e++){var n=r[e];if(!this.selectDefaultTrack||n.default){if(!i||i===n.name){return n.id}}}return-1};r.onError=function i(r,e){t.prototype.onError.call(this,r,e);if(e.fatal||!e.context){return}if(e.context.type===a["PlaylistContextType"].SUBTITLE_TRACK&&e.context.id===this.trackId&&e.context.groupId===this.groupId){this.retryLoadingOrFail(e)}};r.loadPlaylist=function t(i){var r=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(r)){var n=r.id;var s=r.groupId;var a=r.url;if(i){try{a=i.addDirectives(a)}catch(t){this.warn("Could not construct new URL with HLS Delivery Directives: "+t)}}this.log("Loading subtitle playlist for id "+n);this.hls.trigger(e["Events"].SUBTITLE_TRACK_LOADING,{url:a,id:n,groupId:s,deliveryDirectives:i||null})}};r.toggleTrackModes=function t(i){var r=this;var e=this.media,n=this.subtitleDisplay,s=this.trackId;if(!e){return}var a=c(e.textTracks);var u=a.filter((function(t){return t.groupId===r.groupId}));if(i===-1){[].slice.call(a).forEach((function(t){t.mode="disabled"}))}else{var o=u[s];if(o){o.mode="disabled"}}var f=u[i];if(f){f.mode=n?"showing":"hidden"}};r.setSubtitleTrack=function t(i,r){var n;var s=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=i;return}if(this.trackId!==i){this.toggleTrackModes(i)}if(this.trackId===i&&(i===-1||(n=s[i])!==null&&n!==void 0&&n.details)||i<-1||i>=s.length){return}this.clearTimer();var a=s[i];this.log("Switching to subtitle track "+i);this.trackId=i;if(a){var u=a.id,o=a.groupId,f=o===void 0?"":o,h=a.name,l=a.type,c=a.url;this.hls.trigger(e["Events"].SUBTITLE_TRACK_SWITCH,{id:u,groupId:f,name:h,type:l,url:c});var v=this.switchParams(a.url,r===null||r===void 0?void 0:r.details);this.loadPlaylist(v)}else{this.hls.trigger(e["Events"].SUBTITLE_TRACK_SWITCH,{id:i})}};r.onTextTracksChanged=function t(){if(!this.useTextTrackPolling){self.clearInterval(this.subtitlePollingInterval)}if(!this.media||!this.hls.config.renderTextTracksNatively){return}var i=-1;var r=c(this.media.textTracks);for(var e=0;e<r.length;e++){if(r[e].mode==="hidden"){i=e}else if(r[e].mode==="showing"){i=e;break}}if(this.subtitleTrack!==i){this.subtitleTrack=i}};o(i,[{key:"subtitleTracks",get:function t(){return this.tracksInGroup}},{key:"subtitleTrack",get:function t(){return this.trackId},set:function t(i){this.selectDefaultTrack=false;var r=this.tracksInGroup?this.tracksInGroup[this.trackId]:undefined;this.setSubtitleTrack(i,r)}}]);return i}(s["default"]);function c(t){var i=[];for(var r=0;r<t.length;r++){var e=t[r];if(e.kind==="subtitles"&&e.label){i.push(t[r])}}return i}i["default"]=l},"./src/controller/timeline-controller.ts":
|
|
102
|
+
/*!***********************************************!*\
|
|
103
|
+
!*** ./src/controller/timeline-controller.ts ***!
|
|
104
|
+
\***********************************************/
|
|
105
|
+
/*! exports provided: TimelineController */function(t,i,r){r.r(i);r.d(i,"TimelineController",(function(){return c}));var e=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");var n=r(/*! ../events */"./src/events.ts");var s=r(/*! ../utils/cea-608-parser */"./src/utils/cea-608-parser.ts");var a=r(/*! ../utils/output-filter */"./src/utils/output-filter.ts");var u=r(/*! ../utils/webvtt-parser */"./src/utils/webvtt-parser.ts");var o=r(/*! ../utils/texttrack-utils */"./src/utils/texttrack-utils.ts");var f=r(/*! ../utils/imsc1-ttml-parser */"./src/utils/imsc1-ttml-parser.ts");var h=r(/*! ../types/loader */"./src/types/loader.ts");var l=r(/*! ../utils/logger */"./src/utils/logger.ts");var c=function(){function t(t){this.hls=void 0;this.media=null;this.config=void 0;this.enabled=true;this.Cues=void 0;this.textTracks=[];this.tracks=[];this.initPTS=[];this.timescale=[];this.unparsedVttFrags=[];this.captionsTracks={};this.nonNativeCaptionsTracks={};this.cea608Parser1=void 0;this.cea608Parser2=void 0;this.lastSn=-1;this.lastPartIndex=-1;this.prevCC=-1;this.vttCCs=m();this.captionsProperties=void 0;this.hls=t;this.config=t.config;this.Cues=t.config.cueHandler;this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}};if(this.config.enableCEA708Captions){var i=new a["default"](this,"textTrack1");var r=new a["default"](this,"textTrack2");var e=new a["default"](this,"textTrack3");var u=new a["default"](this,"textTrack4");this.cea608Parser1=new s["default"](1,i,r);this.cea608Parser2=new s["default"](3,e,u)}t.on(n["Events"].MEDIA_ATTACHING,this.onMediaAttaching,this);t.on(n["Events"].MEDIA_DETACHING,this.onMediaDetaching,this);t.on(n["Events"].MANIFEST_LOADING,this.onManifestLoading,this);t.on(n["Events"].MANIFEST_LOADED,this.onManifestLoaded,this);t.on(n["Events"].SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this);t.on(n["Events"].FRAG_LOADING,this.onFragLoading,this);t.on(n["Events"].FRAG_LOADED,this.onFragLoaded,this);t.on(n["Events"].FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this);t.on(n["Events"].FRAG_DECRYPTED,this.onFragDecrypted,this);t.on(n["Events"].INIT_PTS_FOUND,this.onInitPtsFound,this);t.on(n["Events"].SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this);t.on(n["Events"].BUFFER_FLUSHING,this.onBufferFlushing,this)}var i=t.prototype;i.destroy=function t(){var i=this.hls;i.off(n["Events"].MEDIA_ATTACHING,this.onMediaAttaching,this);i.off(n["Events"].MEDIA_DETACHING,this.onMediaDetaching,this);i.off(n["Events"].MANIFEST_LOADING,this.onManifestLoading,this);i.off(n["Events"].MANIFEST_LOADED,this.onManifestLoaded,this);i.off(n["Events"].SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this);i.off(n["Events"].FRAG_LOADING,this.onFragLoading,this);i.off(n["Events"].FRAG_LOADED,this.onFragLoaded,this);i.off(n["Events"].FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this);i.off(n["Events"].FRAG_DECRYPTED,this.onFragDecrypted,this);i.off(n["Events"].INIT_PTS_FOUND,this.onInitPtsFound,this);i.off(n["Events"].SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this);i.off(n["Events"].BUFFER_FLUSHING,this.onBufferFlushing,this);this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null};i.addCues=function t(i,r,e,s,a){var u=false;for(var o=a.length;o--;){var f=a[o];var h=d(f[0],f[1],r,e);if(h>=0){f[0]=Math.min(f[0],r);f[1]=Math.max(f[1],e);u=true;if(h/(e-r)>.5){return}}}if(!u){a.push([r,e])}if(this.config.renderTextTracksNatively){var l=this.captionsTracks[i];this.Cues.newCue(l,r,e,s)}else{var c=this.Cues.newCue(null,r,e,s);this.hls.trigger(n["Events"].CUES_PARSED,{type:"captions",cues:c,track:i})}};i.onInitPtsFound=function t(i,r){var e=this;var s=r.frag,a=r.id,u=r.initPTS,o=r.timescale;var f=this.unparsedVttFrags;if(a==="main"){this.initPTS[s.cc]=u;this.timescale[s.cc]=o}if(f.length){this.unparsedVttFrags=[];f.forEach((function(t){e.onFragLoaded(n["Events"].FRAG_LOADED,t)}))}};i.getExistingTrack=function t(i){var r=this.media;if(r){for(var e=0;e<r.textTracks.length;e++){var n=r.textTracks[e];if(n[i]){return n}}}return null};i.createCaptionsTrack=function t(i){if(this.config.renderTextTracksNatively){this.createNativeTrack(i)}else{this.createNonNativeTrack(i)}};i.createNativeTrack=function t(i){if(this.captionsTracks[i]){return}var r=this.captionsProperties,e=this.captionsTracks,n=this.media;var s=r[i],a=s.label,u=s.languageCode;var f=this.getExistingTrack(i);if(!f){var h=this.createTextTrack("captions",a,u);if(h){h[i]=true;e[i]=h}}else{e[i]=f;Object(o["clearCurrentCues"])(e[i]);Object(o["sendAddTrackEvent"])(e[i],n)}};i.createNonNativeTrack=function t(i){if(this.nonNativeCaptionsTracks[i]){return}var r=this.captionsProperties[i];if(!r){return}var e=r.label;var s={_id:i,label:e,kind:"captions",default:r.media?!!r.media.default:false,closedCaptions:r.media};this.nonNativeCaptionsTracks[i]=s;this.hls.trigger(n["Events"].NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[s]})};i.createTextTrack=function t(i,r,e){var n=this.media;if(!n){return}return n.addTextTrack(i,r,e)};i.onMediaAttaching=function t(i,r){this.media=r.media;this._cleanTracks()};i.onMediaDetaching=function t(){var i=this.captionsTracks;Object.keys(i).forEach((function(t){Object(o["clearCurrentCues"])(i[t]);delete i[t]}));this.nonNativeCaptionsTracks={}};i.onManifestLoading=function t(){this.lastSn=-1;this.lastPartIndex=-1;this.prevCC=-1;this.vttCCs=m();this._cleanTracks();this.tracks=[];this.captionsTracks={};this.nonNativeCaptionsTracks={};this.textTracks=[];this.unparsedVttFrags=this.unparsedVttFrags||[];this.initPTS=[];this.timescale=[];if(this.cea608Parser1&&this.cea608Parser2){this.cea608Parser1.reset();this.cea608Parser2.reset()}};i._cleanTracks=function t(){var i=this.media;if(!i){return}var r=i.textTracks;if(r){for(var e=0;e<r.length;e++){Object(o["clearCurrentCues"])(r[e])}}};i.onSubtitleTracksUpdated=function t(i,r){var e=this;this.textTracks=[];var s=r.subtitleTracks||[];var a=s.some((function(t){return t.textCodec===f["IMSC1_CODEC"]}));if(this.config.enableWebVTT||a&&this.config.enableIMSC1){var u=this.tracks&&s&&this.tracks.length===s.length;this.tracks=s||[];if(this.config.renderTextTracksNatively){var h=this.media?this.media.textTracks:[];this.tracks.forEach((function(t,i){var r;if(i<h.length){var n=null;for(var s=0;s<h.length;s++){if(v(h[s],t)){n=h[s];break}}if(n){r=n}}if(r){Object(o["clearCurrentCues"])(r)}else{r=e.createTextTrack("subtitles",t.name,t.lang);if(r){r.mode="disabled"}}if(r){r.groupId=t.groupId;e.textTracks.push(r)}}))}else if(!u&&this.tracks&&this.tracks.length){var l=this.tracks.map((function(t){return{label:t.name,kind:t.type.toLowerCase(),default:t.default,subtitleTrack:t}}));this.hls.trigger(n["Events"].NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:l})}}};i.onManifestLoaded=function t(i,r){var e=this;if(this.config.enableCEA708Captions&&r.captions){r.captions.forEach((function(t){var i=/(?:CC|SERVICE)([1-4])/.exec(t.instreamId);if(!i){return}var r="textTrack"+i[1];var n=e.captionsProperties[r];if(!n){return}n.label=t.name;if(t.lang){n.languageCode=t.lang}n.media=t}))}};i.onFragLoading=function t(i,r){var e=this.cea608Parser1,n=this.cea608Parser2,s=this.lastSn,a=this.lastPartIndex;if(!this.enabled||!(e&&n)){return}if(r.frag.type===h["PlaylistLevelType"].MAIN){var u,o;var f=r.frag.sn;var l=(u=r===null||r===void 0?void 0:(o=r.part)===null||o===void 0?void 0:o.index)!=null?u:-1;if(!(f===s+1||f===s&&l===a+1)){e.reset();n.reset()}this.lastSn=f;this.lastPartIndex=l}};i.onFragLoaded=function t(i,r){var s=r.frag,a=r.payload;var u=this.initPTS,o=this.unparsedVttFrags;if(s.type===h["PlaylistLevelType"].SUBTITLE){if(a.byteLength){if(!Object(e["isFiniteNumber"])(u[s.cc])){o.push(r);if(u.length){this.hls.trigger(n["Events"].SUBTITLE_FRAG_PROCESSED,{success:false,frag:s,error:new Error("Missing initial subtitle PTS")})}return}var l=s.decryptdata;var c="stats"in r;if(l==null||l.key==null||l.method!=="AES-128"||c){var v=this.tracks[s.level];var d=this.vttCCs;if(!d[s.cc]){d[s.cc]={start:s.start,prevCC:this.prevCC,new:true};this.prevCC=s.cc}if(v&&v.textCodec===f["IMSC1_CODEC"]){this._parseIMSC1(s,a)}else{this._parseVTTs(s,a,d)}}}else{this.hls.trigger(n["Events"].SUBTITLE_FRAG_PROCESSED,{success:false,frag:s,error:new Error("Empty subtitle payload")})}}};i._parseIMSC1=function t(i,r){var e=this;var s=this.hls;Object(f["parseIMSC1"])(r,this.initPTS[i.cc],this.timescale[i.cc],(function(t){e._appendCues(t,i.level);s.trigger(n["Events"].SUBTITLE_FRAG_PROCESSED,{success:true,frag:i})}),(function(t){l["logger"].log("Failed to parse IMSC1: "+t);s.trigger(n["Events"].SUBTITLE_FRAG_PROCESSED,{success:false,frag:i,error:t})}))};i._parseVTTs=function t(i,r,e){var s=this;var a=this.hls;Object(u["parseWebVTT"])(r,this.initPTS[i.cc],this.timescale[i.cc],e,i.cc,i.start,(function(t){s._appendCues(t,i.level);a.trigger(n["Events"].SUBTITLE_FRAG_PROCESSED,{success:true,frag:i})}),(function(t){s._fallbackToIMSC1(i,r);l["logger"].log("Failed to parse VTT cue: "+t);a.trigger(n["Events"].SUBTITLE_FRAG_PROCESSED,{success:false,frag:i,error:t})}))};i._fallbackToIMSC1=function t(i,r){var e=this;var n=this.tracks[i.level];if(!n.textCodec){Object(f["parseIMSC1"])(r,this.initPTS[i.cc],this.timescale[i.cc],(function(){n.textCodec=f["IMSC1_CODEC"];e._parseIMSC1(i,r)}),(function(){n.textCodec="wvtt"}))}};i._appendCues=function t(i,r){var e=this.hls;if(this.config.renderTextTracksNatively){var s=this.textTracks[r];if(s.mode==="disabled"){return}i.forEach((function(t){return Object(o["addCueToTrack"])(s,t)}))}else{var a=this.tracks[r];var u=a.default?"default":"subtitles"+r;e.trigger(n["Events"].CUES_PARSED,{type:"subtitles",cues:i,track:u})}};i.onFragDecrypted=function t(i,r){var s=r.frag;if(s.type===h["PlaylistLevelType"].SUBTITLE){if(!Object(e["isFiniteNumber"])(this.initPTS[s.cc])){this.unparsedVttFrags.push(r);return}this.onFragLoaded(n["Events"].FRAG_LOADED,r)}};i.onSubtitleTracksCleared=function t(){this.tracks=[];this.captionsTracks={}};i.onFragParsingUserdata=function t(i,r){var e=this.cea608Parser1,n=this.cea608Parser2;if(!this.enabled||!(e&&n)){return}for(var s=0;s<r.samples.length;s++){var a=r.samples[s].bytes;if(a){var u=this.extractCea608Data(a);e.addData(r.samples[s].pts,u[0]);n.addData(r.samples[s].pts,u[1])}}};i.onBufferFlushing=function t(i,r){var e=r.startOffset,n=r.endOffset,s=r.endOffsetSubtitles,a=r.type;var u=this.media;if(!u||u.currentTime<n){return}if(!a||a==="video"){var f=this.captionsTracks;Object.keys(f).forEach((function(t){return Object(o["removeCuesInRange"])(f[t],e,n)}))}if(this.config.renderTextTracksNatively){if(e===0&&s!==undefined){var h=this.textTracks;Object.keys(h).forEach((function(t){return Object(o["removeCuesInRange"])(h[t],e,s)}))}}};i.extractCea608Data=function t(i){var r=i[0]&31;var e=2;var n=[[],[]];for(var s=0;s<r;s++){var a=i[e++];var u=127&i[e++];var o=127&i[e++];var f=(4&a)!==0;var h=3&a;if(u===0&&o===0){continue}if(f){if(h===0||h===1){n[h].push(u);n[h].push(o)}}}return n};return t}();function v(t,i){return t&&t.label===i.name&&!(t.textTrack1||t.textTrack2)}function d(t,i,r,e){return Math.min(i,e)-Math.max(t,r)}function m(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:false}}}},"./src/crypt/aes-crypto.ts":
|
|
106
|
+
/*!*********************************!*\
|
|
107
|
+
!*** ./src/crypt/aes-crypto.ts ***!
|
|
108
|
+
\*********************************/
|
|
109
|
+
/*! exports provided: default */function(t,i,r){r.r(i);r.d(i,"default",(function(){return e}));var e=function(){function t(t,i){this.subtle=void 0;this.aesIV=void 0;this.subtle=t;this.aesIV=i}var i=t.prototype;i.decrypt=function t(i,r){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},r,i)};return t}()},"./src/crypt/aes-decryptor.ts":
|
|
110
|
+
/*!************************************!*\
|
|
111
|
+
!*** ./src/crypt/aes-decryptor.ts ***!
|
|
112
|
+
\************************************/
|
|
113
|
+
/*! exports provided: removePadding, default */function(t,i,r){r.r(i);r.d(i,"removePadding",(function(){return n}));r.d(i,"default",(function(){return s}));var e=r(/*! ../utils/typed-array */"./src/utils/typed-array.ts");function n(t){var i=t.byteLength;var r=i&&new DataView(t.buffer).getUint8(i-1);if(r){return Object(e["sliceUint8"])(t,0,i-r)}return t}var s=function(){function t(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54];this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)];this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)];this.sBox=new Uint32Array(256);this.invSBox=new Uint32Array(256);this.key=new Uint32Array(0);this.ksRows=0;this.keySize=0;this.keySchedule=void 0;this.invKeySchedule=void 0;this.initTable()}var i=t.prototype;i.uint8ArrayToUint32Array_=function t(i){var r=new DataView(i);var e=new Uint32Array(4);for(var n=0;n<4;n++){e[n]=r.getUint32(n*4)}return e};i.initTable=function t(){var i=this.sBox;var r=this.invSBox;var e=this.subMix;var n=e[0];var s=e[1];var a=e[2];var u=e[3];var o=this.invSubMix;var f=o[0];var h=o[1];var l=o[2];var c=o[3];var v=new Uint32Array(256);var d=0;var m=0;var p=0;for(p=0;p<256;p++){if(p<128){v[p]=p<<1}else{v[p]=p<<1^283}}for(p=0;p<256;p++){var g=m^m<<1^m<<2^m<<3^m<<4;g=g>>>8^g&255^99;i[d]=g;r[g]=d;var b=v[d];var y=v[b];var w=v[y];var A=v[g]*257^g*16843008;n[d]=A<<24|A>>>8;s[d]=A<<16|A>>>16;a[d]=A<<8|A>>>24;u[d]=A;A=w*16843009^y*65537^b*257^d*16843008;f[g]=A<<24|A>>>8;h[g]=A<<16|A>>>16;l[g]=A<<8|A>>>24;c[g]=A;if(!d){d=m=1}else{d=b^v[v[v[w^b]]];m^=v[v[m]]}}};i.expandKey=function t(i){var r=this.uint8ArrayToUint32Array_(i);var e=true;var n=0;while(n<r.length&&e){e=r[n]===this.key[n];n++}if(e){return}this.key=r;var s=this.keySize=r.length;if(s!==4&&s!==6&&s!==8){throw new Error("Invalid aes key size="+s)}var a=this.ksRows=(s+6+1)*4;var u;var o;var f=this.keySchedule=new Uint32Array(a);var h=this.invKeySchedule=new Uint32Array(a);var l=this.sBox;var c=this.rcon;var v=this.invSubMix;var d=v[0];var m=v[1];var p=v[2];var g=v[3];var b;var y;for(u=0;u<a;u++){if(u<s){b=f[u]=r[u];continue}y=b;if(u%s===0){y=y<<8|y>>>24;y=l[y>>>24]<<24|l[y>>>16&255]<<16|l[y>>>8&255]<<8|l[y&255];y^=c[u/s|0]<<24}else if(s>6&&u%s===4){y=l[y>>>24]<<24|l[y>>>16&255]<<16|l[y>>>8&255]<<8|l[y&255]}f[u]=b=(f[u-s]^y)>>>0}for(o=0;o<a;o++){u=a-o;if(o&3){y=f[u]}else{y=f[u-4]}if(o<4||u<=4){h[o]=y}else{h[o]=d[l[y>>>24]]^m[l[y>>>16&255]]^p[l[y>>>8&255]]^g[l[y&255]]}h[o]=h[o]>>>0}};i.networkToHostOrderSwap=function t(i){return i<<24|(i&65280)<<8|(i&16711680)>>8|i>>>24};i.decrypt=function t(i,r,e){var n=this.keySize+6;var s=this.invKeySchedule;var a=this.invSBox;var u=this.invSubMix;var o=u[0];var f=u[1];var h=u[2];var l=u[3];var c=this.uint8ArrayToUint32Array_(e);var v=c[0];var d=c[1];var m=c[2];var p=c[3];var g=new Int32Array(i);var b=new Int32Array(g.length);var y,w,A,k;var T,E,O,S;var M,x,j,D;var I,L;var C=this.networkToHostOrderSwap;while(r<g.length){M=C(g[r]);x=C(g[r+1]);j=C(g[r+2]);D=C(g[r+3]);T=M^s[0];E=D^s[1];O=j^s[2];S=x^s[3];I=4;for(L=1;L<n;L++){y=o[T>>>24]^f[E>>16&255]^h[O>>8&255]^l[S&255]^s[I];w=o[E>>>24]^f[O>>16&255]^h[S>>8&255]^l[T&255]^s[I+1];A=o[O>>>24]^f[S>>16&255]^h[T>>8&255]^l[E&255]^s[I+2];k=o[S>>>24]^f[T>>16&255]^h[E>>8&255]^l[O&255]^s[I+3];T=y;E=w;O=A;S=k;I=I+4}y=a[T>>>24]<<24^a[E>>16&255]<<16^a[O>>8&255]<<8^a[S&255]^s[I];w=a[E>>>24]<<24^a[O>>16&255]<<16^a[S>>8&255]<<8^a[T&255]^s[I+1];A=a[O>>>24]<<24^a[S>>16&255]<<16^a[T>>8&255]<<8^a[E&255]^s[I+2];k=a[S>>>24]<<24^a[T>>16&255]<<16^a[E>>8&255]<<8^a[O&255]^s[I+3];b[r]=C(y^v);b[r+1]=C(k^d);b[r+2]=C(A^m);b[r+3]=C(w^p);v=M;d=x;m=j;p=D;r=r+4}return b.buffer};return t}()},"./src/crypt/decrypter.ts":
|
|
114
|
+
/*!********************************!*\
|
|
115
|
+
!*** ./src/crypt/decrypter.ts ***!
|
|
116
|
+
\********************************/
|
|
117
|
+
/*! exports provided: default */function(t,i,r){r.r(i);r.d(i,"default",(function(){return h}));var e=r(/*! ./aes-crypto */"./src/crypt/aes-crypto.ts");var n=r(/*! ./fast-aes-key */"./src/crypt/fast-aes-key.ts");var s=r(/*! ./aes-decryptor */"./src/crypt/aes-decryptor.ts");var a=r(/*! ../utils/logger */"./src/utils/logger.ts");var u=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts");var o=r(/*! ../utils/typed-array */"./src/utils/typed-array.ts");var f=16;var h=function(){function t(t,i,r){var e=r===void 0?{}:r,n=e.removePKCS7Padding,s=n===void 0?true:n;this.logEnabled=true;this.observer=void 0;this.config=void 0;this.removePKCS7Padding=void 0;this.subtle=null;this.softwareDecrypter=null;this.key=null;this.fastAesKey=null;this.remainderData=null;this.currentIV=null;this.currentResult=null;this.observer=t;this.config=i;this.removePKCS7Padding=s;if(s){try{var a=self.crypto;if(a){this.subtle=a.subtle||a.webkitSubtle}}catch(t){}}if(this.subtle===null){this.config.enableSoftwareAES=true}}var i=t.prototype;i.destroy=function t(){this.observer=null};i.isSync=function t(){return this.config.enableSoftwareAES};i.flush=function t(){var i=this.currentResult;if(!i){this.reset();return}var r=new Uint8Array(i);this.reset();if(this.removePKCS7Padding){return Object(s["removePadding"])(r)}return r};i.reset=function t(){this.currentResult=null;this.currentIV=null;this.remainderData=null;if(this.softwareDecrypter){this.softwareDecrypter=null}};i.decrypt=function t(i,r,e,n){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(i),r,e);var s=this.flush();if(s){n(s.buffer)}}else{this.webCryptoDecrypt(new Uint8Array(i),r,e).then(n)}};i.softwareDecrypt=function t(i,r,e){var n=this.currentIV,a=this.currentResult,f=this.remainderData;this.logOnce("JS AES decrypt");if(f){i=Object(u["appendUint8Array"])(f,i);this.remainderData=null}var h=this.getValidChunk(i);if(!h.length){return null}if(n){e=n}var l=this.softwareDecrypter;if(!l){l=this.softwareDecrypter=new s["default"]}l.expandKey(r);var c=a;this.currentResult=l.decrypt(h.buffer,0,e);this.currentIV=Object(o["sliceUint8"])(h,-16).buffer;if(!c){return null}return c};i.webCryptoDecrypt=function t(i,r,s){var a=this;var u=this.subtle;if(this.key!==r||!this.fastAesKey){this.key=r;this.fastAesKey=new n["default"](u,r)}return this.fastAesKey.expandKey().then((function(t){if(!u){return Promise.reject(new Error("web crypto not initialized"))}var r=new e["default"](u,s);return r.decrypt(i.buffer,t)})).catch((function(t){return a.onWebCryptoError(t,i,r,s)}))};i.onWebCryptoError=function t(i,r,e,n){a["logger"].warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",i);this.config.enableSoftwareAES=true;this.logEnabled=true;return this.softwareDecrypt(r,e,n)};i.getValidChunk=function t(i){var r=i;var e=i.length-i.length%f;if(e!==i.length){r=Object(o["sliceUint8"])(i,0,e);this.remainderData=Object(o["sliceUint8"])(i,e)}return r};i.logOnce=function t(i){if(!this.logEnabled){return}a["logger"].log("[decrypter.ts]: "+i);this.logEnabled=false};return t}()},"./src/crypt/fast-aes-key.ts":
|
|
118
|
+
/*!***********************************!*\
|
|
119
|
+
!*** ./src/crypt/fast-aes-key.ts ***!
|
|
120
|
+
\***********************************/
|
|
121
|
+
/*! exports provided: default */function(t,i,r){r.r(i);r.d(i,"default",(function(){return e}));var e=function(){function t(t,i){this.subtle=void 0;this.key=void 0;this.subtle=t;this.key=i}var i=t.prototype;i.expandKey=function t(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},false,["encrypt","decrypt"])};return t}()},"./src/demux/aacdemuxer.ts":
|
|
122
|
+
/*!*********************************!*\
|
|
123
|
+
!*** ./src/demux/aacdemuxer.ts ***!
|
|
124
|
+
\*********************************/
|
|
125
|
+
/*! exports provided: default */function(t,i,r){r.r(i);var e=r(/*! ./base-audio-demuxer */"./src/demux/base-audio-demuxer.ts");var n=r(/*! ./adts */"./src/demux/adts.ts");var s=r(/*! ../utils/logger */"./src/utils/logger.ts");var a=r(/*! ../demux/id3 */"./src/demux/id3.ts");function u(t,i){t.prototype=Object.create(i.prototype);t.prototype.constructor=t;o(t,i)}function o(t,i){o=Object.setPrototypeOf||function t(i,r){i.__proto__=r;return i};return o(t,i)}var f=function(t){u(i,t);function i(i,r){var e;e=t.call(this)||this;e.observer=void 0;e.config=void 0;e.observer=i;e.config=r;return e}var r=i.prototype;r.resetInitSegment=function i(r,e,n){t.prototype.resetInitSegment.call(this,r,e,n);this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:true,samples:[],manifestCodec:r,duration:n,inputTimeScale:9e4,dropped:0}};i.probe=function t(i){if(!i){return false}var r=a["getID3Data"](i,0)||[];var e=r.length;for(var u=i.length;e<u;e++){if(n["probe"](i,e)){s["logger"].log("ADTS sync word found !");return true}}return false};r.canParse=function t(i,r){return n["canParse"](i,r)};r.appendFrame=function t(i,r,e){n["initTrackConfig"](i,this.observer,r,e,i.manifestCodec);var s=n["appendFrame"](i,r,e,this.initPTS,this.frameIndex);if(s&&s.missing===0){return s}};return i}(e["default"]);f.minProbeByteLength=9;i["default"]=f},"./src/demux/adts.ts":
|
|
126
|
+
/*!***************************!*\
|
|
127
|
+
!*** ./src/demux/adts.ts ***!
|
|
128
|
+
\***************************/
|
|
129
|
+
/*! exports provided: getAudioConfig, isHeaderPattern, getHeaderLength, getFullFrameLength, canGetFrameLength, isHeader, canParse, probe, initTrackConfig, getFrameDuration, parseFrameHeader, appendFrame */function(t,i,r){r.r(i);r.d(i,"getAudioConfig",(function(){return a}));r.d(i,"isHeaderPattern",(function(){return u}));r.d(i,"getHeaderLength",(function(){return o}));r.d(i,"getFullFrameLength",(function(){return f}));r.d(i,"canGetFrameLength",(function(){return h}));r.d(i,"isHeader",(function(){return l}));r.d(i,"canParse",(function(){return c}));r.d(i,"probe",(function(){return v}));r.d(i,"initTrackConfig",(function(){return d}));r.d(i,"getFrameDuration",(function(){return m}));r.d(i,"parseFrameHeader",(function(){return p}));r.d(i,"appendFrame",(function(){return g}));var e=r(/*! ../utils/logger */"./src/utils/logger.ts");var n=r(/*! ../errors */"./src/errors.ts");var s=r(/*! ../events */"./src/events.ts");function a(t,i,r,a){var u;var o;var f;var h;var l=navigator.userAgent.toLowerCase();var c=a;var v=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];u=((i[r+2]&192)>>>6)+1;var d=(i[r+2]&60)>>>2;if(d>v.length-1){t.trigger(s["Events"].ERROR,{type:n["ErrorTypes"].MEDIA_ERROR,details:n["ErrorDetails"].FRAG_PARSING_ERROR,fatal:true,reason:"invalid ADTS sampling index:"+d});return}f=(i[r+2]&1)<<2;f|=(i[r+3]&192)>>>6;e["logger"].log("manifest codec:"+a+", ADTS type:"+u+", samplingIndex:"+d);if(/firefox/i.test(l)){if(d>=6){u=5;h=new Array(4);o=d-3}else{u=2;h=new Array(2);o=d}}else if(l.indexOf("android")!==-1){u=2;h=new Array(2);o=d}else{u=5;h=new Array(4);if(a&&(a.indexOf("mp4a.40.29")!==-1||a.indexOf("mp4a.40.5")!==-1)||!a&&d>=6){o=d-3}else{if(a&&a.indexOf("mp4a.40.2")!==-1&&(d>=6&&f===1||/vivaldi/i.test(l))||!a&&f===1){u=2;h=new Array(2)}o=d}}h[0]=u<<3;h[0]|=(d&14)>>1;h[1]|=(d&1)<<7;h[1]|=f<<3;if(u===5){h[1]|=(o&14)>>1;h[2]=(o&1)<<7;h[2]|=2<<2;h[3]=0}return{config:h,samplerate:v[d],channelCount:f,codec:"mp4a.40."+u,manifestCodec:c}}function u(t,i){return t[i]===255&&(t[i+1]&246)===240}function o(t,i){return t[i+1]&1?7:9}function f(t,i){return(t[i+3]&3)<<11|t[i+4]<<3|(t[i+5]&224)>>>5}function h(t,i){return i+5<t.length}function l(t,i){return i+1<t.length&&u(t,i)}function c(t,i){return h(t,i)&&u(t,i)&&f(t,i)<=t.length-i}function v(t,i){if(l(t,i)){var r=o(t,i);if(i+r>=t.length){return false}var e=f(t,i);if(e<=r){return false}var n=i+e;return n===t.length||l(t,n)}return false}function d(t,i,r,n,s){if(!t.samplerate){var u=a(i,r,n,s);if(!u){return}t.config=u.config;t.samplerate=u.samplerate;t.channelCount=u.channelCount;t.codec=u.codec;t.manifestCodec=u.manifestCodec;e["logger"].log("parsed codec:"+t.codec+", rate:"+u.samplerate+", channels:"+u.channelCount)}}function m(t){return 1024*9e4/t}function p(t,i,r,e,n){var s=o(t,i);var a=f(t,i);a-=s;if(a>0){var u=r+e*n;return{headerLength:s,frameLength:a,stamp:u}}}function g(t,i,r,e,n){var s=m(t.samplerate);var a=p(i,r,e,n,s);if(a){var u=a.frameLength,o=a.headerLength,f=a.stamp;var h=o+u;var l=Math.max(0,r+h-i.length);var c;if(l){c=new Uint8Array(h-o);c.set(i.subarray(r+o,i.length),0)}else{c=i.subarray(r+o,r+h)}var v={unit:c,pts:f};if(!l){t.samples.push(v)}return{sample:v,length:h,missing:l}}}},"./src/demux/base-audio-demuxer.ts":
|
|
130
|
+
/*!*****************************************!*\
|
|
131
|
+
!*** ./src/demux/base-audio-demuxer.ts ***!
|
|
132
|
+
\*****************************************/
|
|
133
|
+
/*! exports provided: initPTSFn, default */function(t,i,r){r.r(i);r.d(i,"initPTSFn",(function(){return f}));var e=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");var n=r(/*! ../demux/id3 */"./src/demux/id3.ts");var s=r(/*! ./dummy-demuxed-track */"./src/demux/dummy-demuxed-track.ts");var a=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts");var u=r(/*! ../utils/typed-array */"./src/utils/typed-array.ts");var o=function(){function t(){this._audioTrack=void 0;this._id3Track=void 0;this.frameIndex=0;this.cachedData=null;this.initPTS=null}var i=t.prototype;i.resetInitSegment=function t(i,r,e){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}};i.resetTimeStamp=function t(){};i.resetContiguity=function t(){};i.canParse=function t(i,r){return false};i.appendFrame=function t(i,r,e){};i.demux=function t(i,r){if(this.cachedData){i=Object(a["appendUint8Array"])(this.cachedData,i);this.cachedData=null}var e=n["getID3Data"](i,0);var o=e?e.length:0;var h;var l;var c=this._audioTrack;var v=this._id3Track;var d=e?n["getTimeStamp"](e):undefined;var m=i.length;if(this.frameIndex===0||this.initPTS===null){this.initPTS=f(d,r)}if(e&&e.length>0){v.samples.push({pts:this.initPTS,dts:this.initPTS,data:e})}l=this.initPTS;while(o<m){if(this.canParse(i,o)){var p=this.appendFrame(c,i,o);if(p){this.frameIndex++;l=p.sample.pts;o+=p.length;h=o}else{o=m}}else if(n["canParse"](i,o)){e=n["getID3Data"](i,o);v.samples.push({pts:l,dts:l,data:e});o+=e.length;h=o}else{o++}if(o===m&&h!==m){var g=Object(u["sliceUint8"])(i,h);if(this.cachedData){this.cachedData=Object(a["appendUint8Array"])(this.cachedData,g)}else{this.cachedData=g}}}return{audioTrack:c,avcTrack:Object(s["dummyTrack"])(),id3Track:v,textTrack:Object(s["dummyTrack"])()}};i.demuxSampleAes=function t(i,r,e){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))};i.flush=function t(i){var r=this.cachedData;if(r){this.cachedData=null;this.demux(r,0)}this.frameIndex=0;return{audioTrack:this._audioTrack,avcTrack:Object(s["dummyTrack"])(),id3Track:this._id3Track,textTrack:Object(s["dummyTrack"])()}};i.destroy=function t(){};return t}();var f=function t(i,r){return Object(e["isFiniteNumber"])(i)?i*90:r*9e4};i["default"]=o},"./src/demux/chunk-cache.ts":
|
|
134
|
+
/*!**********************************!*\
|
|
135
|
+
!*** ./src/demux/chunk-cache.ts ***!
|
|
136
|
+
\**********************************/
|
|
137
|
+
/*! exports provided: default */function(t,i,r){r.r(i);r.d(i,"default",(function(){return e}));var e=function(){function t(){this.chunks=[];this.dataLength=0}var i=t.prototype;i.push=function t(i){this.chunks.push(i);this.dataLength+=i.length};i.flush=function t(){var i=this.chunks,r=this.dataLength;var e;if(!i.length){return new Uint8Array(0)}else if(i.length===1){e=i[0]}else{e=n(i,r)}this.reset();return e};i.reset=function t(){this.chunks.length=0;this.dataLength=0};return t}();function n(t,i){var r=new Uint8Array(i);var e=0;for(var n=0;n<t.length;n++){var s=t[n];r.set(s,e);e+=s.length}return r}},"./src/demux/dummy-demuxed-track.ts":
|
|
138
|
+
/*!******************************************!*\
|
|
139
|
+
!*** ./src/demux/dummy-demuxed-track.ts ***!
|
|
140
|
+
\******************************************/
|
|
141
|
+
/*! exports provided: dummyTrack */function(t,i,r){r.r(i);r.d(i,"dummyTrack",(function(){return e}));function e(){return{type:"",id:-1,pid:-1,inputTimeScale:9e4,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":
|
|
142
|
+
/*!*********************************!*\
|
|
143
|
+
!*** ./src/demux/exp-golomb.ts ***!
|
|
144
|
+
\*********************************/
|
|
145
|
+
/*! exports provided: default */function(t,i,r){r.r(i);var e=r(/*! ../utils/logger */"./src/utils/logger.ts");var n=function(){function t(t){this.data=void 0;this.bytesAvailable=void 0;this.word=void 0;this.bitsAvailable=void 0;this.data=t;this.bytesAvailable=t.byteLength;this.word=0;this.bitsAvailable=0}var i=t.prototype;i.loadWord=function t(){var i=this.data;var r=this.bytesAvailable;var e=i.byteLength-r;var n=new Uint8Array(4);var s=Math.min(4,r);if(s===0){throw new Error("no bytes available")}n.set(i.subarray(e,e+s));this.word=new DataView(n.buffer).getUint32(0);this.bitsAvailable=s*8;this.bytesAvailable-=s};i.skipBits=function t(i){var r;if(this.bitsAvailable>i){this.word<<=i;this.bitsAvailable-=i}else{i-=this.bitsAvailable;r=i>>3;i-=r>>3;this.bytesAvailable-=r;this.loadWord();this.word<<=i;this.bitsAvailable-=i}};i.readBits=function t(i){var r=Math.min(this.bitsAvailable,i);var n=this.word>>>32-r;if(i>32){e["logger"].error("Cannot read more than 32 bits at a time")}this.bitsAvailable-=r;if(this.bitsAvailable>0){this.word<<=r}else if(this.bytesAvailable>0){this.loadWord()}r=i-r;if(r>0&&this.bitsAvailable){return n<<r|this.readBits(r)}else{return n}};i.skipLZ=function t(){var i;for(i=0;i<this.bitsAvailable;++i){if((this.word&2147483648>>>i)!==0){this.word<<=i;this.bitsAvailable-=i;return i}}this.loadWord();return i+this.skipLZ()};i.skipUEG=function t(){this.skipBits(1+this.skipLZ())};i.skipEG=function t(){this.skipBits(1+this.skipLZ())};i.readUEG=function t(){var i=this.skipLZ();return this.readBits(i+1)-1};i.readEG=function t(){var i=this.readUEG();if(1&i){return 1+i>>>1}else{return-1*(i>>>1)}};i.readBoolean=function t(){return this.readBits(1)===1};i.readUByte=function t(){return this.readBits(8)};i.readUShort=function t(){return this.readBits(16)};i.readUInt=function t(){return this.readBits(32)};i.skipScalingList=function t(i){var r=8;var e=8;var n;for(var s=0;s<i;s++){if(e!==0){n=this.readEG();e=(r+n+256)%256}r=e===0?r:e}};i.readSPS=function t(){var i=0;var r=0;var e=0;var n=0;var s;var a;var u;var o=this.readUByte.bind(this);var f=this.readBits.bind(this);var h=this.readUEG.bind(this);var l=this.readBoolean.bind(this);var c=this.skipBits.bind(this);var v=this.skipEG.bind(this);var d=this.skipUEG.bind(this);var m=this.skipScalingList.bind(this);o();var p=o();f(5);c(3);o();d();if(p===100||p===110||p===122||p===244||p===44||p===83||p===86||p===118||p===128){var g=h();if(g===3){c(1)}d();d();c(1);if(l()){a=g!==3?8:12;for(u=0;u<a;u++){if(l()){if(u<6){m(16)}else{m(64)}}}}}d();var b=h();if(b===0){h()}else if(b===1){c(1);v();v();s=h();for(u=0;u<s;u++){v()}}d();c(1);var y=h();var w=h();var A=f(1);if(A===0){c(1)}c(1);if(l()){i=h();r=h();e=h();n=h()}var k=[1,1];if(l()){if(l()){var T=o();switch(T){case 1:k=[1,1];break;case 2:k=[12,11];break;case 3:k=[10,11];break;case 4:k=[16,11];break;case 5:k=[40,33];break;case 6:k=[24,11];break;case 7:k=[20,11];break;case 8:k=[32,11];break;case 9:k=[80,33];break;case 10:k=[18,11];break;case 11:k=[15,11];break;case 12:k=[64,33];break;case 13:k=[160,99];break;case 14:k=[4,3];break;case 15:k=[3,2];break;case 16:k=[2,1];break;case 255:{k=[o()<<8|o(),o()<<8|o()];break}}}}return{width:Math.ceil((y+1)*16-i*2-r*2),height:(2-A)*(w+1)*16-(A?2:4)*(e+n),pixelRatio:k}};i.readSliceType=function t(){this.readUByte();this.readUEG();return this.readUEG()};return t}();i["default"]=n},"./src/demux/id3.ts":
|
|
146
|
+
/*!**************************!*\
|
|
147
|
+
!*** ./src/demux/id3.ts ***!
|
|
148
|
+
\**************************/
|
|
149
|
+
/*! exports provided: isHeader, isFooter, getID3Data, canParse, getTimeStamp, isTimeStampFrame, getID3Frames, decodeFrame, utf8ArrayToStr, testables */function(t,i,r){r.r(i);r.d(i,"isHeader",(function(){return e}));r.d(i,"isFooter",(function(){return n}));r.d(i,"getID3Data",(function(){return s}));r.d(i,"canParse",(function(){return u}));r.d(i,"getTimeStamp",(function(){return o}));r.d(i,"isTimeStampFrame",(function(){return f}));r.d(i,"getID3Frames",(function(){return l}));r.d(i,"decodeFrame",(function(){return c}));r.d(i,"utf8ArrayToStr",(function(){return g}));r.d(i,"testables",(function(){return b}));var e=function t(i,r){if(r+10<=i.length){if(i[r]===73&&i[r+1]===68&&i[r+2]===51){if(i[r+3]<255&&i[r+4]<255){if(i[r+6]<128&&i[r+7]<128&&i[r+8]<128&&i[r+9]<128){return true}}}}return false};var n=function t(i,r){if(r+10<=i.length){if(i[r]===51&&i[r+1]===68&&i[r+2]===73){if(i[r+3]<255&&i[r+4]<255){if(i[r+6]<128&&i[r+7]<128&&i[r+8]<128&&i[r+9]<128){return true}}}}return false};var s=function t(i,r){var s=r;var u=0;while(e(i,r)){u+=10;var o=a(i,r+6);u+=o;if(n(i,r+10)){u+=10}r+=u}if(u>0){return i.subarray(s,s+u)}return undefined};var a=function t(i,r){var e=0;e=(i[r]&127)<<21;e|=(i[r+1]&127)<<14;e|=(i[r+2]&127)<<7;e|=i[r+3]&127;return e};var u=function t(i,r){return e(i,r)&&a(i,r+6)+10<=i.length-r};var o=function t(i){var r=l(i);for(var e=0;e<r.length;e++){var n=r[e];if(f(n)){return p(n)}}return undefined};var f=function t(i){return i&&i.key==="PRIV"&&i.info==="com.apple.streaming.transportStreamTimestamp"};var h=function t(i){var r=String.fromCharCode(i[0],i[1],i[2],i[3]);var e=a(i,4);var n=10;return{type:r,size:e,data:i.subarray(n,n+e)}};var l=function t(i){var r=0;var s=[];while(e(i,r)){var u=a(i,r+6);r+=10;var o=r+u;while(r+8<o){var f=h(i.subarray(r));var l=c(f);if(l){s.push(l)}r+=f.size+10}if(n(i,r)){r+=10}}return s};var c=function t(i){if(i.type==="PRIV"){return v(i)}else if(i.type[0]==="W"){return m(i)}return d(i)};var v=function t(i){if(i.size<2){return undefined}var r=g(i.data,true);var e=new Uint8Array(i.data.subarray(r.length+1));return{key:i.type,info:r,data:e.buffer}};var d=function t(i){if(i.size<2){return undefined}if(i.type==="TXXX"){var r=1;var e=g(i.data.subarray(r),true);r+=e.length+1;var n=g(i.data.subarray(r));return{key:i.type,info:e,data:n}}var s=g(i.data.subarray(1));return{key:i.type,data:s}};var m=function t(i){if(i.type==="WXXX"){if(i.size<2){return undefined}var r=1;var e=g(i.data.subarray(r),true);r+=e.length+1;var n=g(i.data.subarray(r));return{key:i.type,info:e,data:n}}var s=g(i.data);return{key:i.type,data:s}};var p=function t(i){if(i.data.byteLength===8){var r=new Uint8Array(i.data);var e=r[3]&1;var n=(r[4]<<23)+(r[5]<<15)+(r[6]<<7)+r[7];n/=45;if(e){n+=47721858.84}return Math.round(n)}return undefined};var g=function t(i,r){if(r===void 0){r=false}var e=w();if(e){var n=e.decode(i);if(r){var s=n.indexOf("\0");return s!==-1?n.substring(0,s):n}return n.replace(/\0/g,"")}var a=i.length;var u;var o;var f;var h="";var l=0;while(l<a){u=i[l++];if(u===0&&r){return h}else if(u===0||u===3){continue}switch(u>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:h+=String.fromCharCode(u);break;case 12:case 13:o=i[l++];h+=String.fromCharCode((u&31)<<6|o&63);break;case 14:o=i[l++];f=i[l++];h+=String.fromCharCode((u&15)<<12|(o&63)<<6|(f&63)<<0);break}}return h};var b={decodeTextFrame:d};var y;function w(){if(!y&&typeof self.TextDecoder!=="undefined"){y=new self.TextDecoder("utf-8")}return y}},"./src/demux/mp3demuxer.ts":
|
|
150
|
+
/*!*********************************!*\
|
|
151
|
+
!*** ./src/demux/mp3demuxer.ts ***!
|
|
152
|
+
\*********************************/
|
|
153
|
+
/*! exports provided: default */function(t,i,r){r.r(i);var e=r(/*! ./base-audio-demuxer */"./src/demux/base-audio-demuxer.ts");var n=r(/*! ../demux/id3 */"./src/demux/id3.ts");var s=r(/*! ../utils/logger */"./src/utils/logger.ts");var a=r(/*! ./mpegaudio */"./src/demux/mpegaudio.ts");function u(t,i){t.prototype=Object.create(i.prototype);t.prototype.constructor=t;o(t,i)}function o(t,i){o=Object.setPrototypeOf||function t(i,r){i.__proto__=r;return i};return o(t,i)}var f=function(t){u(i,t);function i(){return t.apply(this,arguments)||this}var r=i.prototype;r.resetInitSegment=function i(r,e,n){t.prototype.resetInitSegment.call(this,r,e,n);this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:false,samples:[],manifestCodec:r,duration:n,inputTimeScale:9e4,dropped:0}};i.probe=function t(i){if(!i){return false}var r=n["getID3Data"](i,0)||[];var e=r.length;for(var u=i.length;e<u;e++){if(a["probe"](i,e)){s["logger"].log("MPEG Audio sync word found !");return true}}return false};r.canParse=function t(i,r){return a["canParse"](i,r)};r.appendFrame=function t(i,r,e){if(this.initPTS===null){return}return a["appendFrame"](i,r,e,this.initPTS,this.frameIndex)};return i}(e["default"]);f.minProbeByteLength=4;i["default"]=f},"./src/demux/mp4demuxer.ts":
|
|
154
|
+
/*!*********************************!*\
|
|
155
|
+
!*** ./src/demux/mp4demuxer.ts ***!
|
|
156
|
+
\*********************************/
|
|
157
|
+
/*! exports provided: default */function(t,i,r){r.r(i);var e=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts");var n=r(/*! ./dummy-demuxed-track */"./src/demux/dummy-demuxed-track.ts");var s=function(){function t(t,i){this.remainderData=null;this.config=void 0;this.config=i}var i=t.prototype;i.resetTimeStamp=function t(){};i.resetInitSegment=function t(){};i.resetContiguity=function t(){};t.probe=function t(i){return Object(e["findBox"])({data:i,start:0,end:Math.min(i.length,16384)},["moof"]).length>0};i.demux=function t(i){var r=i;var s=Object(n["dummyTrack"])();if(this.config.progressive){if(this.remainderData){r=Object(e["appendUint8Array"])(this.remainderData,i)}var a=Object(e["segmentValidRange"])(r);this.remainderData=a.remainder;s.samples=a.valid||new Uint8Array}else{s.samples=r}return{audioTrack:Object(n["dummyTrack"])(),avcTrack:s,id3Track:Object(n["dummyTrack"])(),textTrack:Object(n["dummyTrack"])()}};i.flush=function t(){var i=Object(n["dummyTrack"])();i.samples=this.remainderData||new Uint8Array;this.remainderData=null;return{audioTrack:Object(n["dummyTrack"])(),avcTrack:i,id3Track:Object(n["dummyTrack"])(),textTrack:Object(n["dummyTrack"])()}};i.demuxSampleAes=function t(i,r,e){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))};i.destroy=function t(){};return t}();s.minProbeByteLength=1024;i["default"]=s},"./src/demux/mpegaudio.ts":
|
|
158
|
+
/*!********************************!*\
|
|
159
|
+
!*** ./src/demux/mpegaudio.ts ***!
|
|
160
|
+
\********************************/
|
|
161
|
+
/*! exports provided: appendFrame, parseHeader, isHeaderPattern, isHeader, canParse, probe */function(t,i,r){r.r(i);r.d(i,"appendFrame",(function(){return o}));r.d(i,"parseHeader",(function(){return f}));r.d(i,"isHeaderPattern",(function(){return h}));r.d(i,"isHeader",(function(){return l}));r.d(i,"canParse",(function(){return c}));r.d(i,"probe",(function(){return v}));var e=null;var n=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160];var s=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3];var a=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]];var u=[0,1,1,4];function o(t,i,r,e,n){if(r+24>i.length){return}var s=f(i,r);if(s&&r+s.frameLength<=i.length){var a=s.samplesPerFrame*9e4/s.sampleRate;var u=e+n*a;var o={unit:i.subarray(r,r+s.frameLength),pts:u,dts:u};t.config=[];t.channelCount=s.channelCount;t.samplerate=s.sampleRate;t.samples.push(o);return{sample:o,length:s.frameLength,missing:0}}}function f(t,i){var r=t[i+1]>>3&3;var o=t[i+1]>>1&3;var f=t[i+2]>>4&15;var h=t[i+2]>>2&3;if(r!==1&&f!==0&&f!==15&&h!==3){var l=t[i+2]>>1&1;var c=t[i+3]>>6;var v=r===3?3-o:o===3?3:4;var d=n[v*14+f-1]*1e3;var m=r===3?0:r===2?1:2;var p=s[m*3+h];var g=c===3?1:2;var b=a[r][o];var y=u[o];var w=b*8*y;var A=Math.floor(b*d/p+l)*y;if(e===null){var k=navigator.userAgent||"";var T=k.match(/Chrome\/(\d+)/i);e=T?parseInt(T[1]):0}var E=!!e&&e<=87;if(E&&o===2&&d>=224e3&&c===0){t[i+3]=t[i+3]|128}return{sampleRate:p,channelCount:g,frameLength:A,samplesPerFrame:w}}}function h(t,i){return t[i]===255&&(t[i+1]&224)===224&&(t[i+1]&6)!==0}function l(t,i){return i+1<t.length&&h(t,i)}function c(t,i){var r=4;return h(t,i)&&r<=t.length-i}function v(t,i){if(i+1<t.length&&h(t,i)){var r=4;var e=f(t,i);var n=r;if(e!==null&&e!==void 0&&e.frameLength){n=e.frameLength}var s=i+n;return s===t.length||l(t,s)}return false}},"./src/demux/sample-aes.ts":
|
|
162
|
+
/*!*********************************!*\
|
|
163
|
+
!*** ./src/demux/sample-aes.ts ***!
|
|
164
|
+
\*********************************/
|
|
165
|
+
/*! exports provided: default */function(t,i,r){r.r(i);var e=r(/*! ../crypt/decrypter */"./src/crypt/decrypter.ts");var n=r(/*! ./tsdemuxer */"./src/demux/tsdemuxer.ts");var s=function(){function t(t,i,r){this.keyData=void 0;this.decrypter=void 0;this.keyData=r;this.decrypter=new e["default"](t,i,{removePKCS7Padding:false})}var i=t.prototype;i.decryptBuffer=function t(i,r){this.decrypter.decrypt(i,this.keyData.key.buffer,this.keyData.iv.buffer,r)};i.decryptAacSample=function t(i,r,e,n){var s=i[r].unit;var a=s.subarray(16,s.length-s.length%16);var u=a.buffer.slice(a.byteOffset,a.byteOffset+a.length);var o=this;this.decryptBuffer(u,(function(t){var a=new Uint8Array(t);s.set(a,16);if(!n){o.decryptAacSamples(i,r+1,e)}}))};i.decryptAacSamples=function t(i,r,e){for(;;r++){if(r>=i.length){e();return}if(i[r].unit.length<32){continue}var n=this.decrypter.isSync();this.decryptAacSample(i,r,e,n);if(!n){return}}};i.getAvcEncryptedData=function t(i){var r=Math.floor((i.length-48)/160)*16+16;var e=new Int8Array(r);var n=0;for(var s=32;s<i.length-16;s+=160,n+=16){e.set(i.subarray(s,s+16),n)}return e};i.getAvcDecryptedUnit=function t(i,r){var e=new Uint8Array(r);var n=0;for(var s=32;s<i.length-16;s+=160,n+=16){i.set(e.subarray(n,n+16),s)}return i};i.decryptAvcSample=function t(i,r,e,s,a,u){var o=Object(n["discardEPB"])(a.data);var f=this.getAvcEncryptedData(o);var h=this;this.decryptBuffer(f.buffer,(function(t){a.data=h.getAvcDecryptedUnit(o,t);if(!u){h.decryptAvcSamples(i,r,e+1,s)}}))};i.decryptAvcSamples=function t(i,r,e,n){if(i instanceof Uint8Array){throw new Error("Cannot decrypt samples of type Uint8Array")}for(;;r++,e=0){if(r>=i.length){n();return}var s=i[r].units;for(;;e++){if(e>=s.length){break}var a=s[e];if(a.data.length<=48||a.type!==1&&a.type!==5){continue}var u=this.decrypter.isSync();this.decryptAvcSample(i,r,e,n,a,u);if(!u){return}}}};return t}();i["default"]=s},"./src/demux/transmuxer-interface.ts":
|
|
166
|
+
/*!*******************************************!*\
|
|
167
|
+
!*** ./src/demux/transmuxer-interface.ts ***!
|
|
168
|
+
\*******************************************/
|
|
169
|
+
/*! exports provided: default */function(t,i,r){r.r(i);r.d(i,"default",(function(){return l}));var e=r(/*! webworkify-webpack */"./node_modules/webworkify-webpack/index.js");var n=r(/*! ../events */"./src/events.ts");var s=r(/*! ../demux/transmuxer */"./src/demux/transmuxer.ts");var a=r(/*! ../utils/logger */"./src/utils/logger.ts");var u=r(/*! ../errors */"./src/errors.ts");var o=r(/*! ../utils/mediasource-helper */"./src/utils/mediasource-helper.ts");var f=r(/*! eventemitter3 */"./node_modules/eventemitter3/index.js");var h=Object(o["getMediaSource"])()||{isTypeSupported:function t(){return false}};var l=function(){function t(t,i,r,o){var l=this;this.hls=void 0;this.id=void 0;this.observer=void 0;this.frag=null;this.part=null;this.worker=void 0;this.onwmsg=void 0;this.transmuxer=null;this.onTransmuxComplete=void 0;this.onFlush=void 0;this.hls=t;this.id=i;this.onTransmuxComplete=r;this.onFlush=o;var c=t.config;var v=function i(r,e){e=e||{};e.frag=l.frag;e.id=l.id;t.trigger(r,e)};this.observer=new f["EventEmitter"];this.observer.on(n["Events"].FRAG_DECRYPTED,v);this.observer.on(n["Events"].ERROR,v);var d={mp4:h.isTypeSupported("video/mp4"),mpeg:h.isTypeSupported("audio/mpeg"),mp3:h.isTypeSupported('audio/mp4; codecs="mp3"')};var m=navigator.vendor;if(c.enableWorker&&typeof Worker!=="undefined"){a["logger"].log("demuxing in webworker");var p;try{p=this.worker=e(/*! ../demux/transmuxer-worker.ts */"./src/demux/transmuxer-worker.ts");this.onwmsg=this.onWorkerMessage.bind(this);p.addEventListener("message",this.onwmsg);p.onerror=function(i){t.trigger(n["Events"].ERROR,{type:u["ErrorTypes"].OTHER_ERROR,details:u["ErrorDetails"].INTERNAL_EXCEPTION,fatal:true,event:"demuxerWorker",error:new Error(i.message+" ("+i.filename+":"+i.lineno+")")})};p.postMessage({cmd:"init",typeSupported:d,vendor:m,id:i,config:JSON.stringify(c)})}catch(t){a["logger"].warn("Error in worker:",t);a["logger"].error("Error while initializing DemuxerWorker, fallback to inline");if(p){self.URL.revokeObjectURL(p.objectURL)}this.transmuxer=new s["default"](this.observer,d,c,m,i);this.worker=null}}else{this.transmuxer=new s["default"](this.observer,d,c,m,i)}}var i=t.prototype;i.destroy=function t(){var i=this.worker;if(i){i.removeEventListener("message",this.onwmsg);i.terminate();this.worker=null}else{var r=this.transmuxer;if(r){r.destroy();this.transmuxer=null}}var e=this.observer;if(e){e.removeAllListeners()}this.observer=null};i.push=function t(i,r,e,n,u,o,f,h,l,c){var v,d,m=this;l.transmuxing.start=self.performance.now();var p=this.transmuxer,g=this.worker;var b=o?o.start:u.start;var y=u.decryptdata;var w=this.frag;var A=!(w&&u.cc===w.cc);var k=!(w&&l.level===w.level);var T=w?l.sn-w.sn:-1;var E=this.part?l.part-this.part.index:1;var O=!k&&(T===1||T===0&&E===1);var S=self.performance.now();if(k||T||u.stats.parsing.start===0){u.stats.parsing.start=S}if(o&&(E||!O)){o.stats.parsing.start=S}var M=!(w&&((v=u.initSegment)===null||v===void 0?void 0:v.url)===((d=w.initSegment)===null||d===void 0?void 0:d.url));var x=new s["TransmuxState"](A,O,h,k,b,M);if(!O||A||M){a["logger"].log("[transmuxer-interface, "+u.type+"]: Starting new transmux session for sn: "+l.sn+" p: "+l.part+" level: "+l.level+" id: "+l.id+"\n discontinuity: "+A+"\n trackSwitch: "+k+"\n contiguous: "+O+"\n accurateTimeOffset: "+h+"\n timeOffset: "+b+"\n initSegmentChange: "+M);var j=new s["TransmuxConfig"](e,n,r,f,c);this.configureTransmuxer(j)}this.frag=u;this.part=o;if(g){g.postMessage({cmd:"demux",data:i,decryptdata:y,chunkMeta:l,state:x},i instanceof ArrayBuffer?[i]:[])}else if(p){var D=p.push(i,y,l,x);if(Object(s["isPromise"])(D)){D.then((function(t){m.handleTransmuxComplete(t)}))}else{this.handleTransmuxComplete(D)}}};i.flush=function t(i){var r=this;i.transmuxing.start=self.performance.now();var e=this.transmuxer,n=this.worker;if(n){n.postMessage({cmd:"flush",chunkMeta:i})}else if(e){var a=e.flush(i);if(Object(s["isPromise"])(a)){a.then((function(t){r.handleFlushResult(t,i)}))}else{this.handleFlushResult(a,i)}}};i.handleFlushResult=function t(i,r){var e=this;i.forEach((function(t){e.handleTransmuxComplete(t)}));this.onFlush(r)};i.onWorkerMessage=function t(i){var r=i.data;var e=this.hls;switch(r.event){case"init":{self.URL.revokeObjectURL(this.worker.objectURL);break}case"transmuxComplete":{this.handleTransmuxComplete(r.data);break}case"flush":{this.onFlush(r.data);break}default:{r.data=r.data||{};r.data.frag=this.frag;r.data.id=this.id;e.trigger(r.event,r.data);break}}};i.configureTransmuxer=function t(i){var r=this.worker,e=this.transmuxer;if(r){r.postMessage({cmd:"configure",config:i})}else if(e){e.configure(i)}};i.handleTransmuxComplete=function t(i){i.chunkMeta.transmuxing.end=self.performance.now();this.onTransmuxComplete(i)};return t}()},"./src/demux/transmuxer-worker.ts":
|
|
170
|
+
/*!****************************************!*\
|
|
171
|
+
!*** ./src/demux/transmuxer-worker.ts ***!
|
|
172
|
+
\****************************************/
|
|
173
|
+
/*! exports provided: default */function(t,i,r){r.r(i);r.d(i,"default",(function(){return u}));var e=r(/*! ../demux/transmuxer */"./src/demux/transmuxer.ts");var n=r(/*! ../events */"./src/events.ts");var s=r(/*! ../utils/logger */"./src/utils/logger.ts");var a=r(/*! eventemitter3 */"./node_modules/eventemitter3/index.js");function u(t){var i=new a["EventEmitter"];var r=function i(r,e){t.postMessage({event:r,data:e})};i.on(n["Events"].FRAG_DECRYPTED,r);i.on(n["Events"].ERROR,r);t.addEventListener("message",(function(n){var a=n.data;switch(a.cmd){case"init":{var u=JSON.parse(a.config);t.transmuxer=new e["default"](i,a.typeSupported,u,a.vendor,a.id);Object(s["enableLogs"])(u.debug);r("init",null);break}case"configure":{t.transmuxer.configure(a.config);break}case"demux":{var f=t.transmuxer.push(a.data,a.decryptdata,a.chunkMeta,a.state);if(Object(e["isPromise"])(f)){f.then((function(i){o(t,i)}))}else{o(t,f)}break}case"flush":{var l=a.chunkMeta;var c=t.transmuxer.flush(l);if(Object(e["isPromise"])(c)){c.then((function(i){h(t,i,l)}))}else{h(t,c,l)}break}}}))}function o(t,i){if(l(i.remuxResult)){return}var r=[];var e=i.remuxResult,n=e.audio,s=e.video;if(n){f(r,n)}if(s){f(r,s)}t.postMessage({event:"transmuxComplete",data:i},r)}function f(t,i){if(i.data1){t.push(i.data1.buffer)}if(i.data2){t.push(i.data2.buffer)}}function h(t,i,r){i.forEach((function(i){o(t,i)}));t.postMessage({event:"flush",data:r})}function l(t){return!t.audio&&!t.video&&!t.text&&!t.id3&&!t.initSegment}},"./src/demux/transmuxer.ts":
|
|
174
|
+
/*!*********************************!*\
|
|
175
|
+
!*** ./src/demux/transmuxer.ts ***!
|
|
176
|
+
\*********************************/
|
|
177
|
+
/*! exports provided: default, isPromise, TransmuxConfig, TransmuxState */function(t,i,r){r.r(i);r.d(i,"default",(function(){return b}));r.d(i,"isPromise",(function(){return A}));r.d(i,"TransmuxConfig",(function(){return k}));r.d(i,"TransmuxState",(function(){return T}));var e=r(/*! ../events */"./src/events.ts");var n=r(/*! ../errors */"./src/errors.ts");var s=r(/*! ../crypt/decrypter */"./src/crypt/decrypter.ts");var a=r(/*! ../demux/aacdemuxer */"./src/demux/aacdemuxer.ts");var u=r(/*! ../demux/mp4demuxer */"./src/demux/mp4demuxer.ts");var o=r(/*! ../demux/tsdemuxer */"./src/demux/tsdemuxer.ts");var f=r(/*! ../demux/mp3demuxer */"./src/demux/mp3demuxer.ts");var h=r(/*! ../remux/mp4-remuxer */"./src/remux/mp4-remuxer.ts");var l=r(/*! ../remux/passthrough-remuxer */"./src/remux/passthrough-remuxer.ts");var c=r(/*! ./chunk-cache */"./src/demux/chunk-cache.ts");var v=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts");var d=r(/*! ../utils/logger */"./src/utils/logger.ts");var m;try{m=self.performance.now.bind(self.performance)}catch(t){d["logger"].debug("Unable to use Performance API on this environment");m=self.Date.now}var p=[{demux:o["default"],remux:h["default"]},{demux:u["default"],remux:l["default"]},{demux:a["default"],remux:h["default"]},{demux:f["default"],remux:h["default"]}];var g=1024;p.forEach((function(t){var i=t.demux;g=Math.max(g,i.minProbeByteLength)}));var b=function(){function t(t,i,r,e,n){this.observer=void 0;this.typeSupported=void 0;this.config=void 0;this.vendor=void 0;this.id=void 0;this.demuxer=void 0;this.remuxer=void 0;this.decrypter=void 0;this.probe=void 0;this.decryptionPromise=null;this.transmuxConfig=void 0;this.currentTransmuxState=void 0;this.cache=new c["default"];this.observer=t;this.typeSupported=i;this.config=r;this.vendor=e;this.id=n}var i=t.prototype;i.configure=function t(i){this.transmuxConfig=i;if(this.decrypter){this.decrypter.reset()}};i.push=function t(i,r,e,n){var s=this;var a=e.transmuxing;a.executeStart=m();var u=new Uint8Array(i);var o=this.cache,f=this.config,h=this.currentTransmuxState,l=this.transmuxConfig;if(n){this.currentTransmuxState=n}var c=y(u,r);if(c&&c.method==="AES-128"){var d=this.getDecrypter();if(f.enableSoftwareAES){var p=d.softwareDecrypt(u,c.key.buffer,c.iv.buffer);if(!p){a.executeEnd=m();return w(e)}u=new Uint8Array(p)}else{this.decryptionPromise=d.webCryptoDecrypt(u,c.key.buffer,c.iv.buffer).then((function(t){var i=s.push(t,null,e);s.decryptionPromise=null;return i}));return this.decryptionPromise}}var g=n||h,b=g.contiguous,A=g.discontinuity,k=g.trackSwitch,T=g.accurateTimeOffset,E=g.timeOffset,O=g.initSegmentChange;var S=l.audioCodec,M=l.videoCodec,x=l.defaultInitPts,j=l.duration,D=l.initSegmentData;if(A||k||O){this.resetInitSegment(D,S,M,j)}if(A||O){this.resetInitialTimestamp(x)}if(!b){this.resetContiguity()}if(this.needsProbing(u,A,k)){if(o.dataLength){var I=o.flush();u=Object(v["appendUint8Array"])(I,u)}this.configureTransmuxer(u,l)}var L=this.transmux(u,c,E,T,e);var C=this.currentTransmuxState;C.contiguous=true;C.discontinuity=false;C.trackSwitch=false;a.executeEnd=m();return L};i.flush=function t(i){var r=this;var s=i.transmuxing;s.executeStart=m();var a=this.decrypter,u=this.cache,o=this.currentTransmuxState,f=this.decryptionPromise;if(f){return f.then((function(){return r.flush(i)}))}var h=[];var l=o.timeOffset;if(a){var c=a.flush();if(c){h.push(this.push(c,null,i))}}var v=u.dataLength;u.reset();var d=this.demuxer,p=this.remuxer;if(!d||!p){if(v>=g){this.observer.emit(e["Events"].ERROR,e["Events"].ERROR,{type:n["ErrorTypes"].MEDIA_ERROR,details:n["ErrorDetails"].FRAG_PARSING_ERROR,fatal:true,reason:"no demux matching with content found"})}s.executeEnd=m();return[w(i)]}var b=d.flush(l);if(A(b)){return b.then((function(t){r.flushRemux(h,t,i);return h}))}this.flushRemux(h,b,i);return h};i.flushRemux=function t(i,r,e){var n=r.audioTrack,s=r.avcTrack,a=r.id3Track,u=r.textTrack;var o=this.currentTransmuxState,f=o.accurateTimeOffset,h=o.timeOffset;d["logger"].log("[transmuxer.ts]: Flushed fragment "+e.sn+(e.part>-1?" p: "+e.part:"")+" of level "+e.level);var l=this.remuxer.remux(n,s,a,u,h,f,true,this.id);i.push({remuxResult:l,chunkMeta:e});e.transmuxing.executeEnd=m()};i.resetInitialTimestamp=function t(i){var r=this.demuxer,e=this.remuxer;if(!r||!e){return}r.resetTimeStamp(i);e.resetTimeStamp(i)};i.resetContiguity=function t(){var i=this.demuxer,r=this.remuxer;if(!i||!r){return}i.resetContiguity();r.resetNextTimestamp()};i.resetInitSegment=function t(i,r,e,n){var s=this.demuxer,a=this.remuxer;if(!s||!a){return}s.resetInitSegment(r,e,n);a.resetInitSegment(i,r,e)};i.destroy=function t(){if(this.demuxer){this.demuxer.destroy();this.demuxer=undefined}if(this.remuxer){this.remuxer.destroy();this.remuxer=undefined}};i.transmux=function t(i,r,e,n,s){var a;if(r&&r.method==="SAMPLE-AES"){a=this.transmuxSampleAes(i,r,e,n,s)}else{a=this.transmuxUnencrypted(i,e,n,s)}return a};i.transmuxUnencrypted=function t(i,r,e,n){var s=this.demuxer.demux(i,r,false,!this.config.progressive),a=s.audioTrack,u=s.avcTrack,o=s.id3Track,f=s.textTrack;var h=this.remuxer.remux(a,u,o,f,r,e,false,this.id);return{remuxResult:h,chunkMeta:n}};i.transmuxSampleAes=function t(i,r,e,n,s){var a=this;return this.demuxer.demuxSampleAes(i,r,e).then((function(t){var i=a.remuxer.remux(t.audioTrack,t.avcTrack,t.id3Track,t.textTrack,e,n,false,a.id);return{remuxResult:i,chunkMeta:s}}))};i.configureTransmuxer=function t(i,r){var e=this.config,n=this.observer,s=this.typeSupported,a=this.vendor;var o=r.audioCodec,f=r.defaultInitPts,h=r.duration,c=r.initSegmentData,v=r.videoCodec;var m;for(var g=0,b=p.length;g<b;g++){if(p[g].demux.probe(i)){m=p[g];break}}if(!m){d["logger"].warn("Failed to find demuxer by probing frag, treating as mp4 passthrough");m={demux:u["default"],remux:l["default"]}}var y=this.demuxer;var w=this.remuxer;var A=m.remux;var k=m.demux;if(!w||!(w instanceof A)){this.remuxer=new A(n,e,s,a)}if(!y||!(y instanceof k)){this.demuxer=new k(n,e,s);this.probe=k.probe}this.resetInitSegment(c,o,v,h);this.resetInitialTimestamp(f)};i.needsProbing=function t(i,r,e){return!this.demuxer||!this.remuxer||r||e};i.getDecrypter=function t(){var i=this.decrypter;if(!i){i=this.decrypter=new s["default"](this.observer,this.config)}return i};return t}();function y(t,i){var r=null;if(t.byteLength>0&&i!=null&&i.key!=null&&i.iv!==null&&i.method!=null){r=i}return r}var w=function t(i){return{remuxResult:{},chunkMeta:i}};function A(t){return"then"in t&&t.then instanceof Function}var k=function t(i,r,e,n,s){this.audioCodec=void 0;this.videoCodec=void 0;this.initSegmentData=void 0;this.duration=void 0;this.defaultInitPts=void 0;this.audioCodec=i;this.videoCodec=r;this.initSegmentData=e;this.duration=n;this.defaultInitPts=s};var T=function t(i,r,e,n,s,a){this.discontinuity=void 0;this.contiguous=void 0;this.accurateTimeOffset=void 0;this.trackSwitch=void 0;this.timeOffset=void 0;this.initSegmentChange=void 0;this.discontinuity=i;this.contiguous=r;this.accurateTimeOffset=e;this.trackSwitch=n;this.timeOffset=s;this.initSegmentChange=a}},"./src/demux/tsdemuxer.ts":
|
|
178
|
+
/*!********************************!*\
|
|
179
|
+
!*** ./src/demux/tsdemuxer.ts ***!
|
|
180
|
+
\********************************/
|
|
181
|
+
/*! exports provided: discardEPB, default */function(t,i,r){r.r(i);r.d(i,"discardEPB",(function(){return w}));var e=r(/*! ./adts */"./src/demux/adts.ts");var n=r(/*! ./mpegaudio */"./src/demux/mpegaudio.ts");var s=r(/*! ./exp-golomb */"./src/demux/exp-golomb.ts");var a=r(/*! ./id3 */"./src/demux/id3.ts");var u=r(/*! ./sample-aes */"./src/demux/sample-aes.ts");var o=r(/*! ../events */"./src/events.ts");var f=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts");var h=r(/*! ../utils/logger */"./src/utils/logger.ts");var l=r(/*! ../errors */"./src/errors.ts");var c={video:1,audio:2,id3:3,text:4};var v=function(){function t(t,i,r){this.observer=void 0;this.config=void 0;this.typeSupported=void 0;this.sampleAes=null;this.pmtParsed=false;this.audioCodec=void 0;this.videoCodec=void 0;this._duration=0;this.aacLastPTS=null;this._initPTS=null;this._initDTS=null;this._pmtId=-1;this._avcTrack=void 0;this._audioTrack=void 0;this._id3Track=void 0;this._txtTrack=void 0;this.aacOverFlow=null;this.avcSample=null;this.remainderData=null;this.observer=t;this.config=i;this.typeSupported=r}t.probe=function i(r){var e=t.syncOffset(r);if(e<0){return false}else{if(e){h["logger"].warn("MPEG2-TS detected but first sync word found @ offset "+e+", junk ahead ?")}return true}};t.syncOffset=function t(i){var r=Math.min(1e3,i.length-3*188);var e=0;while(e<r){if(i[e]===71&&i[e+188]===71&&i[e+2*188]===71){return e}else{e++}}return-1};t.createTrack=function t(i,r){return{container:i==="video"||i==="audio"?"video/mp2t":undefined,type:i,id:c[i],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:i==="audio"?r:undefined}};var i=t.prototype;i.resetInitSegment=function i(r,e,n){this.pmtParsed=false;this._pmtId=-1;this._avcTrack=t.createTrack("video",n);this._audioTrack=t.createTrack("audio",n);this._id3Track=t.createTrack("id3",n);this._txtTrack=t.createTrack("text",n);this._audioTrack.isAAC=true;this.aacOverFlow=null;this.aacLastPTS=null;this.avcSample=null;this.audioCodec=r;this.videoCodec=e;this._duration=n};i.resetTimeStamp=function t(){};i.resetContiguity=function t(){var i=this._audioTrack,r=this._avcTrack,e=this._id3Track;if(i){i.pesData=null}if(r){r.pesData=null}if(e){e.pesData=null}this.aacOverFlow=null;this.aacLastPTS=null};i.demux=function i(r,e,n,s){if(n===void 0){n=false}if(s===void 0){s=false}if(!n){this.sampleAes=null}var a;var u=this._avcTrack;var c=this._audioTrack;var v=this._id3Track;var d=u.pid;var b=u.pesData;var y=c.pid;var w=v.pid;var A=c.pesData;var k=v.pesData;var T=false;var E=this.pmtParsed;var O=this._pmtId;var S=r.length;if(this.remainderData){r=Object(f["appendUint8Array"])(this.remainderData,r);S=r.length;this.remainderData=null}if(S<188&&!s){this.remainderData=r;return{audioTrack:c,avcTrack:u,id3Track:v,textTrack:this._txtTrack}}var M=Math.max(0,t.syncOffset(r));S-=(S+M)%188;if(S<r.byteLength&&!s){this.remainderData=new Uint8Array(r.buffer,S,r.buffer.byteLength-S)}var x=0;for(var j=M;j<S;j+=188){if(r[j]===71){var D=!!(r[j+1]&64);var I=((r[j+1]&31)<<8)+r[j+2];var L=(r[j+3]&48)>>4;var C=void 0;if(L>1){C=j+5+r[j+4];if(C===j+188){continue}}else{C=j+4}switch(I){case d:if(D){if(b&&(a=g(b))){this.parseAVCPES(a,false)}b={data:[],size:0}}if(b){b.data.push(r.subarray(C,j+188));b.size+=j+188-C}break;case y:if(D){if(A&&(a=g(A))){if(c.isAAC){this.parseAACPES(a)}else{this.parseMPEGPES(a)}}A={data:[],size:0}}if(A){A.data.push(r.subarray(C,j+188));A.size+=j+188-C}break;case w:if(D){if(k&&(a=g(k))){this.parseID3PES(a)}k={data:[],size:0}}if(k){k.data.push(r.subarray(C,j+188));k.size+=j+188-C}break;case 0:if(D){C+=r[C]+1}O=this._pmtId=m(r,C);break;case O:{if(D){C+=r[C]+1}var R=p(r,C,this.typeSupported.mpeg===true||this.typeSupported.mp3===true,n);d=R.avc;if(d>0){u.pid=d}y=R.audio;if(y>0){c.pid=y;c.isAAC=R.isAAC}w=R.id3;if(w>0){v.pid=w}if(T&&!E){h["logger"].log("reparse from beginning");T=false;j=M-188}E=this.pmtParsed=true;break}case 17:case 8191:break;default:T=true;break}}else{x++}}if(x>0){this.observer.emit(o["Events"].ERROR,o["Events"].ERROR,{type:l["ErrorTypes"].MEDIA_ERROR,details:l["ErrorDetails"].FRAG_PARSING_ERROR,fatal:false,reason:"Found "+x+" TS packet/s that do not start with 0x47"})}u.pesData=b;c.pesData=A;v.pesData=k;var N={audioTrack:c,avcTrack:u,id3Track:v,textTrack:this._txtTrack};if(s){this.extractRemainingSamples(N)}return N};i.flush=function t(){var i=this.remainderData;this.remainderData=null;var r;if(i){r=this.demux(i,-1,false,true)}else{r={audioTrack:this._audioTrack,avcTrack:this._avcTrack,textTrack:this._txtTrack,id3Track:this._id3Track}}this.extractRemainingSamples(r);if(this.sampleAes){return this.decrypt(r,this.sampleAes)}return r};i.extractRemainingSamples=function t(i){var r=i.audioTrack,e=i.avcTrack,n=i.id3Track;var s=e.pesData;var a=r.pesData;var u=n.pesData;var o;if(s&&(o=g(s))){this.parseAVCPES(o,true);e.pesData=null}else{e.pesData=s}if(a&&(o=g(a))){if(r.isAAC){this.parseAACPES(o)}else{this.parseMPEGPES(o)}r.pesData=null}else{if(a!==null&&a!==void 0&&a.size){h["logger"].log("last AAC PES packet truncated,might overlap between fragments")}r.pesData=a}if(u&&(o=g(u))){this.parseID3PES(o);n.pesData=null}else{n.pesData=u}};i.demuxSampleAes=function t(i,r,e){var n=this.demux(i,e,true,!this.config.progressive);var s=this.sampleAes=new u["default"](this.observer,this.config,r);return this.decrypt(n,s)};i.decrypt=function t(i,r){return new Promise((function(t){var e=i.audioTrack,n=i.avcTrack;if(e.samples&&e.isAAC){r.decryptAacSamples(e.samples,0,(function(){if(n.samples){r.decryptAvcSamples(n.samples,0,0,(function(){t(i)}))}else{t(i)}}))}else if(n.samples){r.decryptAvcSamples(n.samples,0,0,(function(){t(i)}))}}))};i.destroy=function t(){this._initPTS=this._initDTS=null;this._duration=0};i.parseAVCPES=function t(i,r){var e=this;var n=this._avcTrack;var u=this.parseAVCNALu(i.data);var o=this.avcSample;var f;var h=false;i.data=null;if(o&&u.length&&!n.audFound){b(o,n);o=this.avcSample=d(false,i.pts,i.dts,"")}u.forEach((function(t){switch(t.type){case 1:{f=true;if(!o){o=e.avcSample=d(true,i.pts,i.dts,"")}o.frame=true;var r=t.data;if(h&&r.length>4){var u=new s["default"](r).readSliceType();if(u===2||u===4||u===7||u===9){o.key=true}}break}case 5:f=true;if(!o){o=e.avcSample=d(true,i.pts,i.dts,"")}o.key=true;o.frame=true;break;case 6:{f=true;var l=new s["default"](w(t.data));l.readUByte();var c=0;var v=0;var m=false;var p=0;while(!m&&l.bytesAvailable>1){c=0;do{p=l.readUByte();c+=p}while(p===255);v=0;do{p=l.readUByte();v+=p}while(p===255);if(c===4&&l.bytesAvailable!==0){m=true;var g=l.readUByte();if(g===181){var A=l.readUShort();if(A===49){var k=l.readUInt();if(k===1195456820){var T=l.readUByte();if(T===3){var E=l.readUByte();var O=l.readUByte();var S=31&E;var M=[E,O];for(var x=0;x<S;x++){M.push(l.readUByte());M.push(l.readUByte());M.push(l.readUByte())}y(e._txtTrack.samples,{type:3,pts:i.pts,bytes:M})}}}}}else if(c===5&&l.bytesAvailable!==0){m=true;if(v>16){var j=[];for(var D=0;D<16;D++){j.push(l.readUByte().toString(16));if(D===3||D===5||D===7||D===9){j.push("-")}}var I=v-16;var L=new Uint8Array(I);for(var C=0;C<I;C++){L[C]=l.readUByte()}y(e._txtTrack.samples,{pts:i.pts,payloadType:c,uuid:j.join(""),userData:Object(a["utf8ArrayToStr"])(L),userDataBytes:L})}}else if(v<l.bytesAvailable){for(var R=0;R<v;R++){l.readUByte()}}}break}case 7:f=true;h=true;if(!n.sps){var N=new s["default"](t.data);var U=N.readSPS();n.width=U.width;n.height=U.height;n.pixelRatio=U.pixelRatio;n.sps=[t.data];n.duration=e._duration;var P=t.data.subarray(1,4);var F="avc1.";for(var B=0;B<3;B++){var G=P[B].toString(16);if(G.length<2){G="0"+G}F+=G}n.codec=F}break;case 8:f=true;if(!n.pps){n.pps=[t.data]}break;case 9:f=false;n.audFound=true;if(o){b(o,n)}o=e.avcSample=d(false,i.pts,i.dts,"");break;case 12:f=false;break;default:f=false;if(o){o.debug+="unknown NAL "+t.type+" "}break}if(o&&f){var W=o.units;W.push(t)}}));if(r&&o){b(o,n);this.avcSample=null}};i.getLastNalUnit=function t(){var i;var r=this.avcSample;var e;if(!r||r.units.length===0){var n=this._avcTrack.samples;r=n[n.length-1]}if((i=r)!==null&&i!==void 0&&i.units){var s=r.units;e=s[s.length-1]}return e};i.parseAVCNALu=function t(i){var r=i.byteLength;var e=this._avcTrack;var n=e.naluState||0;var s=n;var a=[];var u=0;var o;var f;var h;var l=-1;var c=0;if(n===-1){l=0;c=i[0]&31;n=0;u=1}while(u<r){o=i[u++];if(!n){n=o?0:1;continue}if(n===1){n=o?0:2;continue}if(!o){n=3}else if(o===1){if(l>=0){var v={data:i.subarray(l,u-n-1),type:c};a.push(v)}else{var d=this.getLastNalUnit();if(d){if(s&&u<=4-s){if(d.state){d.data=d.data.subarray(0,d.data.byteLength-s)}}f=u-n-1;if(f>0){var m=new Uint8Array(d.data.byteLength+f);m.set(d.data,0);m.set(i.subarray(0,f),d.data.byteLength);d.data=m;d.state=0}}}if(u<r){h=i[u]&31;l=u;c=h;n=0}else{n=-1}}else{n=0}}if(l>=0&&n>=0){var p={data:i.subarray(l,r),type:c,state:n};a.push(p)}if(a.length===0){var g=this.getLastNalUnit();if(g){var b=new Uint8Array(g.data.byteLength+i.byteLength);b.set(g.data,0);b.set(i,g.data.byteLength);g.data=b}}e.naluState=n;return a};i.parseAACPES=function t(i){var r=0;var n=this._audioTrack;var s=this.aacOverFlow;var a=i.data;if(s){this.aacOverFlow=null;var u=s.sample.unit.byteLength;var f=Math.min(s.missing,u);var c=u-f;s.sample.unit.set(a.subarray(0,f),c);n.samples.push(s.sample);r=s.missing}var v;var d;for(v=r,d=a.length;v<d-1;v++){if(e["isHeader"](a,v)){break}}if(v!==r){var m;var p;if(v<d-1){m="AAC PES did not start with ADTS header,offset:"+v;p=false}else{m="no ADTS header found in AAC PES";p=true}h["logger"].warn("parsing error:"+m);this.observer.emit(o["Events"].ERROR,o["Events"].ERROR,{type:l["ErrorTypes"].MEDIA_ERROR,details:l["ErrorDetails"].FRAG_PARSING_ERROR,fatal:p,reason:m});if(p){return}}e["initTrackConfig"](n,this.observer,a,v,this.audioCodec);var g;if(i.pts!==undefined){g=i.pts}else if(s){var b=e["getFrameDuration"](n.samplerate);g=s.sample.pts+b}else{h["logger"].warn("[tsdemuxer]: AAC PES unknown PTS");return}var y=0;while(v<d){if(e["isHeader"](a,v)){if(v+5<d){var w=e["appendFrame"](n,a,v,g,y);if(w){if(w.missing){this.aacOverFlow=w}else{v+=w.length;y++;continue}}}break}else{v++}}};i.parseMPEGPES=function t(i){var r=i.data;var e=r.length;var s=0;var a=0;var u=i.pts;if(u===undefined){h["logger"].warn("[tsdemuxer]: MPEG PES unknown PTS");return}while(a<e){if(n["isHeader"](r,a)){var o=n["appendFrame"](this._audioTrack,r,a,u,s);if(o){a+=o.length;s++}else{break}}else{a++}}};i.parseID3PES=function t(i){if(i.pts===undefined){h["logger"].warn("[tsdemuxer]: ID3 PES unknown PTS");return}this._id3Track.samples.push(i)};return t}();v.minProbeByteLength=188;function d(t,i,r,e){return{key:t,frame:false,pts:i,dts:r,units:[],debug:e,length:0}}function m(t,i){return(t[i+10]&31)<<8|t[i+11]}function p(t,i,r,e){var n={audio:-1,avc:-1,id3:-1,isAAC:true};var s=(t[i+1]&15)<<8|t[i+2];var a=i+3+s-4;var u=(t[i+10]&15)<<8|t[i+11];i+=12+u;while(i<a){var o=(t[i+1]&31)<<8|t[i+2];switch(t[i]){case 207:if(!e){h["logger"].log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:if(n.audio===-1){n.audio=o}break;case 21:if(n.id3===-1){n.id3=o}break;case 219:if(!e){h["logger"].log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:if(n.avc===-1){n.avc=o}break;case 3:case 4:if(!r){h["logger"].log("MPEG audio found, not supported in this browser")}else if(n.audio===-1){n.audio=o;n.isAAC=false}break;case 36:h["logger"].warn("Unsupported HEVC stream type found");break}i+=((t[i+3]&15)<<8|t[i+4])+5}return n}function g(t){var i=0;var r;var e;var n;var s;var a;var u=t.data;if(!t||t.size===0){return null}while(u[0].length<19&&u.length>1){var o=new Uint8Array(u[0].length+u[1].length);o.set(u[0]);o.set(u[1],u[0].length);u[0]=o;u.splice(1,1)}r=u[0];var f=(r[0]<<16)+(r[1]<<8)+r[2];if(f===1){e=(r[4]<<8)+r[5];if(e&&e>t.size-6){return null}var l=r[7];if(l&192){s=(r[9]&14)*536870912+(r[10]&255)*4194304+(r[11]&254)*16384+(r[12]&255)*128+(r[13]&254)/2;if(l&64){a=(r[14]&14)*536870912+(r[15]&255)*4194304+(r[16]&254)*16384+(r[17]&255)*128+(r[18]&254)/2;if(s-a>60*9e4){h["logger"].warn(Math.round((s-a)/9e4)+"s delta between PTS and DTS, align them");s=a}}else{a=s}}n=r[8];var c=n+9;if(t.size<=c){return null}t.size-=c;var v=new Uint8Array(t.size);for(var d=0,m=u.length;d<m;d++){r=u[d];var p=r.byteLength;if(c){if(c>p){c-=p;continue}else{r=r.subarray(c);p-=c;c=0}}v.set(r,i);i+=p}if(e){e-=n+3}return{data:v,pts:s,dts:a,len:e}}return null}function b(t,i){if(t.units.length&&t.frame){if(t.pts===undefined){var r=i.samples;var e=r.length;if(e){var n=r[e-1];t.pts=n.pts;t.dts=n.dts}else{i.dropped++;return}}i.samples.push(t)}if(t.debug.length){h["logger"].log(t.pts+"/"+t.dts+":"+t.debug)}}function y(t,i){var r=t.length;if(r>0){if(i.pts>=t[r-1].pts){t.push(i)}else{for(var e=r-1;e>=0;e--){if(i.pts<t[e].pts){t.splice(e,0,i);break}}}}else{t.push(i)}}function w(t){var i=t.byteLength;var r=[];var e=1;while(e<i-2){if(t[e]===0&&t[e+1]===0&&t[e+2]===3){r.push(e+2);e+=2}else{e++}}if(r.length===0){return t}var n=i-r.length;var s=new Uint8Array(n);var a=0;for(e=0;e<n;a++,e++){if(a===r[0]){a++;r.shift()}s[e]=t[a]}return s}i["default"]=v},"./src/errors.ts":
|
|
182
|
+
/*!***********************!*\
|
|
183
|
+
!*** ./src/errors.ts ***!
|
|
184
|
+
\***********************/
|
|
185
|
+
/*! exports provided: ErrorTypes, ErrorDetails */function(t,i,r){r.r(i);r.d(i,"ErrorTypes",(function(){return e}));r.d(i,"ErrorDetails",(function(){return n}));var e;(function(t){t["NETWORK_ERROR"]="networkError";t["MEDIA_ERROR"]="mediaError";t["KEY_SYSTEM_ERROR"]="keySystemError";t["MUX_ERROR"]="muxError";t["OTHER_ERROR"]="otherError"})(e||(e={}));var n;(function(t){t["KEY_SYSTEM_NO_KEYS"]="keySystemNoKeys";t["KEY_SYSTEM_NO_ACCESS"]="keySystemNoAccess";t["KEY_SYSTEM_NO_SESSION"]="keySystemNoSession";t["KEY_SYSTEM_LICENSE_REQUEST_FAILED"]="keySystemLicenseRequestFailed";t["KEY_SYSTEM_NO_INIT_DATA"]="keySystemNoInitData";t["MANIFEST_LOAD_ERROR"]="manifestLoadError";t["MANIFEST_LOAD_TIMEOUT"]="manifestLoadTimeOut";t["MANIFEST_PARSING_ERROR"]="manifestParsingError";t["MANIFEST_INCOMPATIBLE_CODECS_ERROR"]="manifestIncompatibleCodecsError";t["LEVEL_EMPTY_ERROR"]="levelEmptyError";t["LEVEL_LOAD_ERROR"]="levelLoadError";t["LEVEL_LOAD_TIMEOUT"]="levelLoadTimeOut";t["LEVEL_SWITCH_ERROR"]="levelSwitchError";t["AUDIO_TRACK_LOAD_ERROR"]="audioTrackLoadError";t["AUDIO_TRACK_LOAD_TIMEOUT"]="audioTrackLoadTimeOut";t["SUBTITLE_LOAD_ERROR"]="subtitleTrackLoadError";t["SUBTITLE_TRACK_LOAD_TIMEOUT"]="subtitleTrackLoadTimeOut";t["FRAG_LOAD_ERROR"]="fragLoadError";t["FRAG_LOAD_TIMEOUT"]="fragLoadTimeOut";t["FRAG_DECRYPT_ERROR"]="fragDecryptError";t["FRAG_PARSING_ERROR"]="fragParsingError";t["REMUX_ALLOC_ERROR"]="remuxAllocError";t["KEY_LOAD_ERROR"]="keyLoadError";t["KEY_LOAD_TIMEOUT"]="keyLoadTimeOut";t["BUFFER_ADD_CODEC_ERROR"]="bufferAddCodecError";t["BUFFER_INCOMPATIBLE_CODECS_ERROR"]="bufferIncompatibleCodecsError";t["BUFFER_APPEND_ERROR"]="bufferAppendError";t["BUFFER_APPENDING_ERROR"]="bufferAppendingError";t["BUFFER_STALLED_ERROR"]="bufferStalledError";t["BUFFER_FULL_ERROR"]="bufferFullError";t["BUFFER_SEEK_OVER_HOLE"]="bufferSeekOverHole";t["BUFFER_NUDGE_ON_STALL"]="bufferNudgeOnStall";t["INTERNAL_EXCEPTION"]="internalException";t["INTERNAL_ABORTED"]="aborted";t["UNKNOWN"]="unknown"})(n||(n={}))},"./src/events.ts":
|
|
186
|
+
/*!***********************!*\
|
|
187
|
+
!*** ./src/events.ts ***!
|
|
188
|
+
\***********************/
|
|
189
|
+
/*! exports provided: Events */function(t,i,r){r.r(i);r.d(i,"Events",(function(){return e}));var e;(function(t){t["MEDIA_ATTACHING"]="hlsMediaAttaching";t["MEDIA_ATTACHED"]="hlsMediaAttached";t["MEDIA_DETACHING"]="hlsMediaDetaching";t["MEDIA_DETACHED"]="hlsMediaDetached";t["BUFFER_RESET"]="hlsBufferReset";t["BUFFER_CODECS"]="hlsBufferCodecs";t["BUFFER_CREATED"]="hlsBufferCreated";t["BUFFER_APPENDING"]="hlsBufferAppending";t["BUFFER_APPENDED"]="hlsBufferAppended";t["BUFFER_EOS"]="hlsBufferEos";t["BUFFER_FLUSHING"]="hlsBufferFlushing";t["BUFFER_FLUSHED"]="hlsBufferFlushed";t["MANIFEST_LOADING"]="hlsManifestLoading";t["MANIFEST_LOADED"]="hlsManifestLoaded";t["MANIFEST_PARSED"]="hlsManifestParsed";t["LEVEL_SWITCHING"]="hlsLevelSwitching";t["LEVEL_SWITCHED"]="hlsLevelSwitched";t["LEVEL_LOADING"]="hlsLevelLoading";t["LEVEL_LOADED"]="hlsLevelLoaded";t["LEVEL_UPDATED"]="hlsLevelUpdated";t["LEVEL_PTS_UPDATED"]="hlsLevelPtsUpdated";t["LEVELS_UPDATED"]="hlsLevelsUpdated";t["AUDIO_TRACKS_UPDATED"]="hlsAudioTracksUpdated";t["AUDIO_TRACK_SWITCHING"]="hlsAudioTrackSwitching";t["AUDIO_TRACK_SWITCHED"]="hlsAudioTrackSwitched";t["AUDIO_TRACK_LOADING"]="hlsAudioTrackLoading";t["AUDIO_TRACK_LOADED"]="hlsAudioTrackLoaded";t["SUBTITLE_TRACKS_UPDATED"]="hlsSubtitleTracksUpdated";t["SUBTITLE_TRACKS_CLEARED"]="hlsSubtitleTracksCleared";t["SUBTITLE_TRACK_SWITCH"]="hlsSubtitleTrackSwitch";t["SUBTITLE_TRACK_LOADING"]="hlsSubtitleTrackLoading";t["SUBTITLE_TRACK_LOADED"]="hlsSubtitleTrackLoaded";t["SUBTITLE_FRAG_PROCESSED"]="hlsSubtitleFragProcessed";t["CUES_PARSED"]="hlsCuesParsed";t["NON_NATIVE_TEXT_TRACKS_FOUND"]="hlsNonNativeTextTracksFound";t["INIT_PTS_FOUND"]="hlsInitPtsFound";t["FRAG_LOADING"]="hlsFragLoading";t["FRAG_LOAD_EMERGENCY_ABORTED"]="hlsFragLoadEmergencyAborted";t["FRAG_LOADED"]="hlsFragLoaded";t["FRAG_DECRYPTED"]="hlsFragDecrypted";t["FRAG_PARSING_INIT_SEGMENT"]="hlsFragParsingInitSegment";t["FRAG_PARSING_USERDATA"]="hlsFragParsingUserdata";t["FRAG_PARSING_METADATA"]="hlsFragParsingMetadata";t["FRAG_PARSED"]="hlsFragParsed";t["FRAG_BUFFERED"]="hlsFragBuffered";t["FRAG_CHANGED"]="hlsFragChanged";t["FPS_DROP"]="hlsFpsDrop";t["FPS_DROP_LEVEL_CAPPING"]="hlsFpsDropLevelCapping";t["ERROR"]="hlsError";t["DESTROYING"]="hlsDestroying";t["KEY_LOADING"]="hlsKeyLoading";t["KEY_LOADED"]="hlsKeyLoaded";t["LIVE_BACK_BUFFER_REACHED"]="hlsLiveBackBufferReached";t["BACK_BUFFER_REACHED"]="hlsBackBufferReached"})(e||(e={}))},"./src/hls.ts":
|
|
190
|
+
/*!********************!*\
|
|
191
|
+
!*** ./src/hls.ts ***!
|
|
192
|
+
\********************/
|
|
193
|
+
/*! exports provided: default */function(t,i,r){r.r(i);r.d(i,"default",(function(){return y}));var e=r(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js");var n=r(/*! ./loader/playlist-loader */"./src/loader/playlist-loader.ts");var s=r(/*! ./loader/key-loader */"./src/loader/key-loader.ts");var a=r(/*! ./controller/id3-track-controller */"./src/controller/id3-track-controller.ts");var u=r(/*! ./controller/latency-controller */"./src/controller/latency-controller.ts");var o=r(/*! ./controller/level-controller */"./src/controller/level-controller.ts");var f=r(/*! ./controller/fragment-tracker */"./src/controller/fragment-tracker.ts");var h=r(/*! ./controller/stream-controller */"./src/controller/stream-controller.ts");var l=r(/*! ./is-supported */"./src/is-supported.ts");var c=r(/*! ./utils/logger */"./src/utils/logger.ts");var v=r(/*! ./config */"./src/config.ts");var d=r(/*! eventemitter3 */"./node_modules/eventemitter3/index.js");var m=r(/*! ./events */"./src/events.ts");var p=r(/*! ./errors */"./src/errors.ts");function g(t,i){for(var r=0;r<i.length;r++){var e=i[r];e.enumerable=e.enumerable||false;e.configurable=true;if("value"in e)e.writable=true;Object.defineProperty(t,e.key,e)}}function b(t,i,r){if(i)g(t.prototype,i);if(r)g(t,r);return t}var y=function(){t.isSupported=function t(){return Object(l["isSupported"])()};function t(i){if(i===void 0){i={}}this.config=void 0;this.userConfig=void 0;this.coreComponents=void 0;this.networkControllers=void 0;this._emitter=new d["EventEmitter"];this._autoLevelCapping=void 0;this.abrController=void 0;this.bufferController=void 0;this.capLevelController=void 0;this.latencyController=void 0;this.levelController=void 0;this.streamController=void 0;this.audioTrackController=void 0;this.subtitleTrackController=void 0;this.emeController=void 0;this.cmcdController=void 0;this._media=null;this.url=null;var r=this.config=Object(v["mergeConfig"])(t.DefaultConfig,i);this.userConfig=i;Object(c["enableLogs"])(r.debug);this._autoLevelCapping=-1;if(r.progressive){Object(v["enableStreamingMode"])(r)}var e=r.abrController,l=r.bufferController,m=r.capLevelController,p=r.fpsController;var g=this.abrController=new e(this);var b=this.bufferController=new l(this);var y=this.capLevelController=new m(this);var w=new p(this);var A=new n["default"](this);var k=new s["default"](this);var T=new a["default"](this);var E=this.levelController=new o["default"](this);var O=new f["FragmentTracker"](this);var S=this.streamController=new h["default"](this,O);y.setStreamController(S);w.setStreamController(S);var M=[E,S];this.networkControllers=M;var x=[A,k,g,b,y,w,T,O];this.audioTrackController=this.createController(r.audioTrackController,null,M);this.createController(r.audioStreamController,O,M);this.subtitleTrackController=this.createController(r.subtitleTrackController,null,M);this.createController(r.subtitleStreamController,O,M);this.createController(r.timelineController,null,x);this.emeController=this.createController(r.emeController,null,x);this.cmcdController=this.createController(r.cmcdController,null,x);this.latencyController=this.createController(u["default"],null,x);this.coreComponents=x}var i=t.prototype;i.createController=function t(i,r,e){if(i){var n=r?new i(this,r):new i(this);if(e){e.push(n)}return n}return null};i.on=function t(i,r,e){if(e===void 0){e=this}this._emitter.on(i,r,e)};i.once=function t(i,r,e){if(e===void 0){e=this}this._emitter.once(i,r,e)};i.removeAllListeners=function t(i){this._emitter.removeAllListeners(i)};i.off=function t(i,r,e,n){if(e===void 0){e=this}this._emitter.off(i,r,e,n)};i.listeners=function t(i){return this._emitter.listeners(i)};i.emit=function t(i,r,e){return this._emitter.emit(i,r,e)};i.trigger=function t(i,r){if(this.config.debug){return this.emit(i,i,r)}else{try{return this.emit(i,i,r)}catch(t){c["logger"].error("An internal error happened while handling event "+i+'. Error message: "'+t.message+'". Here is a stacktrace:',t);this.trigger(m["Events"].ERROR,{type:p["ErrorTypes"].OTHER_ERROR,details:p["ErrorDetails"].INTERNAL_EXCEPTION,fatal:false,event:i,error:t})}}return false};i.listenerCount=function t(i){return this._emitter.listenerCount(i)};i.destroy=function t(){c["logger"].log("destroy");this.trigger(m["Events"].DESTROYING,undefined);this.detachMedia();this.removeAllListeners();this._autoLevelCapping=-1;this.url=null;this.networkControllers.forEach((function(t){return t.destroy()}));this.networkControllers.length=0;this.coreComponents.forEach((function(t){return t.destroy()}));this.coreComponents.length=0};i.attachMedia=function t(i){c["logger"].log("attachMedia");this._media=i;this.trigger(m["Events"].MEDIA_ATTACHING,{media:i})};i.detachMedia=function t(){c["logger"].log("detachMedia");this.trigger(m["Events"].MEDIA_DETACHING,undefined);this._media=null};i.loadSource=function t(i){this.stopLoad();var r=this.media;var n=this.url;var s=this.url=e["buildAbsoluteURL"](self.location.href,i,{alwaysNormalize:true});c["logger"].log("loadSource:"+s);if(r&&n&&n!==s&&this.bufferController.hasSourceTypes()){this.detachMedia();this.attachMedia(r)}this.trigger(m["Events"].MANIFEST_LOADING,{url:i})};i.startLoad=function t(i){if(i===void 0){i=-1}c["logger"].log("startLoad("+i+")");this.networkControllers.forEach((function(t){t.startLoad(i)}))};i.stopLoad=function t(){c["logger"].log("stopLoad");this.networkControllers.forEach((function(t){t.stopLoad()}))};i.swapAudioCodec=function t(){c["logger"].log("swapAudioCodec");this.streamController.swapAudioCodec()};i.recoverMediaError=function t(){c["logger"].log("recoverMediaError");var i=this._media;this.detachMedia();if(i){this.attachMedia(i)}};i.removeLevel=function t(i,r){if(r===void 0){r=0}this.levelController.removeLevel(i,r)};b(t,[{key:"levels",get:function t(){var i=this.levelController.levels;return i?i:[]}},{key:"currentLevel",get:function t(){return this.streamController.currentLevel},set:function t(i){c["logger"].log("set currentLevel:"+i);this.loadLevel=i;this.abrController.clearTimer();this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function t(){return this.streamController.nextLevel},set:function t(i){c["logger"].log("set nextLevel:"+i);this.levelController.manualLevel=i;this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function t(){return this.levelController.level},set:function t(i){c["logger"].log("set loadLevel:"+i);this.levelController.manualLevel=i}},{key:"nextLoadLevel",get:function t(){return this.levelController.nextLoadLevel},set:function t(i){this.levelController.nextLoadLevel=i}},{key:"firstLevel",get:function t(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function t(i){c["logger"].log("set firstLevel:"+i);this.levelController.firstLevel=i}},{key:"startLevel",get:function t(){return this.levelController.startLevel},set:function t(i){c["logger"].log("set startLevel:"+i);if(i!==-1){i=Math.max(i,this.minAutoLevel)}this.levelController.startLevel=i}},{key:"capLevelToPlayerSize",get:function t(){return this.config.capLevelToPlayerSize},set:function t(i){var r=!!i;if(r!==this.config.capLevelToPlayerSize){if(r){this.capLevelController.startCapping()}else{this.capLevelController.stopCapping();this.autoLevelCapping=-1;this.streamController.nextLevelSwitch()}this.config.capLevelToPlayerSize=r}}},{key:"autoLevelCapping",get:function t(){return this._autoLevelCapping},set:function t(i){if(this._autoLevelCapping!==i){c["logger"].log("set autoLevelCapping:"+i);this._autoLevelCapping=i}}},{key:"bandwidthEstimate",get:function t(){var i=this.abrController.bwEstimator;if(!i){return NaN}return i.getEstimate()}},{key:"autoLevelEnabled",get:function t(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function t(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function t(){var i=this.levels,r=this.config.minAutoBitrate;if(!i)return 0;var e=i.length;for(var n=0;n<e;n++){if(i[n].maxBitrate>r){return n}}return 0}},{key:"maxAutoLevel",get:function t(){var i=this.levels,r=this.autoLevelCapping;var e;if(r===-1&&i&&i.length){e=i.length-1}else{e=r}return e}},{key:"nextAutoLevel",get:function t(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function t(i){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,i)}},{key:"audioTracks",get:function t(){var i=this.audioTrackController;return i?i.audioTracks:[]}},{key:"audioTrack",get:function t(){var i=this.audioTrackController;return i?i.audioTrack:-1},set:function t(i){var r=this.audioTrackController;if(r){r.audioTrack=i}}},{key:"subtitleTracks",get:function t(){var i=this.subtitleTrackController;return i?i.subtitleTracks:[]}},{key:"subtitleTrack",get:function t(){var i=this.subtitleTrackController;return i?i.subtitleTrack:-1},set:function t(i){var r=this.subtitleTrackController;if(r){r.subtitleTrack=i}}},{key:"media",get:function t(){return this._media}},{key:"subtitleDisplay",get:function t(){var i=this.subtitleTrackController;return i?i.subtitleDisplay:false},set:function t(i){var r=this.subtitleTrackController;if(r){r.subtitleDisplay=i}}},{key:"lowLatencyMode",get:function t(){return this.config.lowLatencyMode},set:function t(i){this.config.lowLatencyMode=i}},{key:"liveSyncPosition",get:function t(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function t(){return this.latencyController.latency}},{key:"maxLatency",get:function t(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function t(){return this.latencyController.targetLatency}},{key:"drift",get:function t(){return this.latencyController.drift}},{key:"forceStartLoad",get:function t(){return this.streamController.forceStartLoad}}],[{key:"version",get:function t(){return"1.1.5"}},{key:"Events",get:function t(){return m["Events"]}},{key:"ErrorTypes",get:function t(){return p["ErrorTypes"]}},{key:"ErrorDetails",get:function t(){return p["ErrorDetails"]}},{key:"DefaultConfig",get:function i(){if(!t.defaultConfig){return v["hlsDefaultConfig"]}return t.defaultConfig},set:function i(r){t.defaultConfig=r}}]);return t}();y.defaultConfig=void 0},"./src/is-supported.ts":
|
|
194
|
+
/*!*****************************!*\
|
|
195
|
+
!*** ./src/is-supported.ts ***!
|
|
196
|
+
\*****************************/
|
|
197
|
+
/*! exports provided: isSupported, changeTypeSupported */function(t,i,r){r.r(i);r.d(i,"isSupported",(function(){return s}));r.d(i,"changeTypeSupported",(function(){return a}));var e=r(/*! ./utils/mediasource-helper */"./src/utils/mediasource-helper.ts");function n(){return self.SourceBuffer||self.WebKitSourceBuffer}function s(){var t=Object(e["getMediaSource"])();if(!t){return false}var i=n();var r=t&&typeof t.isTypeSupported==="function"&&t.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"');var s=!i||i.prototype&&typeof i.prototype.appendBuffer==="function"&&typeof i.prototype.remove==="function";return!!r&&!!s}function a(){var t;var i=n();return typeof(i===null||i===void 0?void 0:(t=i.prototype)===null||t===void 0?void 0:t.changeType)==="function"}},"./src/loader/fragment-loader.ts":
|
|
198
|
+
/*!***************************************!*\
|
|
199
|
+
!*** ./src/loader/fragment-loader.ts ***!
|
|
200
|
+
\***************************************/
|
|
201
|
+
/*! exports provided: default, LoadError */function(t,i,r){r.r(i);r.d(i,"default",(function(){return v}));r.d(i,"LoadError",(function(){return m}));var e=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");var n=r(/*! ../errors */"./src/errors.ts");function s(t,i){t.prototype=Object.create(i.prototype);t.prototype.constructor=t;h(t,i)}function a(t){var i=typeof Map==="function"?new Map:undefined;a=function t(r){if(r===null||!f(r))return r;if(typeof r!=="function"){throw new TypeError("Super expression must either be null or a function")}if(typeof i!=="undefined"){if(i.has(r))return i.get(r);i.set(r,e)}function e(){return u(r,arguments,l(this).constructor)}e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:false,writable:true,configurable:true}});return h(e,r)};return a(t)}function u(t,i,r){if(o()){u=Reflect.construct}else{u=function t(i,r,e){var n=[null];n.push.apply(n,r);var s=Function.bind.apply(i,n);var a=new s;if(e)h(a,e.prototype);return a}}return u.apply(null,arguments)}function o(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})));return true}catch(t){return false}}function f(t){return Function.toString.call(t).indexOf("[native code]")!==-1}function h(t,i){h=Object.setPrototypeOf||function t(i,r){i.__proto__=r;return i};return h(t,i)}function l(t){l=Object.setPrototypeOf?Object.getPrototypeOf:function t(i){return i.__proto__||Object.getPrototypeOf(i)};return l(t)}var c=Math.pow(2,17);var v=function(){function t(t){this.config=void 0;this.loader=null;this.partLoadTimeout=-1;this.config=t}var i=t.prototype;i.destroy=function t(){if(this.loader){this.loader.destroy();this.loader=null}};i.abort=function t(){if(this.loader){this.loader.abort()}};i.load=function t(i,r){var e=this;var s=i.url;if(!s){return Promise.reject(new m({type:n["ErrorTypes"].NETWORK_ERROR,details:n["ErrorDetails"].FRAG_LOAD_ERROR,fatal:false,frag:i,networkDetails:null},"Fragment does not have a "+(s?"part list":"url")))}this.abort();var a=this.config;var u=a.fLoader;var o=a.loader;return new Promise((function(t,s){if(e.loader){e.loader.destroy()}var f=e.loader=i.loader=u?new u(a):new o(a);var h=d(i);var l={timeout:a.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:a.fragLoadingMaxRetryTimeout,highWaterMark:c};i.stats=f.stats;f.load(h,l,{onSuccess:function r(n,s,a,u){e.resetLoader(i,f);t({frag:i,part:null,payload:n.data,networkDetails:u})},onError:function t(r,a,u){e.resetLoader(i,f);s(new m({type:n["ErrorTypes"].NETWORK_ERROR,details:n["ErrorDetails"].FRAG_LOAD_ERROR,fatal:false,frag:i,response:r,networkDetails:u}))},onAbort:function t(r,a,u){e.resetLoader(i,f);s(new m({type:n["ErrorTypes"].NETWORK_ERROR,details:n["ErrorDetails"].INTERNAL_ABORTED,fatal:false,frag:i,networkDetails:u}))},onTimeout:function t(r,a,u){e.resetLoader(i,f);s(new m({type:n["ErrorTypes"].NETWORK_ERROR,details:n["ErrorDetails"].FRAG_LOAD_TIMEOUT,fatal:false,frag:i,networkDetails:u}))},onProgress:function t(e,n,s,a){if(r){r({frag:i,part:null,payload:s,networkDetails:a})}}})}))};i.loadPart=function t(i,r,e){var s=this;this.abort();var a=this.config;var u=a.fLoader;var o=a.loader;return new Promise((function(t,f){if(s.loader){s.loader.destroy()}var h=s.loader=i.loader=u?new u(a):new o(a);var l=d(i,r);var v={timeout:a.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:a.fragLoadingMaxRetryTimeout,highWaterMark:c};r.stats=h.stats;h.load(l,v,{onSuccess:function n(a,u,o,f){s.resetLoader(i,h);s.updateStatsFromPart(i,r);var l={frag:i,part:r,payload:a.data,networkDetails:f};e(l);t(l)},onError:function t(e,a,u){s.resetLoader(i,h);f(new m({type:n["ErrorTypes"].NETWORK_ERROR,details:n["ErrorDetails"].FRAG_LOAD_ERROR,fatal:false,frag:i,part:r,response:e,networkDetails:u}))},onAbort:function t(e,a,u){i.stats.aborted=r.stats.aborted;s.resetLoader(i,h);f(new m({type:n["ErrorTypes"].NETWORK_ERROR,details:n["ErrorDetails"].INTERNAL_ABORTED,fatal:false,frag:i,part:r,networkDetails:u}))},onTimeout:function t(e,a,u){s.resetLoader(i,h);f(new m({type:n["ErrorTypes"].NETWORK_ERROR,details:n["ErrorDetails"].FRAG_LOAD_TIMEOUT,fatal:false,frag:i,part:r,networkDetails:u}))}})}))};i.updateStatsFromPart=function t(i,r){var e=i.stats;var n=r.stats;var s=n.total;e.loaded+=n.loaded;if(s){var a=Math.round(i.duration/r.duration);var u=Math.min(Math.round(e.loaded/s),a);var o=a-u;var f=o*Math.round(e.loaded/u);e.total=e.loaded+f}else{e.total=Math.max(e.loaded,e.total)}var h=e.loading;var l=n.loading;if(h.start){h.first+=l.first-l.start}else{h.start=l.start;h.first=l.first}h.end=l.end};i.resetLoader=function t(i,r){i.loader=null;if(this.loader===r){self.clearTimeout(this.partLoadTimeout);this.loader=null}r.destroy()};return t}();function d(t,i){if(i===void 0){i=null}var r=i||t;var n={frag:t,part:i,responseType:"arraybuffer",url:r.url,headers:{},rangeStart:0,rangeEnd:0};var s=r.byteRangeStartOffset;var a=r.byteRangeEndOffset;if(Object(e["isFiniteNumber"])(s)&&Object(e["isFiniteNumber"])(a)){n.rangeStart=s;n.rangeEnd=a}return n}var m=function(t){s(i,t);function i(i){var r;for(var e=arguments.length,n=new Array(e>1?e-1:0),s=1;s<e;s++){n[s-1]=arguments[s]}r=t.call.apply(t,[this].concat(n))||this;r.data=void 0;r.data=i;return r}return i}(a(Error))},"./src/loader/fragment.ts":
|
|
202
|
+
/*!********************************!*\
|
|
203
|
+
!*** ./src/loader/fragment.ts ***!
|
|
204
|
+
\********************************/
|
|
205
|
+
/*! exports provided: ElementaryStreamTypes, BaseSegment, Fragment, Part */function(t,i,r){r.r(i);r.d(i,"ElementaryStreamTypes",(function(){return c}));r.d(i,"BaseSegment",(function(){return v}));r.d(i,"Fragment",(function(){return d}));r.d(i,"Part",(function(){return m}));var e=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");var n=r(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js");var s=r(/*! ../utils/logger */"./src/utils/logger.ts");var a=r(/*! ./level-key */"./src/loader/level-key.ts");var u=r(/*! ./load-stats */"./src/loader/load-stats.ts");function o(t,i){t.prototype=Object.create(i.prototype);t.prototype.constructor=t;f(t,i)}function f(t,i){f=Object.setPrototypeOf||function t(i,r){i.__proto__=r;return i};return f(t,i)}function h(t,i){for(var r=0;r<i.length;r++){var e=i[r];e.enumerable=e.enumerable||false;e.configurable=true;if("value"in e)e.writable=true;Object.defineProperty(t,e.key,e)}}function l(t,i,r){if(i)h(t.prototype,i);if(r)h(t,r);return t}var c;(function(t){t["AUDIO"]="audio";t["VIDEO"]="video";t["AUDIOVIDEO"]="audiovideo"})(c||(c={}));var v=function(){function t(t){var i;this._byteRange=null;this._url=null;this.baseurl=void 0;this.relurl=void 0;this.elementaryStreams=(i={},i[c.AUDIO]=null,i[c.VIDEO]=null,i[c.AUDIOVIDEO]=null,i);this.baseurl=t}var i=t.prototype;i.setByteRange=function t(i,r){var e=i.split("@",2);var n=[];if(e.length===1){n[0]=r?r.byteRangeEndOffset:0}else{n[0]=parseInt(e[1])}n[1]=parseInt(e[0])+n[0];this._byteRange=n};l(t,[{key:"byteRange",get:function t(){if(!this._byteRange){return[]}return this._byteRange}},{key:"byteRangeStartOffset",get:function t(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function t(){return this.byteRange[1]}},{key:"url",get:function t(){if(!this._url&&this.baseurl&&this.relurl){this._url=Object(n["buildAbsoluteURL"])(this.baseurl,this.relurl,{alwaysNormalize:true})}return this._url||""},set:function t(i){this._url=i}}]);return t}();var d=function(t){o(i,t);function i(i,r){var e;e=t.call(this,r)||this;e._decryptdata=null;e.rawProgramDateTime=null;e.programDateTime=null;e.tagList=[];e.duration=0;e.sn=0;e.levelkey=void 0;e.type=void 0;e.loader=null;e.level=-1;e.cc=0;e.startPTS=void 0;e.endPTS=void 0;e.appendedPTS=void 0;e.startDTS=void 0;e.endDTS=void 0;e.start=0;e.deltaPTS=void 0;e.maxStartPTS=void 0;e.minEndPTS=void 0;e.stats=new u["LoadStats"];e.urlId=0;e.data=void 0;e.bitrateTest=false;e.title=null;e.initSegment=null;e.type=i;return e}var r=i.prototype;r.createInitializationVector=function t(i){var r=new Uint8Array(16);for(var e=12;e<16;e++){r[e]=i>>8*(15-e)&255}return r};r.setDecryptDataFromLevelKey=function t(i,r){var e=i;if((i===null||i===void 0?void 0:i.method)==="AES-128"&&i.uri&&!i.iv){e=a["LevelKey"].fromURI(i.uri);e.method=i.method;e.iv=this.createInitializationVector(r);e.keyFormat="identity"}return e};r.setElementaryStreamInfo=function t(i,r,e,n,s,a){if(a===void 0){a=false}var u=this.elementaryStreams;var o=u[i];if(!o){u[i]={startPTS:r,endPTS:e,startDTS:n,endDTS:s,partial:a};return}o.startPTS=Math.min(o.startPTS,r);o.endPTS=Math.max(o.endPTS,e);o.startDTS=Math.min(o.startDTS,n);o.endDTS=Math.max(o.endDTS,s)};r.clearElementaryStreamInfo=function t(){var i=this.elementaryStreams;i[c.AUDIO]=null;i[c.VIDEO]=null;i[c.AUDIOVIDEO]=null};l(i,[{key:"decryptdata",get:function t(){if(!this.levelkey&&!this._decryptdata){return null}if(!this._decryptdata&&this.levelkey){var i=this.sn;if(typeof i!=="number"){if(this.levelkey&&this.levelkey.method==="AES-128"&&!this.levelkey.iv){s["logger"].warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue')}i=0}this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,i)}return this._decryptdata}},{key:"end",get:function t(){return this.start+this.duration}},{key:"endProgramDateTime",get:function t(){if(this.programDateTime===null){return null}if(!Object(e["isFiniteNumber"])(this.programDateTime)){return null}var i=!Object(e["isFiniteNumber"])(this.duration)?0:this.duration;return this.programDateTime+i*1e3}},{key:"encrypted",get:function t(){var i;if((i=this.decryptdata)!==null&&i!==void 0&&i.keyFormat&&this.decryptdata.uri){return true}return false}}]);return i}(v);var m=function(t){o(i,t);function i(i,r,e,n,s){var a;a=t.call(this,e)||this;a.fragOffset=0;a.duration=0;a.gap=false;a.independent=false;a.relurl=void 0;a.fragment=void 0;a.index=void 0;a.stats=new u["LoadStats"];a.duration=i.decimalFloatingPoint("DURATION");a.gap=i.bool("GAP");a.independent=i.bool("INDEPENDENT");a.relurl=i.enumeratedString("URI");a.fragment=r;a.index=n;var o=i.enumeratedString("BYTERANGE");if(o){a.setByteRange(o,s)}if(s){a.fragOffset=s.fragOffset+s.duration}return a}l(i,[{key:"start",get:function t(){return this.fragment.start+this.fragOffset}},{key:"end",get:function t(){return this.start+this.duration}},{key:"loaded",get:function t(){var i=this.elementaryStreams;return!!(i.audio||i.video||i.audiovideo)}}]);return i}(v)},"./src/loader/key-loader.ts":
|
|
206
|
+
/*!**********************************!*\
|
|
207
|
+
!*** ./src/loader/key-loader.ts ***!
|
|
208
|
+
\**********************************/
|
|
209
|
+
/*! exports provided: default */function(t,i,r){r.r(i);r.d(i,"default",(function(){return a}));var e=r(/*! ../events */"./src/events.ts");var n=r(/*! ../errors */"./src/errors.ts");var s=r(/*! ../utils/logger */"./src/utils/logger.ts");var a=function(){function t(t){this.hls=void 0;this.loaders={};this.decryptkey=null;this.decrypturl=null;this.hls=t;this._registerListeners()}var i=t.prototype;i._registerListeners=function t(){this.hls.on(e["Events"].KEY_LOADING,this.onKeyLoading,this)};i._unregisterListeners=function t(){this.hls.off(e["Events"].KEY_LOADING,this.onKeyLoading)};i.destroy=function t(){this._unregisterListeners();for(var i in this.loaders){var r=this.loaders[i];if(r){r.destroy()}}this.loaders={}};i.onKeyLoading=function t(i,r){var n=r.frag;var a=n.type;var u=this.loaders[a];if(!n.decryptdata){s["logger"].warn("Missing decryption data on fragment in onKeyLoading");return}var o=n.decryptdata.uri;if(o!==this.decrypturl||this.decryptkey===null){var f=this.hls.config;if(u){s["logger"].warn("abort previous key loader for type:"+a);u.abort()}if(!o){s["logger"].warn("key uri is falsy");return}var h=f.loader;var l=n.loader=this.loaders[a]=new h(f);this.decrypturl=o;this.decryptkey=null;var c={url:o,frag:n,responseType:"arraybuffer"};var v={timeout:f.fragLoadingTimeOut,maxRetry:0,retryDelay:f.fragLoadingRetryDelay,maxRetryDelay:f.fragLoadingMaxRetryTimeout,highWaterMark:0};var d={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};l.load(c,v,d)}else if(this.decryptkey){n.decryptdata.key=this.decryptkey;this.hls.trigger(e["Events"].KEY_LOADED,{frag:n})}};i.loadsuccess=function t(i,r,n){var a=n.frag;if(!a.decryptdata){s["logger"].error("after key load, decryptdata unset");return}this.decryptkey=a.decryptdata.key=new Uint8Array(i.data);a.loader=null;delete this.loaders[a.type];this.hls.trigger(e["Events"].KEY_LOADED,{frag:a})};i.loaderror=function t(i,r){var s=r.frag;var a=s.loader;if(a){a.abort()}delete this.loaders[s.type];this.hls.trigger(e["Events"].ERROR,{type:n["ErrorTypes"].NETWORK_ERROR,details:n["ErrorDetails"].KEY_LOAD_ERROR,fatal:false,frag:s,response:i})};i.loadtimeout=function t(i,r){var s=r.frag;var a=s.loader;if(a){a.abort()}delete this.loaders[s.type];this.hls.trigger(e["Events"].ERROR,{type:n["ErrorTypes"].NETWORK_ERROR,details:n["ErrorDetails"].KEY_LOAD_TIMEOUT,fatal:false,frag:s})};return t}()},"./src/loader/level-details.ts":
|
|
210
|
+
/*!*************************************!*\
|
|
211
|
+
!*** ./src/loader/level-details.ts ***!
|
|
212
|
+
\*************************************/
|
|
213
|
+
/*! exports provided: LevelDetails */function(t,i,r){r.r(i);r.d(i,"LevelDetails",(function(){return u}));var e=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");function n(t,i){for(var r=0;r<i.length;r++){var e=i[r];e.enumerable=e.enumerable||false;e.configurable=true;if("value"in e)e.writable=true;Object.defineProperty(t,e.key,e)}}function s(t,i,r){if(i)n(t.prototype,i);if(r)n(t,r);return t}var a=10;var u=function(){function t(t){this.PTSKnown=false;this.alignedSliding=false;this.averagetargetduration=void 0;this.endCC=0;this.endSN=0;this.fragments=void 0;this.fragmentHint=void 0;this.partList=null;this.live=true;this.ageHeader=0;this.advancedDateTime=void 0;this.updated=true;this.advanced=true;this.availabilityDelay=void 0;this.misses=0;this.needSidxRanges=false;this.startCC=0;this.startSN=0;this.startTimeOffset=null;this.targetduration=0;this.totalduration=0;this.type=null;this.url=void 0;this.m3u8="";this.version=null;this.canBlockReload=false;this.canSkipUntil=0;this.canSkipDateRanges=false;this.skippedSegments=0;this.recentlyRemovedDateranges=void 0;this.partHoldBack=0;this.holdBack=0;this.partTarget=0;this.preloadHint=void 0;this.renditionReports=void 0;this.tuneInGoal=0;this.deltaUpdateFailed=void 0;this.driftStartTime=0;this.driftEndTime=0;this.driftStart=0;this.driftEnd=0;this.fragments=[];this.url=t}var i=t.prototype;i.reloaded=function t(i){if(!i){this.advanced=true;this.updated=true;return}var r=this.lastPartSn-i.lastPartSn;var e=this.lastPartIndex-i.lastPartIndex;this.updated=this.endSN!==i.endSN||!!e||!!r;this.advanced=this.endSN>i.endSN||r>0||r===0&&e>0;if(this.updated||this.advanced){this.misses=Math.floor(i.misses*.6)}else{this.misses=i.misses+1}this.availabilityDelay=i.availabilityDelay};s(t,[{key:"hasProgramDateTime",get:function t(){if(this.fragments.length){return Object(e["isFiniteNumber"])(this.fragments[this.fragments.length-1].programDateTime)}return false}},{key:"levelTargetDuration",get:function t(){return this.averagetargetduration||this.targetduration||a}},{key:"drift",get:function t(){var i=this.driftEndTime-this.driftStartTime;if(i>0){var r=this.driftEnd-this.driftStart;return r*1e3/i}return 1}},{key:"edge",get:function t(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function t(){var i;if((i=this.partList)!==null&&i!==void 0&&i.length){return this.partList[this.partList.length-1].end}return this.fragmentEnd}},{key:"fragmentEnd",get:function t(){var i;if((i=this.fragments)!==null&&i!==void 0&&i.length){return this.fragments[this.fragments.length-1].end}return 0}},{key:"age",get:function t(){if(this.advancedDateTime){return Math.max(Date.now()-this.advancedDateTime,0)/1e3}return 0}},{key:"lastPartIndex",get:function t(){var i;if((i=this.partList)!==null&&i!==void 0&&i.length){return this.partList[this.partList.length-1].index}return-1}},{key:"lastPartSn",get:function t(){var i;if((i=this.partList)!==null&&i!==void 0&&i.length){return this.partList[this.partList.length-1].fragment.sn}return this.endSN}}]);return t}()},"./src/loader/level-key.ts":
|
|
214
|
+
/*!*********************************!*\
|
|
215
|
+
!*** ./src/loader/level-key.ts ***!
|
|
216
|
+
\*********************************/
|
|
217
|
+
/*! exports provided: LevelKey */function(t,i,r){r.r(i);r.d(i,"LevelKey",(function(){return a}));var e=r(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js");function n(t,i){for(var r=0;r<i.length;r++){var e=i[r];e.enumerable=e.enumerable||false;e.configurable=true;if("value"in e)e.writable=true;Object.defineProperty(t,e.key,e)}}function s(t,i,r){if(i)n(t.prototype,i);if(r)n(t,r);return t}var a=function(){t.fromURL=function i(r,e){return new t(r,e)};t.fromURI=function i(r){return new t(r)};function t(t,i){this._uri=null;this.method=null;this.keyFormat=null;this.keyFormatVersions=null;this.keyID=null;this.key=null;this.iv=null;if(i){this._uri=Object(e["buildAbsoluteURL"])(t,i,{alwaysNormalize:true})}else{this._uri=t}}s(t,[{key:"uri",get:function t(){return this._uri}}]);return t}()},"./src/loader/load-stats.ts":
|
|
218
|
+
/*!**********************************!*\
|
|
219
|
+
!*** ./src/loader/load-stats.ts ***!
|
|
220
|
+
\**********************************/
|
|
221
|
+
/*! exports provided: LoadStats */function(t,i,r){r.r(i);r.d(i,"LoadStats",(function(){return e}));var e=function t(){this.aborted=false;this.loaded=0;this.retry=0;this.total=0;this.chunkCount=0;this.bwEstimate=0;this.loading={start:0,first:0,end:0};this.parsing={start:0,end:0};this.buffering={start:0,first:0,end:0}}},"./src/loader/m3u8-parser.ts":
|
|
222
|
+
/*!***********************************!*\
|
|
223
|
+
!*** ./src/loader/m3u8-parser.ts ***!
|
|
224
|
+
\***********************************/
|
|
225
|
+
/*! exports provided: default */function(t,i,r){r.r(i);r.d(i,"default",(function(){return g}));var e=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");var n=r(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js");var s=r(/*! ./fragment */"./src/loader/fragment.ts");var a=r(/*! ./level-details */"./src/loader/level-details.ts");var u=r(/*! ./level-key */"./src/loader/level-key.ts");var o=r(/*! ../utils/attr-list */"./src/utils/attr-list.ts");var f=r(/*! ../utils/logger */"./src/utils/logger.ts");var h=r(/*! ../utils/codecs */"./src/utils/codecs.ts");var l=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+/g;var c=/#EXT-X-MEDIA:(.*)/g;var v=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g");var d=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(PLAYLIST-TYPE):(.+)/.source,/#EXT-X-(MEDIA-SEQUENCE): *(\d+)/.source,/#EXT-X-(SKIP):(.+)/.source,/#EXT-X-(TARGETDURATION): *(\d+)/.source,/#EXT-X-(KEY):(.+)/.source,/#EXT-X-(START):(.+)/.source,/#EXT-X-(ENDLIST)/.source,/#EXT-X-(DISCONTINUITY-SEQ)UENCE: *(\d+)/.source,/#EXT-X-(DIS)CONTINUITY/.source,/#EXT-X-(VERSION):(\d+)/.source,/#EXT-X-(MAP):(.+)/.source,/#EXT-X-(SERVER-CONTROL):(.+)/.source,/#EXT-X-(PART-INF):(.+)/.source,/#EXT-X-(GAP)/.source,/#EXT-X-(BITRATE):\s*(\d+)/.source,/#EXT-X-(PART):(.+)/.source,/#EXT-X-(PRELOAD-HINT):(.+)/.source,/#EXT-X-(RENDITION-REPORT):(.+)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|"));var m=/\.(mp4|m4s|m4v|m4a)$/i;function p(t){var i,r;return m.test((i=(r=n["parseURL"](t))===null||r===void 0?void 0:r.path)!=null?i:"")}var g=function(){function t(){}t.findGroup=function t(i,r){for(var e=0;e<i.length;e++){var n=i[e];if(n.id===r){return n}}};t.convertAVC1ToAVCOTI=function t(i){var r=i.split(".");if(r.length>2){var e=r.shift()+".";e+=parseInt(r.shift()).toString(16);e+=("000"+parseInt(r.shift()).toString(16)).substr(-4);return e}return i};t.resolve=function t(i,r){return n["buildAbsoluteURL"](r,i,{alwaysNormalize:true})};t.parseMasterPlaylist=function i(r,e){var n=[];var s={};var a=false;l.lastIndex=0;var u;while((u=l.exec(r))!=null){if(u[1]){var f=new o["AttrList"](u[1]);var h={attrs:f,bitrate:f.decimalInteger("AVERAGE-BANDWIDTH")||f.decimalInteger("BANDWIDTH"),name:f.NAME,url:t.resolve(u[2],e)};var c=f.decimalResolution("RESOLUTION");if(c){h.width=c.width;h.height=c.height}b((f.CODECS||"").split(/[ ,]+/).filter((function(t){return t})),h);if(h.videoCodec&&h.videoCodec.indexOf("avc1")!==-1){h.videoCodec=t.convertAVC1ToAVCOTI(h.videoCodec)}n.push(h)}else if(u[3]){var v=new o["AttrList"](u[3]);if(v["DATA-ID"]){a=true;s[v["DATA-ID"]]=v}}}return{levels:n,sessionData:a?s:null}};t.parseMasterPlaylistMedia=function i(r,e,n,s){if(s===void 0){s=[]}var a;var u=[];var f=0;c.lastIndex=0;while((a=c.exec(r))!==null){var h=new o["AttrList"](a[1]);if(h.TYPE===n){var l={attrs:h,bitrate:0,id:f++,groupId:h["GROUP-ID"],instreamId:h["INSTREAM-ID"],name:h.NAME||h.LANGUAGE||"",type:n,default:h.bool("DEFAULT"),autoselect:h.bool("AUTOSELECT"),forced:h.bool("FORCED"),lang:h.LANGUAGE,url:h.URI?t.resolve(h.URI,e):""};if(s.length){var v=t.findGroup(s,l.groupId)||s[0];y(l,v,"audioCodec");y(l,v,"textCodec")}u.push(l)}}return u};t.parseLevelPlaylist=function t(i,r,n,h,l){var c=new a["LevelDetails"](r);var m=c.fragments;var g=null;var b=0;var y=0;var k=0;var T=0;var E=null;var O=new s["Fragment"](h,r);var S;var M;var x;var j=-1;var D=false;v.lastIndex=0;c.m3u8=i;while((S=v.exec(i))!==null){if(D){D=false;O=new s["Fragment"](h,r);O.start=k;O.sn=b;O.cc=T;O.level=n;if(g){O.initSegment=g;O.rawProgramDateTime=g.rawProgramDateTime}}var I=S[1];if(I){O.duration=parseFloat(I);var L=(" "+S[2]).slice(1);O.title=L||null;O.tagList.push(L?["INF",I,L]:["INF",I])}else if(S[3]){if(Object(e["isFiniteNumber"])(O.duration)){O.start=k;if(x){O.levelkey=x}O.sn=b;O.level=n;O.cc=T;O.urlId=l;m.push(O);O.relurl=(" "+S[3]).slice(1);A(O,E);E=O;k+=O.duration;b++;y=0;D=true}}else if(S[4]){var C=(" "+S[4]).slice(1);if(E){O.setByteRange(C,E)}else{O.setByteRange(C)}}else if(S[5]){O.rawProgramDateTime=(" "+S[5]).slice(1);O.tagList.push(["PROGRAM-DATE-TIME",O.rawProgramDateTime]);if(j===-1){j=m.length}}else{S=S[0].match(d);if(!S){f["logger"].warn("No matches on slow regex match for level playlist!");continue}for(M=1;M<S.length;M++){if(typeof S[M]!=="undefined"){break}}var R=(" "+S[M]).slice(1);var N=(" "+S[M+1]).slice(1);var U=S[M+2]?(" "+S[M+2]).slice(1):"";switch(R){case"PLAYLIST-TYPE":c.type=N.toUpperCase();break;case"MEDIA-SEQUENCE":b=c.startSN=parseInt(N);break;case"SKIP":{var P=new o["AttrList"](N);var F=P.decimalInteger("SKIPPED-SEGMENTS");if(Object(e["isFiniteNumber"])(F)){c.skippedSegments=F;for(var B=F;B--;){m.unshift(null)}b+=F}var G=P.enumeratedString("RECENTLY-REMOVED-DATERANGES");if(G){c.recentlyRemovedDateranges=G.split("\t")}break}case"TARGETDURATION":c.targetduration=parseFloat(N);break;case"VERSION":c.version=parseInt(N);break;case"EXTM3U":break;case"ENDLIST":c.live=false;break;case"#":if(N||U){O.tagList.push(U?[N,U]:[N])}break;case"DIS":T++;case"GAP":O.tagList.push([R]);break;case"BITRATE":O.tagList.push([R,N]);break;case"DISCONTINUITY-SEQ":T=parseInt(N);break;case"KEY":{var W;var X=new o["AttrList"](N);var z=X.enumeratedString("METHOD");var Y=X.URI;var Z=X.hexadecimalInteger("IV");var V=X.enumeratedString("KEYFORMATVERSIONS");var Q=X.enumeratedString("KEYID");var H=(W=X.enumeratedString("KEYFORMAT"))!=null?W:"identity";var K=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(K.indexOf(H)>-1){f["logger"].warn("Keyformat "+H+" is not supported from the manifest");continue}else if(H!=="identity"){continue}if(z){x=u["LevelKey"].fromURL(r,Y);if(Y&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(z)>=0){x.method=z;x.keyFormat=H;if(Q){x.keyID=Q}if(V){x.keyFormatVersions=V}x.iv=Z}}break}case"START":{var J=new o["AttrList"](N);var q=J.decimalFloatingPoint("TIME-OFFSET");if(Object(e["isFiniteNumber"])(q)){c.startTimeOffset=q}break}case"MAP":{var _=new o["AttrList"](N);O.relurl=_.URI;if(_.BYTERANGE){O.setByteRange(_.BYTERANGE)}O.level=n;O.sn="initSegment";if(x){O.levelkey=x}O.initSegment=null;g=O;D=true;break}case"SERVER-CONTROL":{var $=new o["AttrList"](N);c.canBlockReload=$.bool("CAN-BLOCK-RELOAD");c.canSkipUntil=$.optionalFloat("CAN-SKIP-UNTIL",0);c.canSkipDateRanges=c.canSkipUntil>0&&$.bool("CAN-SKIP-DATERANGES");c.partHoldBack=$.optionalFloat("PART-HOLD-BACK",0);c.holdBack=$.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var tt=new o["AttrList"](N);c.partTarget=tt.decimalFloatingPoint("PART-TARGET");break}case"PART":{var it=c.partList;if(!it){it=c.partList=[]}var rt=y>0?it[it.length-1]:undefined;var et=y++;var nt=new s["Part"](new o["AttrList"](N),O,r,et,rt);it.push(nt);O.duration+=nt.duration;break}case"PRELOAD-HINT":{var st=new o["AttrList"](N);c.preloadHint=st;break}case"RENDITION-REPORT":{var at=new o["AttrList"](N);c.renditionReports=c.renditionReports||[];c.renditionReports.push(at);break}default:f["logger"].warn("line parsed but not handled: "+S);break}}}if(E&&!E.relurl){m.pop();k-=E.duration;if(c.partList){c.fragmentHint=E}}else if(c.partList){A(O,E);O.cc=T;c.fragmentHint=O}var ut=m.length;var ot=m[0];var ft=m[ut-1];k+=c.skippedSegments*c.targetduration;if(k>0&&ut&&ft){c.averagetargetduration=k/ut;var ht=ft.sn;c.endSN=ht!=="initSegment"?ht:0;if(ot){c.startCC=ot.cc;if(!ot.initSegment){if(c.fragments.every((function(t){return t.relurl&&p(t.relurl)}))){f["logger"].warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX");O=new s["Fragment"](h,r);O.relurl=ft.relurl;O.level=n;O.sn="initSegment";ot.initSegment=O;c.needSidxRanges=true}}}}else{c.endSN=0;c.startCC=0}if(c.fragmentHint){k+=c.fragmentHint.duration}c.totalduration=k;c.endCC=T;if(j>0){w(m,j)}return c};return t}();function b(t,i){["video","audio","text"].forEach((function(r){var e=t.filter((function(t){return Object(h["isCodecType"])(t,r)}));if(e.length){var n=e.filter((function(t){return t.lastIndexOf("avc1",0)===0||t.lastIndexOf("mp4a",0)===0}));i[r+"Codec"]=n.length>0?n[0]:e[0];t=t.filter((function(t){return e.indexOf(t)===-1}))}}));i.unknownCodecs=t}function y(t,i,r){var e=i[r];if(e){t[r]=e}}function w(t,i){var r=t[i];for(var e=i;e--;){var n=t[e];if(!n){return}n.programDateTime=r.programDateTime-n.duration*1e3;r=n}}function A(t,i){if(t.rawProgramDateTime){t.programDateTime=Date.parse(t.rawProgramDateTime)}else if(i!==null&&i!==void 0&&i.programDateTime){t.programDateTime=i.endProgramDateTime}if(!Object(e["isFiniteNumber"])(t.programDateTime)){t.programDateTime=null;t.rawProgramDateTime=null}}},"./src/loader/playlist-loader.ts":
|
|
226
|
+
/*!***************************************!*\
|
|
227
|
+
!*** ./src/loader/playlist-loader.ts ***!
|
|
228
|
+
\***************************************/
|
|
229
|
+
/*! exports provided: default */function(t,i,r){r.r(i);var e=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");var n=r(/*! ../events */"./src/events.ts");var s=r(/*! ../errors */"./src/errors.ts");var a=r(/*! ../utils/logger */"./src/utils/logger.ts");var u=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts");var o=r(/*! ./m3u8-parser */"./src/loader/m3u8-parser.ts");var f=r(/*! ../types/loader */"./src/types/loader.ts");var h=r(/*! ../utils/attr-list */"./src/utils/attr-list.ts");function l(t){var i=t.type;switch(i){case f["PlaylistContextType"].AUDIO_TRACK:return f["PlaylistLevelType"].AUDIO;case f["PlaylistContextType"].SUBTITLE_TRACK:return f["PlaylistLevelType"].SUBTITLE;default:return f["PlaylistLevelType"].MAIN}}function c(t,i){var r=t.url;if(r===undefined||r.indexOf("data:")===0){r=i.url}return r}var v=function(){function t(t){this.hls=void 0;this.loaders=Object.create(null);this.hls=t;this.registerListeners()}var i=t.prototype;i.registerListeners=function t(){var i=this.hls;i.on(n["Events"].MANIFEST_LOADING,this.onManifestLoading,this);i.on(n["Events"].LEVEL_LOADING,this.onLevelLoading,this);i.on(n["Events"].AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this);i.on(n["Events"].SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)};i.unregisterListeners=function t(){var i=this.hls;i.off(n["Events"].MANIFEST_LOADING,this.onManifestLoading,this);i.off(n["Events"].LEVEL_LOADING,this.onLevelLoading,this);i.off(n["Events"].AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this);i.off(n["Events"].SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)};i.createInternalLoader=function t(i){var r=this.hls.config;var e=r.pLoader;var n=r.loader;var s=e||n;var a=new s(r);i.loader=a;this.loaders[i.type]=a;return a};i.getInternalLoader=function t(i){return this.loaders[i.type]};i.resetInternalLoader=function t(i){if(this.loaders[i]){delete this.loaders[i]}};i.destroyInternalLoaders=function t(){for(var i in this.loaders){var r=this.loaders[i];if(r){r.destroy()}this.resetInternalLoader(i)}};i.destroy=function t(){this.unregisterListeners();this.destroyInternalLoaders()};i.onManifestLoading=function t(i,r){var e=r.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:f["PlaylistContextType"].MANIFEST,url:e,deliveryDirectives:null})};i.onLevelLoading=function t(i,r){var e=r.id,n=r.level,s=r.url,a=r.deliveryDirectives;this.load({id:e,groupId:null,level:n,responseType:"text",type:f["PlaylistContextType"].LEVEL,url:s,deliveryDirectives:a})};i.onAudioTrackLoading=function t(i,r){var e=r.id,n=r.groupId,s=r.url,a=r.deliveryDirectives;this.load({id:e,groupId:n,level:null,responseType:"text",type:f["PlaylistContextType"].AUDIO_TRACK,url:s,deliveryDirectives:a})};i.onSubtitleTrackLoading=function t(i,r){var e=r.id,n=r.groupId,s=r.url,a=r.deliveryDirectives;this.load({id:e,groupId:n,level:null,responseType:"text",type:f["PlaylistContextType"].SUBTITLE_TRACK,url:s,deliveryDirectives:a})};i.load=function t(i){var r;var e=this.hls.config;var n=this.getInternalLoader(i);if(n){var s=n.context;if(s&&s.url===i.url){a["logger"].trace("[playlist-loader]: playlist request ongoing");return}a["logger"].log("[playlist-loader]: aborting previous loader for type: "+i.type);n.abort()}var u;var o;var h;var l;switch(i.type){case f["PlaylistContextType"].MANIFEST:u=e.manifestLoadingMaxRetry;o=e.manifestLoadingTimeOut;h=e.manifestLoadingRetryDelay;l=e.manifestLoadingMaxRetryTimeout;break;case f["PlaylistContextType"].LEVEL:case f["PlaylistContextType"].AUDIO_TRACK:case f["PlaylistContextType"].SUBTITLE_TRACK:u=0;o=e.levelLoadingTimeOut;break;default:u=e.levelLoadingMaxRetry;o=e.levelLoadingTimeOut;h=e.levelLoadingRetryDelay;l=e.levelLoadingMaxRetryTimeout;break}n=this.createInternalLoader(i);if((r=i.deliveryDirectives)!==null&&r!==void 0&&r.part){var c;if(i.type===f["PlaylistContextType"].LEVEL&&i.level!==null){c=this.hls.levels[i.level].details}else if(i.type===f["PlaylistContextType"].AUDIO_TRACK&&i.id!==null){c=this.hls.audioTracks[i.id].details}else if(i.type===f["PlaylistContextType"].SUBTITLE_TRACK&&i.id!==null){c=this.hls.subtitleTracks[i.id].details}if(c){var v=c.partTarget;var d=c.targetduration;if(v&&d){o=Math.min(Math.max(v*3,d*.8)*1e3,o)}}}var m={timeout:o,maxRetry:u,retryDelay:h,maxRetryDelay:l,highWaterMark:0};var p={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};n.load(i,m,p)};i.loadsuccess=function t(i,r,e,n){if(n===void 0){n=null}if(e.isSidxRequest){this.handleSidxRequest(i,e);this.handlePlaylistLoaded(i,r,e,n);return}this.resetInternalLoader(e.type);var s=i.data;if(s.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(i,e,"no EXTM3U delimiter",n);return}r.parsing.start=performance.now();if(s.indexOf("#EXTINF:")>0||s.indexOf("#EXT-X-TARGETDURATION:")>0){this.handleTrackOrLevelPlaylist(i,r,e,n)}else{this.handleMasterPlaylist(i,r,e,n)}};i.loaderror=function t(i,r,e){if(e===void 0){e=null}this.handleNetworkError(r,e,false,i)};i.loadtimeout=function t(i,r,e){if(e===void 0){e=null}this.handleNetworkError(r,e,true)};i.handleMasterPlaylist=function t(i,r,e,s){var u=this.hls;var f=i.data;var l=c(i,e);var v=o["default"].parseMasterPlaylist(f,l),d=v.levels,m=v.sessionData;if(!d.length){this.handleManifestParsingError(i,e,"no level found in manifest",s);return}var p=d.map((function(t){return{id:t.attrs.AUDIO,audioCodec:t.audioCodec}}));var g=d.map((function(t){return{id:t.attrs.SUBTITLES,textCodec:t.textCodec}}));var b=o["default"].parseMasterPlaylistMedia(f,l,"AUDIO",p);var y=o["default"].parseMasterPlaylistMedia(f,l,"SUBTITLES",g);var w=o["default"].parseMasterPlaylistMedia(f,l,"CLOSED-CAPTIONS");if(b.length){var A=b.some((function(t){return!t.url}));if(!A&&d[0].audioCodec&&!d[0].attrs.AUDIO){a["logger"].log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one");b.unshift({type:"main",name:"main",default:false,autoselect:false,forced:false,id:-1,attrs:new h["AttrList"]({}),bitrate:0,url:""})}}u.trigger(n["Events"].MANIFEST_LOADED,{levels:d,audioTracks:b,subtitles:y,captions:w,url:l,stats:r,networkDetails:s,sessionData:m})};i.handleTrackOrLevelPlaylist=function t(i,r,a,u){var v=this.hls;var d=a.id,m=a.level,p=a.type;var g=c(i,a);var b=Object(e["isFiniteNumber"])(d)?d:0;var y=Object(e["isFiniteNumber"])(m)?m:b;var w=l(a);var A=o["default"].parseLevelPlaylist(i.data,g,y,w,b);if(!A.fragments.length){v.trigger(n["Events"].ERROR,{type:s["ErrorTypes"].NETWORK_ERROR,details:s["ErrorDetails"].LEVEL_EMPTY_ERROR,fatal:false,url:g,reason:"no fragments found in level",level:typeof a.level==="number"?a.level:undefined});return}if(p===f["PlaylistContextType"].MANIFEST){var k={attrs:new h["AttrList"]({}),bitrate:0,details:A,name:"",url:g};v.trigger(n["Events"].MANIFEST_LOADED,{levels:[k],audioTracks:[],url:g,stats:r,networkDetails:u,sessionData:null})}r.parsing.end=performance.now();if(A.needSidxRanges){var T;var E=(T=A.fragments[0].initSegment)===null||T===void 0?void 0:T.url;this.load({url:E,isSidxRequest:true,type:p,level:m,levelDetails:A,id:d,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}a.levelDetails=A;this.handlePlaylistLoaded(i,r,a,u)};i.handleSidxRequest=function t(i,r){var e=Object(u["parseSegmentIndex"])(new Uint8Array(i.data));if(!e){return}var n=e.references;var s=r.levelDetails;n.forEach((function(t,i){var r=t.info;var n=s.fragments[i];if(n.byteRange.length===0){n.setByteRange(String(1+r.end-r.start)+"@"+String(r.start))}if(n.initSegment){n.initSegment.setByteRange(String(e.moovEndOffset)+"@0")}}))};i.handleManifestParsingError=function t(i,r,e,a){this.hls.trigger(n["Events"].ERROR,{type:s["ErrorTypes"].NETWORK_ERROR,details:s["ErrorDetails"].MANIFEST_PARSING_ERROR,fatal:r.type===f["PlaylistContextType"].MANIFEST,url:i.url,reason:e,response:i,context:r,networkDetails:a})};i.handleNetworkError=function t(i,r,e,u){if(e===void 0){e=false}a["logger"].warn("[playlist-loader]: A network "+(e?"timeout":"error")+" occurred while loading "+i.type+" level: "+i.level+" id: "+i.id+' group-id: "'+i.groupId+'"');var o=s["ErrorDetails"].UNKNOWN;var h=false;var l=this.getInternalLoader(i);switch(i.type){case f["PlaylistContextType"].MANIFEST:o=e?s["ErrorDetails"].MANIFEST_LOAD_TIMEOUT:s["ErrorDetails"].MANIFEST_LOAD_ERROR;h=true;break;case f["PlaylistContextType"].LEVEL:o=e?s["ErrorDetails"].LEVEL_LOAD_TIMEOUT:s["ErrorDetails"].LEVEL_LOAD_ERROR;h=false;break;case f["PlaylistContextType"].AUDIO_TRACK:o=e?s["ErrorDetails"].AUDIO_TRACK_LOAD_TIMEOUT:s["ErrorDetails"].AUDIO_TRACK_LOAD_ERROR;h=false;break;case f["PlaylistContextType"].SUBTITLE_TRACK:o=e?s["ErrorDetails"].SUBTITLE_TRACK_LOAD_TIMEOUT:s["ErrorDetails"].SUBTITLE_LOAD_ERROR;h=false;break}if(l){this.resetInternalLoader(i.type)}var c={type:s["ErrorTypes"].NETWORK_ERROR,details:o,fatal:h,url:i.url,loader:l,context:i,networkDetails:r};if(u){c.response=u}this.hls.trigger(n["Events"].ERROR,c)};i.handlePlaylistLoaded=function t(i,r,e,s){var a=e.type,u=e.level,o=e.id,h=e.groupId,l=e.loader,c=e.levelDetails,v=e.deliveryDirectives;if(!(c!==null&&c!==void 0&&c.targetduration)){this.handleManifestParsingError(i,e,"invalid target duration",s);return}if(!l){return}if(c.live){if(l.getCacheAge){c.ageHeader=l.getCacheAge()||0}if(!l.getCacheAge||isNaN(c.ageHeader)){c.ageHeader=0}}switch(a){case f["PlaylistContextType"].MANIFEST:case f["PlaylistContextType"].LEVEL:this.hls.trigger(n["Events"].LEVEL_LOADED,{details:c,level:u||0,id:o||0,stats:r,networkDetails:s,deliveryDirectives:v});break;case f["PlaylistContextType"].AUDIO_TRACK:this.hls.trigger(n["Events"].AUDIO_TRACK_LOADED,{details:c,id:o||0,groupId:h||"",stats:r,networkDetails:s,deliveryDirectives:v});break;case f["PlaylistContextType"].SUBTITLE_TRACK:this.hls.trigger(n["Events"].SUBTITLE_TRACK_LOADED,{details:c,id:o||0,groupId:h||"",stats:r,networkDetails:s,deliveryDirectives:v});break}};return t}();i["default"]=v},"./src/polyfills/number.ts":
|
|
230
|
+
/*!*********************************!*\
|
|
231
|
+
!*** ./src/polyfills/number.ts ***!
|
|
232
|
+
\*********************************/
|
|
233
|
+
/*! exports provided: isFiniteNumber, MAX_SAFE_INTEGER */function(t,i,r){r.r(i);r.d(i,"isFiniteNumber",(function(){return e}));r.d(i,"MAX_SAFE_INTEGER",(function(){return n}));var e=Number.isFinite||function(t){return typeof t==="number"&&isFinite(t)};var n=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":
|
|
234
|
+
/*!*********************************!*\
|
|
235
|
+
!*** ./src/remux/aac-helper.ts ***!
|
|
236
|
+
\*********************************/
|
|
237
|
+
/*! exports provided: default */function(t,i,r){r.r(i);var e=function(){function t(){}t.getSilentFrame=function t(i,r){switch(i){case"mp4a.40.2":if(r===1){return new Uint8Array([0,200,0,128,35,128])}else if(r===2){return new Uint8Array([33,0,73,144,2,25,0,35,128])}else if(r===3){return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142])}else if(r===4){return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56])}else if(r===5){return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56])}else if(r===6){return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}break;default:if(r===1){return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}else if(r===2){return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}else if(r===3){return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}break}return undefined};return t}();i["default"]=e},"./src/remux/mp4-generator.ts":
|
|
238
|
+
/*!************************************!*\
|
|
239
|
+
!*** ./src/remux/mp4-generator.ts ***!
|
|
240
|
+
\************************************/
|
|
241
|
+
/*! exports provided: default */function(t,i,r){r.r(i);var e=Math.pow(2,32)-1;var n=function(){function t(){}t.init=function i(){t.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};var r;for(r in t.types){if(t.types.hasOwnProperty(r)){t.types[r]=[r.charCodeAt(0),r.charCodeAt(1),r.charCodeAt(2),r.charCodeAt(3)]}}var e=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]);var n=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);t.HDLR_TYPES={video:e,audio:n};var s=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]);var a=new Uint8Array([0,0,0,0,0,0,0,0]);t.STTS=t.STSC=t.STCO=a;t.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]);t.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]);t.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]);t.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var u=new Uint8Array([105,115,111,109]);var o=new Uint8Array([97,118,99,49]);var f=new Uint8Array([0,0,0,1]);t.FTYP=t.box(t.types.ftyp,u,f,u,o);t.DINF=t.box(t.types.dinf,t.box(t.types.dref,s))};t.box=function t(i){var r=8;for(var e=arguments.length,n=new Array(e>1?e-1:0),s=1;s<e;s++){n[s-1]=arguments[s]}var a=n.length;var u=a;while(a--){r+=n[a].byteLength}var o=new Uint8Array(r);o[0]=r>>24&255;o[1]=r>>16&255;o[2]=r>>8&255;o[3]=r&255;o.set(i,4);for(a=0,r=8;a<u;a++){o.set(n[a],r);r+=n[a].byteLength}return o};t.hdlr=function i(r){return t.box(t.types.hdlr,t.HDLR_TYPES[r])};t.mdat=function i(r){return t.box(t.types.mdat,r)};t.mdhd=function i(r,n){n*=r;var s=Math.floor(n/(e+1));var a=Math.floor(n%(e+1));return t.box(t.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,r>>24&255,r>>16&255,r>>8&255,r&255,s>>24,s>>16&255,s>>8&255,s&255,a>>24,a>>16&255,a>>8&255,a&255,85,196,0,0]))};t.mdia=function i(r){return t.box(t.types.mdia,t.mdhd(r.timescale,r.duration),t.hdlr(r.type),t.minf(r))};t.mfhd=function i(r){return t.box(t.types.mfhd,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,r&255]))};t.minf=function i(r){if(r.type==="audio"){return t.box(t.types.minf,t.box(t.types.smhd,t.SMHD),t.DINF,t.stbl(r))}else{return t.box(t.types.minf,t.box(t.types.vmhd,t.VMHD),t.DINF,t.stbl(r))}};t.moof=function i(r,e,n){return t.box(t.types.moof,t.mfhd(r),t.traf(n,e))};t.moov=function i(r){var e=r.length;var n=[];while(e--){n[e]=t.trak(r[e])}return t.box.apply(null,[t.types.moov,t.mvhd(r[0].timescale,r[0].duration)].concat(n).concat(t.mvex(r)))};t.mvex=function i(r){var e=r.length;var n=[];while(e--){n[e]=t.trex(r[e])}return t.box.apply(null,[t.types.mvex].concat(n))};t.mvhd=function i(r,n){n*=r;var s=Math.floor(n/(e+1));var a=Math.floor(n%(e+1));var u=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,r>>24&255,r>>16&255,r>>8&255,r&255,s>>24,s>>16&255,s>>8&255,s&255,a>>24,a>>16&255,a>>8&255,a&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return t.box(t.types.mvhd,u)};t.sdtp=function i(r){var e=r.samples||[];var n=new Uint8Array(4+e.length);var s;var a;for(s=0;s<e.length;s++){a=e[s].flags;n[s+4]=a.dependsOn<<4|a.isDependedOn<<2|a.hasRedundancy}return t.box(t.types.sdtp,n)};t.stbl=function i(r){return t.box(t.types.stbl,t.stsd(r),t.box(t.types.stts,t.STTS),t.box(t.types.stsc,t.STSC),t.box(t.types.stsz,t.STSZ),t.box(t.types.stco,t.STCO))};t.avc1=function i(r){var e=[];var n=[];var s;var a;var u;for(s=0;s<r.sps.length;s++){a=r.sps[s];u=a.byteLength;e.push(u>>>8&255);e.push(u&255);e=e.concat(Array.prototype.slice.call(a))}for(s=0;s<r.pps.length;s++){a=r.pps[s];u=a.byteLength;n.push(u>>>8&255);n.push(u&255);n=n.concat(Array.prototype.slice.call(a))}var o=t.box(t.types.avcC,new Uint8Array([1,e[3],e[4],e[5],252|3,224|r.sps.length].concat(e).concat([r.pps.length]).concat(n)));var f=r.width;var h=r.height;var l=r.pixelRatio[0];var c=r.pixelRatio[1];return t.box(t.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,f>>8&255,f&255,h>>8&255,h&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,t.box(t.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),t.box(t.types.pasp,new Uint8Array([l>>24,l>>16&255,l>>8&255,l&255,c>>24,c>>16&255,c>>8&255,c&255])))};t.esds=function t(i){var r=i.config.length;return new Uint8Array([0,0,0,0,3,23+r,0,1,0,4,15+r,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([r]).concat(i.config).concat([6,1,2]))};t.mp4a=function i(r){var e=r.samplerate;return t.box(t.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,r.channelCount,0,16,0,0,0,0,e>>8&255,e&255,0,0]),t.box(t.types.esds,t.esds(r)))};t.mp3=function i(r){var e=r.samplerate;return t.box(t.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,r.channelCount,0,16,0,0,0,0,e>>8&255,e&255,0,0]))};t.stsd=function i(r){if(r.type==="audio"){if(!r.isAAC&&r.codec==="mp3"){return t.box(t.types.stsd,t.STSD,t.mp3(r))}return t.box(t.types.stsd,t.STSD,t.mp4a(r))}else{return t.box(t.types.stsd,t.STSD,t.avc1(r))}};t.tkhd=function i(r){var n=r.id;var s=r.duration*r.timescale;var a=r.width;var u=r.height;var o=Math.floor(s/(e+1));var f=Math.floor(s%(e+1));return t.box(t.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,n>>24&255,n>>16&255,n>>8&255,n&255,0,0,0,0,o>>24,o>>16&255,o>>8&255,o&255,f>>24,f>>16&255,f>>8&255,f&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,a>>8&255,a&255,0,0,u>>8&255,u&255,0,0]))};t.traf=function i(r,n){var s=t.sdtp(r);var a=r.id;var u=Math.floor(n/(e+1));var o=Math.floor(n%(e+1));return t.box(t.types.traf,t.box(t.types.tfhd,new Uint8Array([0,0,0,0,a>>24,a>>16&255,a>>8&255,a&255])),t.box(t.types.tfdt,new Uint8Array([1,0,0,0,u>>24,u>>16&255,u>>8&255,u&255,o>>24,o>>16&255,o>>8&255,o&255])),t.trun(r,s.length+16+20+8+16+8+8),s)};t.trak=function i(r){r.duration=r.duration||4294967295;return t.box(t.types.trak,t.tkhd(r),t.mdia(r))};t.trex=function i(r){var e=r.id;return t.box(t.types.trex,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))};t.trun=function i(r,e){var n=r.samples||[];var s=n.length;var a=12+16*s;var u=new Uint8Array(a);var o;var f;var h;var l;var c;var v;e+=8+a;u.set([0,0,15,1,s>>>24&255,s>>>16&255,s>>>8&255,s&255,e>>>24&255,e>>>16&255,e>>>8&255,e&255],0);for(o=0;o<s;o++){f=n[o];h=f.duration;l=f.size;c=f.flags;v=f.cts;u.set([h>>>24&255,h>>>16&255,h>>>8&255,h&255,l>>>24&255,l>>>16&255,l>>>8&255,l&255,c.isLeading<<2|c.dependsOn,c.isDependedOn<<6|c.hasRedundancy<<4|c.paddingValue<<1|c.isNonSync,c.degradPrio&240<<8,c.degradPrio&15,v>>>24&255,v>>>16&255,v>>>8&255,v&255],12+16*o)}return t.box(t.types.trun,u)};t.initSegment=function i(r){if(!t.types){t.init()}var e=t.moov(r);var n=new Uint8Array(t.FTYP.byteLength+e.byteLength);n.set(t.FTYP);n.set(e,t.FTYP.byteLength);return n};return t}();n.types=void 0;n.HDLR_TYPES=void 0;n.STTS=void 0;n.STSC=void 0;n.STCO=void 0;n.STSZ=void 0;n.VMHD=void 0;n.SMHD=void 0;n.STSD=void 0;n.FTYP=void 0;n.DINF=void 0;i["default"]=n},"./src/remux/mp4-remuxer.ts":
|
|
242
|
+
/*!**********************************!*\
|
|
243
|
+
!*** ./src/remux/mp4-remuxer.ts ***!
|
|
244
|
+
\**********************************/
|
|
245
|
+
/*! exports provided: default, normalizePts */function(t,i,r){r.r(i);r.d(i,"default",(function(){return b}));r.d(i,"normalizePts",(function(){return y}));var e=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");var n=r(/*! ./aac-helper */"./src/remux/aac-helper.ts");var s=r(/*! ./mp4-generator */"./src/remux/mp4-generator.ts");var a=r(/*! ../events */"./src/events.ts");var u=r(/*! ../errors */"./src/errors.ts");var o=r(/*! ../utils/logger */"./src/utils/logger.ts");var f=r(/*! ../types/loader */"./src/types/loader.ts");var h=r(/*! ../utils/timescale-conversion */"./src/utils/timescale-conversion.ts");function l(){l=Object.assign||function(t){for(var i=1;i<arguments.length;i++){var r=arguments[i];for(var e in r){if(Object.prototype.hasOwnProperty.call(r,e)){t[e]=r[e]}}}return t};return l.apply(this,arguments)}var c=10*1e3;var v=1024;var d=1152;var m=null;var p=null;var g=false;var b=function(){function t(t,i,r,e){this.observer=void 0;this.config=void 0;this.typeSupported=void 0;this.ISGenerated=false;this._initPTS=void 0;this._initDTS=void 0;this.nextAvcDts=null;this.nextAudioPts=null;this.isAudioContiguous=false;this.isVideoContiguous=false;this.observer=t;this.config=i;this.typeSupported=r;this.ISGenerated=false;if(m===null){var n=navigator.userAgent||"";var s=n.match(/Chrome\/(\d+)/i);m=s?parseInt(s[1]):0}if(p===null){var a=navigator.userAgent.match(/Safari\/(\d+)/i);p=a?parseInt(a[1]):0}g=!!m&&m<75||!!p&&p<600}var i=t.prototype;i.destroy=function t(){};i.resetTimeStamp=function t(i){o["logger"].log("[mp4-remuxer]: initPTS & initDTS reset");this._initPTS=this._initDTS=i};i.resetNextTimestamp=function t(){o["logger"].log("[mp4-remuxer]: reset next timestamp");this.isVideoContiguous=false;this.isAudioContiguous=false};i.resetInitSegment=function t(){o["logger"].log("[mp4-remuxer]: ISGenerated flag reset");this.ISGenerated=false};i.getVideoStartPts=function t(i){var r=false;var e=i.reduce((function(t,i){var e=i.pts-t;if(e<-4294967296){r=true;return y(t,i.pts)}else if(e>0){return t}else{return i.pts}}),i[0].pts);if(r){o["logger"].debug("PTS rollover detected")}return e};i.remux=function t(i,r,e,n,s,a,u,h){var l;var c;var v;var d;var m;var p;var g=s;var b=s;var A=i.pid>-1;var k=r.pid>-1;var T=r.samples.length;var E=i.samples.length>0;var O=T>1;var S=(!A||E)&&(!k||O)||this.ISGenerated||u;if(S){if(!this.ISGenerated){v=this.generateIS(i,r,s)}var M=this.isVideoContiguous;var x=-1;if(O){x=w(r.samples);if(!M&&this.config.forceKeyFrameOnDiscontinuity){p=true;if(x>0){o["logger"].warn("[mp4-remuxer]: Dropped "+x+" out of "+T+" video samples due to a missing keyframe");var j=this.getVideoStartPts(r.samples);r.samples=r.samples.slice(x);r.dropped+=x;b+=(r.samples[0].pts-j)/(r.timescale||9e4)}else if(x===-1){o["logger"].warn("[mp4-remuxer]: No keyframe found out of "+T+" video samples");p=false}}}if(this.ISGenerated){if(E&&O){var D=this.getVideoStartPts(r.samples);var I=y(i.samples[0].pts,D)-D;var L=I/r.inputTimeScale;g+=Math.max(0,L);b+=Math.max(0,-L)}if(E){if(!i.samplerate){o["logger"].warn("[mp4-remuxer]: regenerate InitSegment as audio detected");v=this.generateIS(i,r,s)}c=this.remuxAudio(i,g,this.isAudioContiguous,a,k||O||h===f["PlaylistLevelType"].AUDIO?b:undefined);if(O){var C=c?c.endPTS-c.startPTS:0;if(!r.inputTimeScale){o["logger"].warn("[mp4-remuxer]: regenerate InitSegment as video detected");v=this.generateIS(i,r,s)}l=this.remuxVideo(r,b,M,C)}}else if(O){l=this.remuxVideo(r,b,M,0)}if(l){l.firstKeyFrame=x;l.independent=x!==-1}}}if(this.ISGenerated){if(e.samples.length){m=this.remuxID3(e,s)}if(n.samples.length){d=this.remuxText(n,s)}}return{audio:c,video:l,initSegment:v,independent:p,text:d,id3:m}};i.generateIS=function t(i,r,n){var a=i.samples;var u=r.samples;var o=this.typeSupported;var f={};var h=!Object(e["isFiniteNumber"])(this._initPTS);var l="audio/mp4";var c;var v;var d;if(h){c=v=Infinity}if(i.config&&a.length){i.timescale=i.samplerate;if(!i.isAAC){if(o.mpeg){l="audio/mpeg";i.codec=""}else if(o.mp3){i.codec="mp3"}}f.audio={id:"audio",container:l,codec:i.codec,initSegment:!i.isAAC&&o.mpeg?new Uint8Array(0):s["default"].initSegment([i]),metadata:{channelCount:i.channelCount}};if(h){d=i.inputTimeScale;c=v=a[0].pts-Math.round(d*n)}}if(r.sps&&r.pps&&u.length){r.timescale=r.inputTimeScale;f.video={id:"main",container:"video/mp4",codec:r.codec,initSegment:s["default"].initSegment([r]),metadata:{width:r.width,height:r.height}};if(h){d=r.inputTimeScale;var m=this.getVideoStartPts(u);var p=Math.round(d*n);v=Math.min(v,y(u[0].dts,m)-p);c=Math.min(c,m-p)}}if(Object.keys(f).length){this.ISGenerated=true;if(h){this._initPTS=c;this._initDTS=v}return{tracks:f,initPTS:c,timescale:d}}};i.remuxVideo=function t(i,r,e,n){var f=i.inputTimeScale;var c=i.samples;var v=[];var d=c.length;var p=this._initPTS;var b=this.nextAvcDts;var w=8;var k;var T;var E;var O=Number.POSITIVE_INFINITY;var S=Number.NEGATIVE_INFINITY;var M=0;var x=false;if(!e||b===null){var j=r*f;var D=c[0].pts-y(c[0].dts,c[0].pts);b=j-D}for(var I=0;I<d;I++){var L=c[I];L.pts=y(L.pts-p,b);L.dts=y(L.dts-p,b);if(L.dts>L.pts){var C=9e4*.2;M=Math.max(Math.min(M,L.pts-L.dts),-1*C)}if(L.dts<c[I>0?I-1:I].dts){x=true}}if(x){c.sort((function(t,i){var r=t.dts-i.dts;var e=t.pts-i.pts;return r||e}))}T=c[0].dts;E=c[c.length-1].dts;var R=Math.round((E-T)/(d-1));if(M<0){if(M<R*-2){o["logger"].warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+Object(h["toMsFromMpegTsClock"])(-R,true)+" ms");var N=M;for(var U=0;U<d;U++){c[U].dts=N=Math.max(N,c[U].pts-R);c[U].pts=Math.max(N,c[U].pts)}}else{o["logger"].warn("PTS < DTS detected in video samples, shifting DTS by "+Object(h["toMsFromMpegTsClock"])(M,true)+" ms to overcome this issue");for(var P=0;P<d;P++){c[P].dts=c[P].dts+M}}T=c[0].dts}if(e){var F=T-b;var B=F>R;var G=F<-1;if(B||G){if(B){o["logger"].warn("AVC: "+Object(h["toMsFromMpegTsClock"])(F,true)+" ms ("+F+"dts) hole between fragments detected, filling it")}else{o["logger"].warn("AVC: "+Object(h["toMsFromMpegTsClock"])(-F,true)+" ms ("+F+"dts) overlapping between fragments detected")}T=b;var W=c[0].pts-F;c[0].dts=T;c[0].pts=W;o["logger"].log("Video: First PTS/DTS adjusted: "+Object(h["toMsFromMpegTsClock"])(W,true)+"/"+Object(h["toMsFromMpegTsClock"])(T,true)+", delta: "+Object(h["toMsFromMpegTsClock"])(F,true)+" ms")}}if(g){T=Math.max(0,T)}var X=0;var z=0;for(var Y=0;Y<d;Y++){var Z=c[Y];var V=Z.units;var Q=V.length;var H=0;for(var K=0;K<Q;K++){H+=V[K].data.length}z+=H;X+=Q;Z.length=H;Z.dts=Math.max(Z.dts,T);Z.pts=Math.max(Z.pts,Z.dts,0);O=Math.min(Z.pts,O);S=Math.max(Z.pts,S)}E=c[d-1].dts;var J=z+4*X+8;var q;try{q=new Uint8Array(J)}catch(t){this.observer.emit(a["Events"].ERROR,a["Events"].ERROR,{type:u["ErrorTypes"].MUX_ERROR,details:u["ErrorDetails"].REMUX_ALLOC_ERROR,fatal:false,bytes:J,reason:"fail allocating video mdat "+J});return}var _=new DataView(q.buffer);_.setUint32(0,J);q.set(s["default"].types.mdat,4);for(var $=0;$<d;$++){var tt=c[$];var it=tt.units;var rt=0;for(var et=0,nt=it.length;et<nt;et++){var st=it[et];var at=st.data;var ut=st.data.byteLength;_.setUint32(w,ut);w+=4;q.set(at,w);w+=ut;rt+=4+ut}if($<d-1){k=c[$+1].dts-tt.dts}else{var ot=this.config;var ft=tt.dts-c[$>0?$-1:$].dts;if(ot.stretchShortVideoTrack&&this.nextAudioPts!==null){var ht=Math.floor(ot.maxBufferHole*f);var lt=(n?O+n*f:this.nextAudioPts)-tt.pts;if(lt>ht){k=lt-ft;if(k<0){k=ft}o["logger"].log("[mp4-remuxer]: It is approximately "+lt/90+" ms to the next segment; using duration "+k/90+" ms for the last video frame.")}else{k=ft}}else{k=ft}}var ct=Math.round(tt.pts-tt.dts);v.push(new A(tt.key,k,rt,ct))}if(v.length&&m&&m<70){var vt=v[0].flags;vt.dependsOn=2;vt.isNonSync=0}console.assert(k!==undefined,"mp4SampleDuration must be computed");this.nextAvcDts=b=E+k;this.isVideoContiguous=true;var dt=s["default"].moof(i.sequenceNumber++,T,l({},i,{samples:v}));var mt="video";var pt={data1:dt,data2:q,startPTS:O/f,endPTS:(S+k)/f,startDTS:T/f,endDTS:b/f,type:mt,hasAudio:false,hasVideo:true,nb:v.length,dropped:i.dropped};i.samples=[];i.dropped=0;console.assert(q.length,"MDAT length must not be zero");return pt};i.remuxAudio=function t(i,r,e,f,h){var m=i.inputTimeScale;var p=i.samplerate?i.samplerate:m;var g=m/p;var b=i.isAAC?v:d;var w=b*g;var k=this._initPTS;var T=!i.isAAC&&this.typeSupported.mpeg;var E=[];var O=i.samples;var S=T?0:8;var M=this.nextAudioPts||-1;var x=r*m;this.isAudioContiguous=e=e||O.length&&M>0&&(f&&Math.abs(x-M)<9e3||Math.abs(y(O[0].pts-k,x)-M)<20*w);O.forEach((function(t){t.pts=y(t.pts-k,x)}));if(!e||M<0){O=O.filter((function(t){return t.pts>=0}));if(!O.length){return}if(h===0){M=0}else if(f){M=Math.max(0,x)}else{M=O[0].pts}}if(i.isAAC){var j=h!==undefined;var D=this.config.maxAudioFramesDrift;for(var I=0,L=M;I<O.length;I++){var C=O[I];var R=C.pts;var N=R-L;var U=Math.abs(1e3*N/m);if(N<=-D*w&&j){if(I===0){o["logger"].warn("Audio frame @ "+(R/m).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*N/m)+" ms.");this.nextAudioPts=M=L=R}}else if(N>=D*w&&U<c&&j){var P=Math.round(N/w);L=R-P*w;if(L<0){P--;L+=w}if(I===0){this.nextAudioPts=M=L}o["logger"].warn("[mp4-remuxer]: Injecting "+P+" audio frame @ "+(L/m).toFixed(3)+"s due to "+Math.round(1e3*N/m)+" ms gap.");for(var F=0;F<P;F++){var B=Math.max(L,0);var G=n["default"].getSilentFrame(i.manifestCodec||i.codec,i.channelCount);if(!G){o["logger"].log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead.");G=C.unit.subarray()}O.splice(I,0,{unit:G,pts:B});L+=w;I++}}C.pts=L;L+=w}}var W=null;var X=null;var z;var Y=0;var Z=O.length;while(Z--){Y+=O[Z].unit.byteLength}for(var V=0,Q=O.length;V<Q;V++){var H=O[V];var K=H.unit;var J=H.pts;if(X!==null){var q=E[V-1];q.duration=Math.round((J-X)/g)}else{if(e&&i.isAAC){J=M}W=J;if(Y>0){Y+=S;try{z=new Uint8Array(Y)}catch(t){this.observer.emit(a["Events"].ERROR,a["Events"].ERROR,{type:u["ErrorTypes"].MUX_ERROR,details:u["ErrorDetails"].REMUX_ALLOC_ERROR,fatal:false,bytes:Y,reason:"fail allocating audio mdat "+Y});return}if(!T){var _=new DataView(z.buffer);_.setUint32(0,Y);z.set(s["default"].types.mdat,4)}}else{return}}z.set(K,S);var $=K.byteLength;S+=$;E.push(new A(true,b,$,0));X=J}var tt=E.length;if(!tt){return}var it=E[E.length-1];this.nextAudioPts=M=X+g*it.duration;var rt=T?new Uint8Array(0):s["default"].moof(i.sequenceNumber++,W/g,l({},i,{samples:E}));i.samples=[];var et=W/m;var nt=M/m;var st="audio";var at={data1:rt,data2:z,startPTS:et,endPTS:nt,startDTS:et,endDTS:nt,type:st,hasAudio:true,hasVideo:false,nb:tt};this.isAudioContiguous=true;console.assert(z.length,"MDAT length must not be zero");return at};i.remuxEmptyAudio=function t(i,r,e,s){var a=i.inputTimeScale;var u=i.samplerate?i.samplerate:a;var f=a/u;var h=this.nextAudioPts;var l=(h!==null?h:s.startDTS*a)+this._initDTS;var c=s.endDTS*a+this._initDTS;var d=f*v;var m=Math.ceil((c-l)/d);var p=n["default"].getSilentFrame(i.manifestCodec||i.codec,i.channelCount);o["logger"].warn("[mp4-remuxer]: remux empty Audio");if(!p){o["logger"].trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}var g=[];for(var b=0;b<m;b++){var y=l+b*d;g.push({unit:p,pts:y,dts:y})}i.samples=g;return this.remuxAudio(i,r,e,false)};i.remuxID3=function t(i,r){var e=i.samples.length;if(!e){return}var n=i.inputTimeScale;var s=this._initPTS;var a=this._initDTS;for(var u=0;u<e;u++){var o=i.samples[u];o.pts=y(o.pts-s,r*n)/n;o.dts=y(o.dts-a,r*n)/n}var f=i.samples;i.samples=[];return{samples:f}};i.remuxText=function t(i,r){var e=i.samples.length;if(!e){return}var n=i.inputTimeScale;var s=this._initPTS;for(var a=0;a<e;a++){var u=i.samples[a];u.pts=y(u.pts-s,r*n)/n}i.samples.sort((function(t,i){return t.pts-i.pts}));var o=i.samples;i.samples=[];return{samples:o}};return t}();function y(t,i){var r;if(i===null){return t}if(i<t){r=-8589934592}else{r=8589934592}while(Math.abs(t-i)>4294967296){t+=r}return t}function w(t){for(var i=0;i<t.length;i++){if(t[i].key){return i}}return-1}var A=function t(i,r,e,n){this.size=void 0;this.duration=void 0;this.cts=void 0;this.flags=void 0;this.duration=r;this.size=e;this.cts=n;this.flags=new k(i)};var k=function t(i){this.isLeading=0;this.isDependedOn=0;this.hasRedundancy=0;this.degradPrio=0;this.dependsOn=1;this.isNonSync=1;this.dependsOn=i?2:1;this.isNonSync=i?0:1}},"./src/remux/passthrough-remuxer.ts":
|
|
246
|
+
/*!******************************************!*\
|
|
247
|
+
!*** ./src/remux/passthrough-remuxer.ts ***!
|
|
248
|
+
\******************************************/
|
|
249
|
+
/*! exports provided: default */function(t,i,r){r.r(i);var e=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");var n=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts");var s=r(/*! ../loader/fragment */"./src/loader/fragment.ts");var a=r(/*! ../utils/logger */"./src/utils/logger.ts");var u=function(){function t(){this.emitInitSegment=false;this.audioCodec=void 0;this.videoCodec=void 0;this.initData=void 0;this.initPTS=void 0;this.initTracks=void 0;this.lastEndDTS=null}var i=t.prototype;i.destroy=function t(){};i.resetTimeStamp=function t(i){this.initPTS=i;this.lastEndDTS=null};i.resetNextTimestamp=function t(){this.lastEndDTS=null};i.resetInitSegment=function t(i,r,e){this.audioCodec=r;this.videoCodec=e;this.generateInitSegment(i);this.emitInitSegment=true};i.generateInitSegment=function t(i){var r=this.audioCodec,e=this.videoCodec;if(!i||!i.byteLength){this.initTracks=undefined;this.initData=undefined;return}var u=this.initData=Object(n["parseInitSegment"])(i);if(!r){r=f(u.audio,s["ElementaryStreamTypes"].AUDIO)}if(!e){e=f(u.video,s["ElementaryStreamTypes"].VIDEO)}var o={};if(u.audio&&u.video){o.audiovideo={container:"video/mp4",codec:r+","+e,initSegment:i,id:"main"}}else if(u.audio){o.audio={container:"audio/mp4",codec:r,initSegment:i,id:"audio"}}else if(u.video){o.video={container:"video/mp4",codec:e,initSegment:i,id:"main"}}else{a["logger"].warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes.")}this.initTracks=o};i.remux=function t(i,r,s,u,f){var h=this.initPTS,l=this.lastEndDTS;var c={audio:undefined,video:undefined,text:u,id3:s,initSegment:undefined};if(!Object(e["isFiniteNumber"])(l)){l=this.lastEndDTS=f||0}var v=r.samples;if(!v||!v.length){return c}var d={initPTS:undefined,timescale:1};var m=this.initData;if(!m||!m.length){this.generateInitSegment(v);m=this.initData}if(!m||!m.length){a["logger"].warn("[passthrough-remuxer.ts]: Failed to generate initSegment.");return c}if(this.emitInitSegment){d.tracks=this.initTracks;this.emitInitSegment=false}if(!Object(e["isFiniteNumber"])(h)){this.initPTS=d.initPTS=h=o(m,v,l)}var p=Object(n["getDuration"])(v,m);var g=l;var b=p+g;Object(n["offsetStartDTS"])(m,v,h);if(p>0){this.lastEndDTS=b}else{a["logger"].warn("Duration parsed from mp4 should be greater than zero");this.resetNextTimestamp()}var y=!!m.audio;var w=!!m.video;var A="";if(y){A+="audio"}if(w){A+="video"}var k={data1:v,startPTS:g,startDTS:g,endPTS:b,endDTS:b,type:A,hasAudio:y,hasVideo:w,nb:1,dropped:0};c.audio=k.type==="audio"?k:undefined;c.video=k.type!=="audio"?k:undefined;c.text=u;c.id3=s;c.initSegment=d;return c};return t}();var o=function t(i,r,e){return Object(n["getStartDTS"])(i,r)-e};function f(t,i){var r=t===null||t===void 0?void 0:t.codec;if(r&&r.length>4){return r}if(r==="hvc1"){return"hvc1.1.c.L120.90"}if(r==="av01"){return"av01.0.04M.08"}if(r==="avc1"||i===s["ElementaryStreamTypes"].VIDEO){return"avc1.42e01e"}return"mp4a.40.5"}i["default"]=u},"./src/task-loop.ts":
|
|
250
|
+
/*!**************************!*\
|
|
251
|
+
!*** ./src/task-loop.ts ***!
|
|
252
|
+
\**************************/
|
|
253
|
+
/*! exports provided: default */function(t,i,r){r.r(i);r.d(i,"default",(function(){return e}));var e=function(){function t(){this._boundTick=void 0;this._tickTimer=null;this._tickInterval=null;this._tickCallCount=0;this._boundTick=this.tick.bind(this)}var i=t.prototype;i.destroy=function t(){this.onHandlerDestroying();this.onHandlerDestroyed()};i.onHandlerDestroying=function t(){this.clearNextTick();this.clearInterval()};i.onHandlerDestroyed=function t(){};i.hasInterval=function t(){return!!this._tickInterval};i.hasNextTick=function t(){return!!this._tickTimer};i.setInterval=function t(i){if(!this._tickInterval){this._tickInterval=self.setInterval(this._boundTick,i);return true}return false};i.clearInterval=function t(){if(this._tickInterval){self.clearInterval(this._tickInterval);this._tickInterval=null;return true}return false};i.clearNextTick=function t(){if(this._tickTimer){self.clearTimeout(this._tickTimer);this._tickTimer=null;return true}return false};i.tick=function t(){this._tickCallCount++;if(this._tickCallCount===1){this.doTick();if(this._tickCallCount>1){this.tickImmediate()}this._tickCallCount=0}};i.tickImmediate=function t(){this.clearNextTick();this._tickTimer=self.setTimeout(this._boundTick,0)};i.doTick=function t(){};return t}()},"./src/types/cmcd.ts":
|
|
254
|
+
/*!***************************!*\
|
|
255
|
+
!*** ./src/types/cmcd.ts ***!
|
|
256
|
+
\***************************/
|
|
257
|
+
/*! exports provided: CMCDVersion, CMCDObjectType, CMCDStreamingFormat, CMCDStreamType */function(t,i,r){r.r(i);r.d(i,"CMCDVersion",(function(){return e}));r.d(i,"CMCDObjectType",(function(){return n}));r.d(i,"CMCDStreamingFormat",(function(){return s}));r.d(i,"CMCDStreamType",(function(){return a}));var e=1;var n;(function(t){t["MANIFEST"]="m";t["AUDIO"]="a";t["VIDEO"]="v";t["MUXED"]="av";t["INIT"]="i";t["CAPTION"]="c";t["TIMED_TEXT"]="tt";t["KEY"]="k";t["OTHER"]="o"})(n||(n={}));var s;(function(t){t["DASH"]="d";t["HLS"]="h";t["SMOOTH"]="s";t["OTHER"]="o"})(s||(s={}));var a;(function(t){t["VOD"]="v";t["LIVE"]="l"})(a||(a={}))},"./src/types/level.ts":
|
|
258
|
+
/*!****************************!*\
|
|
259
|
+
!*** ./src/types/level.ts ***!
|
|
260
|
+
\****************************/
|
|
261
|
+
/*! exports provided: HlsSkip, getSkipValue, HlsUrlParameters, Level */function(t,i,r){r.r(i);r.d(i,"HlsSkip",(function(){return s}));r.d(i,"getSkipValue",(function(){return a}));r.d(i,"HlsUrlParameters",(function(){return u}));r.d(i,"Level",(function(){return o}));function e(t,i){for(var r=0;r<i.length;r++){var e=i[r];e.enumerable=e.enumerable||false;e.configurable=true;if("value"in e)e.writable=true;Object.defineProperty(t,e.key,e)}}function n(t,i,r){if(i)e(t.prototype,i);if(r)e(t,r);return t}var s;(function(t){t["No"]="";t["Yes"]="YES";t["v2"]="v2"})(s||(s={}));function a(t,i){var r=t.canSkipUntil,e=t.canSkipDateRanges,n=t.endSN;var a=i!==undefined?i-n:0;if(r&&a<r){if(e){return s.v2}return s.Yes}return s.No}var u=function(){function t(t,i,r){this.msn=void 0;this.part=void 0;this.skip=void 0;this.msn=t;this.part=i;this.skip=r}var i=t.prototype;i.addDirectives=function t(i){var r=new self.URL(i);if(this.msn!==undefined){r.searchParams.set("_HLS_msn",this.msn.toString())}if(this.part!==undefined){r.searchParams.set("_HLS_part",this.part.toString())}if(this.skip){r.searchParams.set("_HLS_skip",this.skip)}return r.toString()};return t}();var o=function(){function t(t){this.attrs=void 0;this.audioCodec=void 0;this.bitrate=void 0;this.codecSet=void 0;this.height=void 0;this.id=void 0;this.name=void 0;this.videoCodec=void 0;this.width=void 0;this.unknownCodecs=void 0;this.audioGroupIds=void 0;this.details=void 0;this.fragmentError=0;this.loadError=0;this.loaded=void 0;this.realBitrate=0;this.textGroupIds=void 0;this.url=void 0;this._urlId=0;this.url=[t.url];this.attrs=t.attrs;this.bitrate=t.bitrate;if(t.details){this.details=t.details}this.id=t.id||0;this.name=t.name;this.width=t.width||0;this.height=t.height||0;this.audioCodec=t.audioCodec;this.videoCodec=t.videoCodec;this.unknownCodecs=t.unknownCodecs;this.codecSet=[t.videoCodec,t.audioCodec].filter((function(t){return t})).join(",").replace(/\.[^.,]+/g,"")}n(t,[{key:"maxBitrate",get:function t(){return Math.max(this.realBitrate,this.bitrate)}},{key:"uri",get:function t(){return this.url[this._urlId]||""}},{key:"urlId",get:function t(){return this._urlId},set:function t(i){var r=i%this.url.length;if(this._urlId!==r){this.details=undefined;this._urlId=r}}}]);return t}()},"./src/types/loader.ts":
|
|
262
|
+
/*!*****************************!*\
|
|
263
|
+
!*** ./src/types/loader.ts ***!
|
|
264
|
+
\*****************************/
|
|
265
|
+
/*! exports provided: PlaylistContextType, PlaylistLevelType */function(t,i,r){r.r(i);r.d(i,"PlaylistContextType",(function(){return e}));r.d(i,"PlaylistLevelType",(function(){return n}));var e;(function(t){t["MANIFEST"]="manifest";t["LEVEL"]="level";t["AUDIO_TRACK"]="audioTrack";t["SUBTITLE_TRACK"]="subtitleTrack"})(e||(e={}));var n;(function(t){t["MAIN"]="main";t["AUDIO"]="audio";t["SUBTITLE"]="subtitle"})(n||(n={}))},"./src/types/transmuxer.ts":
|
|
266
|
+
/*!*********************************!*\
|
|
267
|
+
!*** ./src/types/transmuxer.ts ***!
|
|
268
|
+
\*********************************/
|
|
269
|
+
/*! exports provided: ChunkMetadata */function(t,i,r){r.r(i);r.d(i,"ChunkMetadata",(function(){return e}));var e=function t(i,r,e,s,a,u){if(s===void 0){s=0}if(a===void 0){a=-1}if(u===void 0){u=false}this.level=void 0;this.sn=void 0;this.part=void 0;this.id=void 0;this.size=void 0;this.partial=void 0;this.transmuxing=n();this.buffering={audio:n(),video:n(),audiovideo:n()};this.level=i;this.sn=r;this.id=e;this.size=s;this.part=a;this.partial=u};function n(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":
|
|
270
|
+
/*!********************************!*\
|
|
271
|
+
!*** ./src/utils/attr-list.ts ***!
|
|
272
|
+
\********************************/
|
|
273
|
+
/*! exports provided: AttrList */function(t,i,r){r.r(i);r.d(i,"AttrList",(function(){return s}));var e=/^(\d+)x(\d+)$/;var n=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g;var s=function(){function t(i){if(typeof i==="string"){i=t.parseAttrList(i)}for(var r in i){if(i.hasOwnProperty(r)){this[r]=i[r]}}}var i=t.prototype;i.decimalInteger=function t(i){var r=parseInt(this[i],10);if(r>Number.MAX_SAFE_INTEGER){return Infinity}return r};i.hexadecimalInteger=function t(i){if(this[i]){var r=(this[i]||"0x").slice(2);r=(r.length&1?"0":"")+r;var e=new Uint8Array(r.length/2);for(var n=0;n<r.length/2;n++){e[n]=parseInt(r.slice(n*2,n*2+2),16)}return e}else{return null}};i.hexadecimalIntegerAsNumber=function t(i){var r=parseInt(this[i],16);if(r>Number.MAX_SAFE_INTEGER){return Infinity}return r};i.decimalFloatingPoint=function t(i){return parseFloat(this[i])};i.optionalFloat=function t(i,r){var e=this[i];return e?parseFloat(e):r};i.enumeratedString=function t(i){return this[i]};i.bool=function t(i){return this[i]==="YES"};i.decimalResolution=function t(i){var r=e.exec(this[i]);if(r===null){return undefined}return{width:parseInt(r[1],10),height:parseInt(r[2],10)}};t.parseAttrList=function t(i){var r;var e={};var s='"';n.lastIndex=0;while((r=n.exec(i))!==null){var a=r[2];if(a.indexOf(s)===0&&a.lastIndexOf(s)===a.length-1){a=a.slice(1,-1)}e[r[1]]=a}return e};return t}()},"./src/utils/binary-search.ts":
|
|
274
|
+
/*!************************************!*\
|
|
275
|
+
!*** ./src/utils/binary-search.ts ***!
|
|
276
|
+
\************************************/
|
|
277
|
+
/*! exports provided: default */function(t,i,r){r.r(i);var e={search:function t(i,r){var e=0;var n=i.length-1;var s=null;var a=null;while(e<=n){s=(e+n)/2|0;a=i[s];var u=r(a);if(u>0){e=s+1}else if(u<0){n=s-1}else{return a}}return null}};i["default"]=e},"./src/utils/buffer-helper.ts":
|
|
278
|
+
/*!************************************!*\
|
|
279
|
+
!*** ./src/utils/buffer-helper.ts ***!
|
|
280
|
+
\************************************/
|
|
281
|
+
/*! exports provided: BufferHelper */function(t,i,r){r.r(i);r.d(i,"BufferHelper",(function(){return s}));var e=r(/*! ./logger */"./src/utils/logger.ts");var n={length:0,start:function t(){return 0},end:function t(){return 0}};var s=function(){function t(){}t.isBuffered=function i(r,e){try{if(r){var n=t.getBuffered(r);for(var s=0;s<n.length;s++){if(e>=n.start(s)&&e<=n.end(s)){return true}}}}catch(t){}return false};t.bufferInfo=function i(r,e,n){try{if(r){var s=t.getBuffered(r);var a=[];var u;for(u=0;u<s.length;u++){a.push({start:s.start(u),end:s.end(u)})}return this.bufferedInfo(a,e,n)}}catch(t){}return{len:0,start:e,end:e,nextStart:undefined}};t.bufferedInfo=function t(i,r,e){r=Math.max(0,r);i.sort((function(t,i){var r=t.start-i.start;if(r){return r}else{return i.end-t.end}}));var n=[];if(e){for(var s=0;s<i.length;s++){var a=n.length;if(a){var u=n[a-1].end;if(i[s].start-u<e){if(i[s].end>u){n[a-1].end=i[s].end}}else{n.push(i[s])}}else{n.push(i[s])}}}else{n=i}var o=0;var f;var h=r;var l=r;for(var c=0;c<n.length;c++){var v=n[c].start;var d=n[c].end;if(r+e>=v&&r<d){h=v;l=d;o=l-r}else if(r+e<v){f=v;break}}return{len:o,start:h||0,end:l||0,nextStart:f}};t.getBuffered=function t(i){try{return i.buffered}catch(t){e["logger"].log("failed to get media.buffered",t);return n}};return t}()},"./src/utils/cea-608-parser.ts":
|
|
282
|
+
/*!*************************************!*\
|
|
283
|
+
!*** ./src/utils/cea-608-parser.ts ***!
|
|
284
|
+
\*************************************/
|
|
285
|
+
/*! exports provided: Row, CaptionScreen, default */function(t,i,r){r.r(i);r.d(i,"Row",(function(){return b}));r.d(i,"CaptionScreen",(function(){return y}));var e=r(/*! ../utils/logger */"./src/utils/logger.ts");var n={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499};var s=function t(i){var r=i;if(n.hasOwnProperty(i)){r=n[i]}return String.fromCharCode(r)};var a=15;var u=100;var o={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14};var f={17:2,18:4,21:6,22:8,23:10,19:13,20:15};var h={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14};var l={25:2,26:4,29:6,30:8,31:10,27:13,28:15};var c=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];var v;(function(t){t[t["ERROR"]=0]="ERROR";t[t["TEXT"]=1]="TEXT";t[t["WARNING"]=2]="WARNING";t[t["INFO"]=2]="INFO";t[t["DEBUG"]=3]="DEBUG";t[t["DATA"]=3]="DATA"})(v||(v={}));var d=function(){function t(){this.time=null;this.verboseLevel=v.ERROR}var i=t.prototype;i.log=function t(i,r){if(this.verboseLevel>=i){e["logger"].log(this.time+" ["+i+"] "+r)}};return t}();var m=function t(i){var r=[];for(var e=0;e<i.length;e++){r.push(i[e].toString(16))}return r};var p=function(){function t(t,i,r,e,n){this.foreground=void 0;this.underline=void 0;this.italics=void 0;this.background=void 0;this.flash=void 0;this.foreground=t||"white";this.underline=i||false;this.italics=r||false;this.background=e||"black";this.flash=n||false}var i=t.prototype;i.reset=function t(){this.foreground="white";this.underline=false;this.italics=false;this.background="black";this.flash=false};i.setStyles=function t(i){var r=["foreground","underline","italics","background","flash"];for(var e=0;e<r.length;e++){var n=r[e];if(i.hasOwnProperty(n)){this[n]=i[n]}}};i.isDefault=function t(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash};i.equals=function t(i){return this.foreground===i.foreground&&this.underline===i.underline&&this.italics===i.italics&&this.background===i.background&&this.flash===i.flash};i.copy=function t(i){this.foreground=i.foreground;this.underline=i.underline;this.italics=i.italics;this.background=i.background;this.flash=i.flash};i.toString=function t(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash};return t}();var g=function(){function t(t,i,r,e,n,s){this.uchar=void 0;this.penState=void 0;this.uchar=t||" ";this.penState=new p(i,r,e,n,s)}var i=t.prototype;i.reset=function t(){this.uchar=" ";this.penState.reset()};i.setChar=function t(i,r){this.uchar=i;this.penState.copy(r)};i.setPenState=function t(i){this.penState.copy(i)};i.equals=function t(i){return this.uchar===i.uchar&&this.penState.equals(i.penState)};i.copy=function t(i){this.uchar=i.uchar;this.penState.copy(i.penState)};i.isEmpty=function t(){return this.uchar===" "&&this.penState.isDefault()};return t}();var b=function(){function t(t){this.chars=void 0;this.pos=void 0;this.currPenState=void 0;this.cueStartTime=void 0;this.logger=void 0;this.chars=[];for(var i=0;i<u;i++){this.chars.push(new g)}this.logger=t;this.pos=0;this.currPenState=new p}var i=t.prototype;i.equals=function t(i){var r=true;for(var e=0;e<u;e++){if(!this.chars[e].equals(i.chars[e])){r=false;break}}return r};i.copy=function t(i){for(var r=0;r<u;r++){this.chars[r].copy(i.chars[r])}};i.isEmpty=function t(){var i=true;for(var r=0;r<u;r++){if(!this.chars[r].isEmpty()){i=false;break}}return i};i.setCursor=function t(i){if(this.pos!==i){this.pos=i}if(this.pos<0){this.logger.log(v.DEBUG,"Negative cursor position "+this.pos);this.pos=0}else if(this.pos>u){this.logger.log(v.DEBUG,"Too large cursor position "+this.pos);this.pos=u}};i.moveCursor=function t(i){var r=this.pos+i;if(i>1){for(var e=this.pos+1;e<r+1;e++){this.chars[e].setPenState(this.currPenState)}}this.setCursor(r)};i.backSpace=function t(){this.moveCursor(-1);this.chars[this.pos].setChar(" ",this.currPenState)};i.insertChar=function t(i){if(i>=144){this.backSpace()}var r=s(i);if(this.pos>=u){this.logger.log(v.ERROR,"Cannot insert "+i.toString(16)+" ("+r+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(r,this.currPenState);this.moveCursor(1)};i.clearFromPos=function t(i){var r;for(r=i;r<u;r++){this.chars[r].reset()}};i.clear=function t(){this.clearFromPos(0);this.pos=0;this.currPenState.reset()};i.clearToEndOfRow=function t(){this.clearFromPos(this.pos)};i.getTextString=function t(){var i=[];var r=true;for(var e=0;e<u;e++){var n=this.chars[e].uchar;if(n!==" "){r=false}i.push(n)}if(r){return""}else{return i.join("")}};i.setPenStyles=function t(i){this.currPenState.setStyles(i);var r=this.chars[this.pos];r.setPenState(this.currPenState)};return t}();var y=function(){function t(t){this.rows=void 0;this.currRow=void 0;this.nrRollUpRows=void 0;this.lastOutputScreen=void 0;this.logger=void 0;this.rows=[];for(var i=0;i<a;i++){this.rows.push(new b(t))}this.logger=t;this.currRow=a-1;this.nrRollUpRows=null;this.lastOutputScreen=null;this.reset()}var i=t.prototype;i.reset=function t(){for(var i=0;i<a;i++){this.rows[i].clear()}this.currRow=a-1};i.equals=function t(i){var r=true;for(var e=0;e<a;e++){if(!this.rows[e].equals(i.rows[e])){r=false;break}}return r};i.copy=function t(i){for(var r=0;r<a;r++){this.rows[r].copy(i.rows[r])}};i.isEmpty=function t(){var i=true;for(var r=0;r<a;r++){if(!this.rows[r].isEmpty()){i=false;break}}return i};i.backSpace=function t(){var i=this.rows[this.currRow];i.backSpace()};i.clearToEndOfRow=function t(){var i=this.rows[this.currRow];i.clearToEndOfRow()};i.insertChar=function t(i){var r=this.rows[this.currRow];r.insertChar(i)};i.setPen=function t(i){var r=this.rows[this.currRow];r.setPenStyles(i)};i.moveCursor=function t(i){var r=this.rows[this.currRow];r.moveCursor(i)};i.setCursor=function t(i){this.logger.log(v.INFO,"setCursor: "+i);var r=this.rows[this.currRow];r.setCursor(i)};i.setPAC=function t(i){this.logger.log(v.INFO,"pacData = "+JSON.stringify(i));var r=i.row-1;if(this.nrRollUpRows&&r<this.nrRollUpRows-1){r=this.nrRollUpRows-1}if(this.nrRollUpRows&&this.currRow!==r){for(var e=0;e<a;e++){this.rows[e].clear()}var n=this.currRow+1-this.nrRollUpRows;var s=this.lastOutputScreen;if(s){var u=s.rows[n].cueStartTime;var o=this.logger.time;if(u&&o!==null&&u<o){for(var f=0;f<this.nrRollUpRows;f++){this.rows[r-this.nrRollUpRows+f+1].copy(s.rows[n+f])}}}}this.currRow=r;var h=this.rows[this.currRow];if(i.indent!==null){var l=i.indent;var c=Math.max(l-1,0);h.setCursor(i.indent);i.color=h.chars[c].penState.foreground}var d={foreground:i.color,underline:i.underline,italics:i.italics,background:"black",flash:false};this.setPen(d)};i.setBkgData=function t(i){this.logger.log(v.INFO,"bkgData = "+JSON.stringify(i));this.backSpace();this.setPen(i);this.insertChar(32)};i.setRollUpRows=function t(i){this.nrRollUpRows=i};i.rollUp=function t(){if(this.nrRollUpRows===null){this.logger.log(v.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(v.TEXT,this.getDisplayText());var i=this.currRow+1-this.nrRollUpRows;var r=this.rows.splice(i,1)[0];r.clear();this.rows.splice(this.currRow,0,r);this.logger.log(v.INFO,"Rolling up")};i.getDisplayText=function t(i){i=i||false;var r=[];var e="";var n=-1;for(var s=0;s<a;s++){var u=this.rows[s].getTextString();if(u){n=s+1;if(i){r.push("Row "+n+": '"+u+"'")}else{r.push(u.trim())}}}if(r.length>0){if(i){e="["+r.join(" | ")+"]"}else{e=r.join("\n")}}return e};i.getTextAndFormat=function t(){return this.rows};return t}();var w=function(){function t(t,i,r){this.chNr=void 0;this.outputFilter=void 0;this.mode=void 0;this.verbose=void 0;this.displayedMemory=void 0;this.nonDisplayedMemory=void 0;this.lastOutputScreen=void 0;this.currRollUpRow=void 0;this.writeScreen=void 0;this.cueStartTime=void 0;this.logger=void 0;this.chNr=t;this.outputFilter=i;this.mode=null;this.verbose=0;this.displayedMemory=new y(r);this.nonDisplayedMemory=new y(r);this.lastOutputScreen=new y(r);this.currRollUpRow=this.displayedMemory.rows[a-1];this.writeScreen=this.displayedMemory;this.mode=null;this.cueStartTime=null;this.logger=r}var i=t.prototype;i.reset=function t(){this.mode=null;this.displayedMemory.reset();this.nonDisplayedMemory.reset();this.lastOutputScreen.reset();this.outputFilter.reset();this.currRollUpRow=this.displayedMemory.rows[a-1];this.writeScreen=this.displayedMemory;this.mode=null;this.cueStartTime=null};i.getHandler=function t(){return this.outputFilter};i.setHandler=function t(i){this.outputFilter=i};i.setPAC=function t(i){this.writeScreen.setPAC(i)};i.setBkgData=function t(i){this.writeScreen.setBkgData(i)};i.setMode=function t(i){if(i===this.mode){return}this.mode=i;this.logger.log(v.INFO,"MODE="+i);if(this.mode==="MODE_POP-ON"){this.writeScreen=this.nonDisplayedMemory}else{this.writeScreen=this.displayedMemory;this.writeScreen.reset()}if(this.mode!=="MODE_ROLL-UP"){this.displayedMemory.nrRollUpRows=null;this.nonDisplayedMemory.nrRollUpRows=null}this.mode=i};i.insertChars=function t(i){for(var r=0;r<i.length;r++){this.writeScreen.insertChar(i[r])}var e=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(v.INFO,e+": "+this.writeScreen.getDisplayText(true));if(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP"){this.logger.log(v.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(true));this.outputDataUpdate()}};i.ccRCL=function t(){this.logger.log(v.INFO,"RCL - Resume Caption Loading");this.setMode("MODE_POP-ON")};i.ccBS=function t(){this.logger.log(v.INFO,"BS - BackSpace");if(this.mode==="MODE_TEXT"){return}this.writeScreen.backSpace();if(this.writeScreen===this.displayedMemory){this.outputDataUpdate()}};i.ccAOF=function t(){};i.ccAON=function t(){};i.ccDER=function t(){this.logger.log(v.INFO,"DER- Delete to End of Row");this.writeScreen.clearToEndOfRow();this.outputDataUpdate()};i.ccRU=function t(i){this.logger.log(v.INFO,"RU("+i+") - Roll Up");this.writeScreen=this.displayedMemory;this.setMode("MODE_ROLL-UP");this.writeScreen.setRollUpRows(i)};i.ccFON=function t(){this.logger.log(v.INFO,"FON - Flash On");this.writeScreen.setPen({flash:true})};i.ccRDC=function t(){this.logger.log(v.INFO,"RDC - Resume Direct Captioning");this.setMode("MODE_PAINT-ON")};i.ccTR=function t(){this.logger.log(v.INFO,"TR");this.setMode("MODE_TEXT")};i.ccRTD=function t(){this.logger.log(v.INFO,"RTD");this.setMode("MODE_TEXT")};i.ccEDM=function t(){this.logger.log(v.INFO,"EDM - Erase Displayed Memory");this.displayedMemory.reset();this.outputDataUpdate(true)};i.ccCR=function t(){this.logger.log(v.INFO,"CR - Carriage Return");this.writeScreen.rollUp();this.outputDataUpdate(true)};i.ccENM=function t(){this.logger.log(v.INFO,"ENM - Erase Non-displayed Memory");this.nonDisplayedMemory.reset()};i.ccEOC=function t(){this.logger.log(v.INFO,"EOC - End Of Caption");if(this.mode==="MODE_POP-ON"){var i=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory;this.nonDisplayedMemory=i;this.writeScreen=this.nonDisplayedMemory;this.logger.log(v.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(true)};i.ccTO=function t(i){this.logger.log(v.INFO,"TO("+i+") - Tab Offset");this.writeScreen.moveCursor(i)};i.ccMIDROW=function t(i){var r={flash:false};r.underline=i%2===1;r.italics=i>=46;if(!r.italics){var e=Math.floor(i/2)-16;var n=["white","green","blue","cyan","red","yellow","magenta"];r.foreground=n[e]}else{r.foreground="white"}this.logger.log(v.INFO,"MIDROW: "+JSON.stringify(r));this.writeScreen.setPen(r)};i.outputDataUpdate=function t(i){if(i===void 0){i=false}var r=this.logger.time;if(r===null){return}if(this.outputFilter){if(this.cueStartTime===null&&!this.displayedMemory.isEmpty()){this.cueStartTime=r}else{if(!this.displayedMemory.equals(this.lastOutputScreen)){this.outputFilter.newCue(this.cueStartTime,r,this.lastOutputScreen);if(i&&this.outputFilter.dispatchCue){this.outputFilter.dispatchCue()}this.cueStartTime=this.displayedMemory.isEmpty()?null:r}}this.lastOutputScreen.copy(this.displayedMemory)}};i.cueSplitAtTime=function t(i){if(this.outputFilter){if(!this.displayedMemory.isEmpty()){if(this.outputFilter.newCue){this.outputFilter.newCue(this.cueStartTime,i,this.displayedMemory)}this.cueStartTime=i}}};return t}();var A=function(){function t(t,i,r){this.channels=void 0;this.currentChannel=0;this.cmdHistory=void 0;this.logger=void 0;var e=new d;this.channels=[null,new w(t,i,e),new w(t+1,r,e)];this.cmdHistory=E();this.logger=e}var i=t.prototype;i.getHandler=function t(i){return this.channels[i].getHandler()};i.setHandler=function t(i,r){this.channels[i].setHandler(r)};i.addData=function t(i,r){var e;var n;var s;var a=false;this.logger.time=i;for(var u=0;u<r.length;u+=2){n=r[u]&127;s=r[u+1]&127;if(n===0&&s===0){continue}else{this.logger.log(v.DATA,"["+m([r[u],r[u+1]])+"] -> ("+m([n,s])+")")}e=this.parseCmd(n,s);if(!e){e=this.parseMidrow(n,s)}if(!e){e=this.parsePAC(n,s)}if(!e){e=this.parseBackgroundAttributes(n,s)}if(!e){a=this.parseChars(n,s);if(a){var o=this.currentChannel;if(o&&o>0){var f=this.channels[o];f.insertChars(a)}else{this.logger.log(v.WARNING,"No channel found yet. TEXT-MODE?")}}}if(!e&&!a){this.logger.log(v.WARNING,"Couldn't parse cleaned data "+m([n,s])+" orig: "+m([r[u],r[u+1]]))}}};i.parseCmd=function t(i,r){var e=this.cmdHistory;var n=(i===20||i===28||i===21||i===29)&&r>=32&&r<=47;var s=(i===23||i===31)&&r>=33&&r<=35;if(!(n||s)){return false}if(T(i,r,e)){k(null,null,e);this.logger.log(v.DEBUG,"Repeated command ("+m([i,r])+") is dropped");return true}var a=i===20||i===21||i===23?1:2;var u=this.channels[a];if(i===20||i===21||i===28||i===29){if(r===32){u.ccRCL()}else if(r===33){u.ccBS()}else if(r===34){u.ccAOF()}else if(r===35){u.ccAON()}else if(r===36){u.ccDER()}else if(r===37){u.ccRU(2)}else if(r===38){u.ccRU(3)}else if(r===39){u.ccRU(4)}else if(r===40){u.ccFON()}else if(r===41){u.ccRDC()}else if(r===42){u.ccTR()}else if(r===43){u.ccRTD()}else if(r===44){u.ccEDM()}else if(r===45){u.ccCR()}else if(r===46){u.ccENM()}else if(r===47){u.ccEOC()}}else{u.ccTO(r-32)}k(i,r,e);this.currentChannel=a;return true};i.parseMidrow=function t(i,r){var e=0;if((i===17||i===25)&&r>=32&&r<=47){if(i===17){e=1}else{e=2}if(e!==this.currentChannel){this.logger.log(v.ERROR,"Mismatch channel in midrow parsing");return false}var n=this.channels[e];if(!n){return false}n.ccMIDROW(r);this.logger.log(v.DEBUG,"MIDROW ("+m([i,r])+")");return true}return false};i.parsePAC=function t(i,r){var e;var n=this.cmdHistory;var s=(i>=17&&i<=23||i>=25&&i<=31)&&r>=64&&r<=127;var a=(i===16||i===24)&&r>=64&&r<=95;if(!(s||a)){return false}if(T(i,r,n)){k(null,null,n);return true}var u=i<=23?1:2;if(r>=64&&r<=95){e=u===1?o[i]:h[i]}else{e=u===1?f[i]:l[i]}var c=this.channels[u];if(!c){return false}c.setPAC(this.interpretPAC(e,r));k(i,r,n);this.currentChannel=u;return true};i.interpretPAC=function t(i,r){var e;var n={color:null,italics:false,indent:null,underline:false,row:i};if(r>95){e=r-96}else{e=r-64}n.underline=(e&1)===1;if(e<=13){n.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(e/2)]}else if(e<=15){n.italics=true;n.color="white"}else{n.indent=Math.floor((e-16)/2)*4}return n};i.parseChars=function t(i,r){var e;var n=null;var a=null;if(i>=25){e=2;a=i-8}else{e=1;a=i}if(a>=17&&a<=19){var u;if(a===17){u=r+80}else if(a===18){u=r+112}else{u=r+144}this.logger.log(v.INFO,"Special char '"+s(u)+"' in channel "+e);n=[u]}else if(i>=32&&i<=127){n=r===0?[i]:[i,r]}if(n){var o=m(n);this.logger.log(v.DEBUG,"Char codes = "+o.join(","));k(i,r,this.cmdHistory)}return n};i.parseBackgroundAttributes=function t(i,r){var e=(i===16||i===24)&&r>=32&&r<=47;var n=(i===23||i===31)&&r>=45&&r<=47;if(!(e||n)){return false}var s;var a={};if(i===16||i===24){s=Math.floor((r-32)/2);a.background=c[s];if(r%2===1){a.background=a.background+"_semi"}}else if(r===45){a.background="transparent"}else{a.foreground="black";if(r===47){a.underline=true}}var u=i<=23?1:2;var o=this.channels[u];o.setBkgData(a);k(i,r,this.cmdHistory);return true};i.reset=function t(){for(var i=0;i<Object.keys(this.channels).length;i++){var r=this.channels[i];if(r){r.reset()}}this.cmdHistory=E()};i.cueSplitAtTime=function t(i){for(var r=0;r<this.channels.length;r++){var e=this.channels[r];if(e){e.cueSplitAtTime(i)}}};return t}();function k(t,i,r){r.a=t;r.b=i}function T(t,i,r){return r.a===t&&r.b===i}function E(){return{a:null,b:null}}i["default"]=A},"./src/utils/codecs.ts":
|
|
286
|
+
/*!*****************************!*\
|
|
287
|
+
!*** ./src/utils/codecs.ts ***!
|
|
288
|
+
\*****************************/
|
|
289
|
+
/*! exports provided: isCodecType, isCodecSupportedInMp4 */function(t,i,r){r.r(i);r.d(i,"isCodecType",(function(){return n}));r.d(i,"isCodecSupportedInMp4",(function(){return s}));var e={audio:{a3ds:true,"ac-3":true,"ac-4":true,alac:true,alaw:true,dra1:true,"dts+":true,"dts-":true,dtsc:true,dtse:true,dtsh:true,"ec-3":true,enca:true,g719:true,g726:true,m4ae:true,mha1:true,mha2:true,mhm1:true,mhm2:true,mlpa:true,mp4a:true,"raw ":true,Opus:true,samr:true,sawb:true,sawp:true,sevc:true,sqcp:true,ssmv:true,twos:true,ulaw:true},video:{avc1:true,avc2:true,avc3:true,avc4:true,avcp:true,av01:true,drac:true,dvav:true,dvhe:true,encv:true,hev1:true,hvc1:true,mjp2:true,mp4v:true,mvc1:true,mvc2:true,mvc3:true,mvc4:true,resv:true,rv60:true,s263:true,svc1:true,svc2:true,"vc-1":true,vp08:true,vp09:true},text:{stpp:true,wvtt:true}};function n(t,i){var r=e[i];return!!r&&r[t.slice(0,4)]===true}function s(t,i){return MediaSource.isTypeSupported((i||"video")+'/mp4;codecs="'+t+'"')}},"./src/utils/cues.ts":
|
|
290
|
+
/*!***************************!*\
|
|
291
|
+
!*** ./src/utils/cues.ts ***!
|
|
292
|
+
\***************************/
|
|
293
|
+
/*! exports provided: default */function(t,i,r){r.r(i);var e=r(/*! ./vttparser */"./src/utils/vttparser.ts");var n=r(/*! ./webvtt-parser */"./src/utils/webvtt-parser.ts");var s=r(/*! ./texttrack-utils */"./src/utils/texttrack-utils.ts");var a=/\s/;var u={newCue:function t(i,r,u,o){var f=[];var h;var l;var c;var v;var d;var m=self.VTTCue||self.TextTrackCue;for(var p=0;p<o.rows.length;p++){h=o.rows[p];c=true;v=0;d="";if(!h.isEmpty()){for(var g=0;g<h.chars.length;g++){if(a.test(h.chars[g].uchar)&&c){v++}else{d+=h.chars[g].uchar;c=false}}h.cueStartTime=r;if(r===u){u+=1e-4}if(v>=16){v--}else{v++}var b=Object(e["fixLineBreaks"])(d.trim());var y=Object(n["generateCueId"])(r,u,b);if(!i||!i.cues||!i.cues.getCueById(y)){l=new m(r,u,b);l.id=y;l.line=p+1;l.align="left";l.position=10+Math.min(80,Math.floor(v*8/32)*10);f.push(l)}}}if(i&&f.length){f.sort((function(t,i){if(t.line==="auto"||i.line==="auto"){return 0}if(t.line>8&&i.line>8){return i.line-t.line}return t.line-i.line}));f.forEach((function(t){return Object(s["addCueToTrack"])(i,t)}))}return f}};i["default"]=u},"./src/utils/discontinuities.ts":
|
|
294
|
+
/*!**************************************!*\
|
|
295
|
+
!*** ./src/utils/discontinuities.ts ***!
|
|
296
|
+
\**************************************/
|
|
297
|
+
/*! exports provided: findFirstFragWithCC, shouldAlignOnDiscontinuities, findDiscontinuousReferenceFrag, adjustSlidingStart, alignStream, alignPDT, alignFragmentByPDTDelta, alignMediaPlaylistByPDT */function(t,i,r){r.r(i);r.d(i,"findFirstFragWithCC",(function(){return a}));r.d(i,"shouldAlignOnDiscontinuities",(function(){return u}));r.d(i,"findDiscontinuousReferenceFrag",(function(){return o}));r.d(i,"adjustSlidingStart",(function(){return h}));r.d(i,"alignStream",(function(){return l}));r.d(i,"alignPDT",(function(){return v}));r.d(i,"alignFragmentByPDTDelta",(function(){return d}));r.d(i,"alignMediaPlaylistByPDT",(function(){return m}));var e=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");var n=r(/*! ./logger */"./src/utils/logger.ts");var s=r(/*! ../controller/level-helper */"./src/controller/level-helper.ts");function a(t,i){var r=null;for(var e=0,n=t.length;e<n;e++){var s=t[e];if(s&&s.cc===i){r=s;break}}return r}function u(t,i,r){if(i.details){if(r.endCC>r.startCC||t&&t.cc<r.startCC){return true}}return false}function o(t,i){var r=t.fragments;var e=i.fragments;if(!e.length||!r.length){n["logger"].log("No fragments to align");return}var s=a(r,e[0].cc);if(!s||s&&!s.startPTS){n["logger"].log("No frag in previous level to align on");return}return s}function f(t,i){if(t){var r=t.start+i;t.start=t.startPTS=r;t.endPTS=r+t.duration}}function h(t,i){var r=i.fragments;for(var e=0,n=r.length;e<n;e++){f(r[e],t)}if(i.fragmentHint){f(i.fragmentHint,t)}i.alignedSliding=true}function l(t,i,r){if(!i){return}c(t,r,i);if(!r.alignedSliding&&i.details){v(r,i.details)}if(!r.alignedSliding&&i.details&&!r.skippedSegments){Object(s["adjustSliding"])(i.details,r)}}function c(t,i,r){if(u(t,r,i)){var s=o(r.details,i);if(s&&Object(e["isFiniteNumber"])(s.start)){n["logger"].log("Adjusting PTS using last level due to CC increase within current level "+i.url);h(s.start,i)}}}function v(t,i){if(!i.fragments.length||!t.hasProgramDateTime||!i.hasProgramDateTime){return}var r=i.fragments[0].programDateTime;var s=t.fragments[0].programDateTime;var a=(s-r)/1e3+i.fragments[0].start;if(a&&Object(e["isFiniteNumber"])(a)){n["logger"].log("Adjusting PTS using programDateTime delta "+(s-r)+"ms, sliding:"+a.toFixed(3)+" "+t.url+" ");h(a,t)}}function d(t,i){var r=t.programDateTime;if(!r)return;var e=(r-i)/1e3;t.start=t.startPTS=e;t.endPTS=e+t.duration}function m(t,i){if(!i.fragments.length||!t.hasProgramDateTime||!i.hasProgramDateTime){return}var r=i.fragments[0].programDateTime;var e=i.fragments[0].start;var n=r-e*1e3;t.fragments.forEach((function(t){d(t,n)}));if(t.fragmentHint){d(t.fragmentHint,n)}t.alignedSliding=true}},"./src/utils/ewma-bandwidth-estimator.ts":
|
|
298
|
+
/*!***********************************************!*\
|
|
299
|
+
!*** ./src/utils/ewma-bandwidth-estimator.ts ***!
|
|
300
|
+
\***********************************************/
|
|
301
|
+
/*! exports provided: default */function(t,i,r){r.r(i);var e=r(/*! ../utils/ewma */"./src/utils/ewma.ts");var n=function(){function t(t,i,r){this.defaultEstimate_=void 0;this.minWeight_=void 0;this.minDelayMs_=void 0;this.slow_=void 0;this.fast_=void 0;this.defaultEstimate_=r;this.minWeight_=.001;this.minDelayMs_=50;this.slow_=new e["default"](t);this.fast_=new e["default"](i)}var i=t.prototype;i.update=function t(i,r){var n=this.slow_,s=this.fast_;if(this.slow_.halfLife!==i){this.slow_=new e["default"](i,n.getEstimate(),n.getTotalWeight())}if(this.fast_.halfLife!==r){this.fast_=new e["default"](r,s.getEstimate(),s.getTotalWeight())}};i.sample=function t(i,r){i=Math.max(i,this.minDelayMs_);var e=8*r;var n=i/1e3;var s=e/n;this.fast_.sample(n,s);this.slow_.sample(n,s)};i.canEstimate=function t(){var i=this.fast_;return i&&i.getTotalWeight()>=this.minWeight_};i.getEstimate=function t(){if(this.canEstimate()){return Math.min(this.fast_.getEstimate(),this.slow_.getEstimate())}else{return this.defaultEstimate_}};i.destroy=function t(){};return t}();i["default"]=n},"./src/utils/ewma.ts":
|
|
302
|
+
/*!***************************!*\
|
|
303
|
+
!*** ./src/utils/ewma.ts ***!
|
|
304
|
+
\***************************/
|
|
305
|
+
/*! exports provided: default */function(t,i,r){r.r(i);var e=function(){function t(t,i,r){if(i===void 0){i=0}if(r===void 0){r=0}this.halfLife=void 0;this.alpha_=void 0;this.estimate_=void 0;this.totalWeight_=void 0;this.halfLife=t;this.alpha_=t?Math.exp(Math.log(.5)/t):0;this.estimate_=i;this.totalWeight_=r}var i=t.prototype;i.sample=function t(i,r){var e=Math.pow(this.alpha_,i);this.estimate_=r*(1-e)+e*this.estimate_;this.totalWeight_+=i};i.getTotalWeight=function t(){return this.totalWeight_};i.getEstimate=function t(){if(this.alpha_){var i=1-Math.pow(this.alpha_,this.totalWeight_);if(i){return this.estimate_/i}}return this.estimate_};return t}();i["default"]=e},"./src/utils/fetch-loader.ts":
|
|
306
|
+
/*!***********************************!*\
|
|
307
|
+
!*** ./src/utils/fetch-loader.ts ***!
|
|
308
|
+
\***********************************/
|
|
309
|
+
/*! exports provided: fetchSupported, default */function(t,i,r){r.r(i);r.d(i,"fetchSupported",(function(){return d}));var e=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");var n=r(/*! ../loader/load-stats */"./src/loader/load-stats.ts");var s=r(/*! ../demux/chunk-cache */"./src/demux/chunk-cache.ts");function a(t,i){t.prototype=Object.create(i.prototype);t.prototype.constructor=t;l(t,i)}function u(t){var i=typeof Map==="function"?new Map:undefined;u=function t(r){if(r===null||!h(r))return r;if(typeof r!=="function"){throw new TypeError("Super expression must either be null or a function")}if(typeof i!=="undefined"){if(i.has(r))return i.get(r);i.set(r,e)}function e(){return o(r,arguments,c(this).constructor)}e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:false,writable:true,configurable:true}});return l(e,r)};return u(t)}function o(t,i,r){if(f()){o=Reflect.construct}else{o=function t(i,r,e){var n=[null];n.push.apply(n,r);var s=Function.bind.apply(i,n);var a=new s;if(e)l(a,e.prototype);return a}}return o.apply(null,arguments)}function f(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})));return true}catch(t){return false}}function h(t){return Function.toString.call(t).indexOf("[native code]")!==-1}function l(t,i){l=Object.setPrototypeOf||function t(i,r){i.__proto__=r;return i};return l(t,i)}function c(t){c=Object.setPrototypeOf?Object.getPrototypeOf:function t(i){return i.__proto__||Object.getPrototypeOf(i)};return c(t)}function v(){v=Object.assign||function(t){for(var i=1;i<arguments.length;i++){var r=arguments[i];for(var e in r){if(Object.prototype.hasOwnProperty.call(r,e)){t[e]=r[e]}}}return t};return v.apply(this,arguments)}function d(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request){try{new self.ReadableStream({});return true}catch(t){}}return false}var m=function(){function t(t){this.fetchSetup=void 0;this.requestTimeout=void 0;this.request=void 0;this.response=void 0;this.controller=void 0;this.context=void 0;this.config=null;this.callbacks=null;this.stats=void 0;this.loader=null;this.fetchSetup=t.fetchSetup||g;this.controller=new self.AbortController;this.stats=new n["LoadStats"]}var i=t.prototype;i.destroy=function t(){this.loader=this.callbacks=null;this.abortInternal()};i.abortInternal=function t(){var i=this.response;if(!i||!i.ok){this.stats.aborted=true;this.controller.abort()}};i.abort=function t(){var i;this.abortInternal();if((i=this.callbacks)!==null&&i!==void 0&&i.onAbort){this.callbacks.onAbort(this.stats,this.context,this.response)}};i.load=function t(i,r,n){var s=this;var a=this.stats;if(a.loading.start){throw new Error("Loader can only be used once.")}a.loading.start=self.performance.now();var u=p(i,this.controller.signal);var o=n.onProgress;var f=i.responseType==="arraybuffer";var h=f?"byteLength":"length";this.context=i;this.config=r;this.callbacks=n;this.request=this.fetchSetup(i,u);self.clearTimeout(this.requestTimeout);this.requestTimeout=self.setTimeout((function(){s.abortInternal();n.onTimeout(a,i,s.response)}),r.timeout);self.fetch(this.request).then((function(t){s.response=s.loader=t;if(!t.ok){var n=t.status,u=t.statusText;throw new b(u||"fetch, bad network response",n,t)}a.loading.first=Math.max(self.performance.now(),a.loading.start);a.total=parseInt(t.headers.get("Content-Length")||"0");if(o&&Object(e["isFiniteNumber"])(r.highWaterMark)){return s.loadProgressively(t,a,i,r.highWaterMark,o)}if(f){return t.arrayBuffer()}return t.text()})).then((function(t){var u=s.response;self.clearTimeout(s.requestTimeout);a.loading.end=Math.max(self.performance.now(),a.loading.first);a.loaded=a.total=t[h];var f={url:u.url,data:t};if(o&&!Object(e["isFiniteNumber"])(r.highWaterMark)){o(a,i,t,u)}n.onSuccess(f,a,i,u)})).catch((function(t){self.clearTimeout(s.requestTimeout);if(a.aborted){return}var r=t.code||0;n.onError({code:r,text:t.message},i,t.details)}))};i.getCacheAge=function t(){var i=null;if(this.response){var r=this.response.headers.get("age");i=r?parseFloat(r):null}return i};i.loadProgressively=function t(i,r,e,n,a){if(n===void 0){n=0}var u=new s["default"];var o=i.body.getReader();var f=function t(){return o.read().then((function(s){if(s.done){if(u.dataLength){a(r,e,u.flush(),i)}return Promise.resolve(new ArrayBuffer(0))}var o=s.value;var f=o.length;r.loaded+=f;if(f<n||u.dataLength){u.push(o);if(u.dataLength>=n){a(r,e,u.flush(),i)}}else{a(r,e,o,i)}return t()})).catch((function(){return Promise.reject()}))};return f()};return t}();function p(t,i){var r={method:"GET",mode:"cors",credentials:"same-origin",signal:i,headers:new self.Headers(v({},t.headers))};if(t.rangeEnd){r.headers.set("Range","bytes="+t.rangeStart+"-"+String(t.rangeEnd-1))}return r}function g(t,i){return new self.Request(t.url,i)}var b=function(t){a(i,t);function i(i,r,e){var n;n=t.call(this,i)||this;n.code=void 0;n.details=void 0;n.code=r;n.details=e;return n}return i}(u(Error));i["default"]=m},"./src/utils/imsc1-ttml-parser.ts":
|
|
310
|
+
/*!****************************************!*\
|
|
311
|
+
!*** ./src/utils/imsc1-ttml-parser.ts ***!
|
|
312
|
+
\****************************************/
|
|
313
|
+
/*! exports provided: IMSC1_CODEC, parseIMSC1 */function(t,i,r){r.r(i);r.d(i,"IMSC1_CODEC",(function(){return h}));r.d(i,"parseIMSC1",(function(){return d}));var e=r(/*! ./mp4-tools */"./src/utils/mp4-tools.ts");var n=r(/*! ./vttparser */"./src/utils/vttparser.ts");var s=r(/*! ./vttcue */"./src/utils/vttcue.ts");var a=r(/*! ../demux/id3 */"./src/demux/id3.ts");var u=r(/*! ./timescale-conversion */"./src/utils/timescale-conversion.ts");var o=r(/*! ./webvtt-parser */"./src/utils/webvtt-parser.ts");function f(){f=Object.assign||function(t){for(var i=1;i<arguments.length;i++){var r=arguments[i];for(var e in r){if(Object.prototype.hasOwnProperty.call(r,e)){t[e]=r[e]}}}return t};return f.apply(this,arguments)}var h="stpp.ttml.im1t";var l=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/;var c=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/;var v={left:"start",center:"center",right:"end",start:"start",end:"end"};function d(t,i,r,n,s){var o=Object(e["findBox"])(new Uint8Array(t),["mdat"]);if(o.length===0){s(new Error("Could not parse IMSC1 mdat"));return}var f=o[0];var h=Object(a["utf8ArrayToStr"])(new Uint8Array(t,f.start,f.end-f.start));var l=Object(u["toTimescaleFromScale"])(i,1,r);try{n(m(h,l))}catch(t){s(t)}}function m(t,i){var r=new DOMParser;var e=r.parseFromString(t,"text/xml");var n=e.getElementsByTagName("tt")[0];if(!n){throw new Error("Invalid ttml")}var a={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0};var u=Object.keys(a).reduce((function(t,i){t[i]=n.getAttribute("ttp:"+i)||a[i];return t}),{});var h=n.getAttribute("xml:space")!=="preserve";var l=g(p(n,"styling","style"));var c=g(p(n,"layout","region"));var d=p(n,"body","[begin]");return[].map.call(d,(function(t){var r=b(t,h);if(!r||!t.hasAttribute("begin")){return null}var e=k(t.getAttribute("begin"),u);var n=k(t.getAttribute("dur"),u);var a=k(t.getAttribute("end"),u);if(e===null){throw A(t)}if(a===null){if(n===null){throw A(t)}a=e+n}var d=new s["default"](e-i,a-i,r);d.id=Object(o["generateCueId"])(d.startTime,d.endTime,d.text);var m=c[t.getAttribute("region")];var p=l[t.getAttribute("style")];d.position=10;d.size=80;var g=y(m,p);var w=g.textAlign;if(w){var T=v[w];if(T){d.lineAlign=T}d.align=w}f(d,g);return d})).filter((function(t){return t!==null}))}function p(t,i,r){var e=t.getElementsByTagName(i)[0];if(e){return[].slice.call(e.querySelectorAll(r))}return[]}function g(t){return t.reduce((function(t,i){var r=i.getAttribute("xml:id");if(r){t[r]=i}return t}),{})}function b(t,i){return[].slice.call(t.childNodes).reduce((function(t,r,e){var n;if(r.nodeName==="br"&&e){return t+"\n"}if((n=r.childNodes)!==null&&n!==void 0&&n.length){return b(r,i)}else if(i){return t+r.textContent.trim().replace(/\s+/g," ")}return t+r.textContent}),"")}function y(t,i){var r="http://www.w3.org/ns/ttml#styling";var e=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"];return e.reduce((function(e,n){var s=w(i,r,n)||w(t,r,n);if(s){e[n]=s}return e}),{})}function w(t,i,r){return t.hasAttributeNS(i,r)?t.getAttributeNS(i,r):null}function A(t){return new Error("Could not parse ttml timestamp "+t)}function k(t,i){if(!t){return null}var r=Object(n["parseTimeStamp"])(t);if(r===null){if(l.test(t)){r=T(t,i)}else if(c.test(t)){r=E(t,i)}}return r}function T(t,i){var r=l.exec(t);var e=(r[4]|0)+(r[5]|0)/i.subFrameRate;return(r[1]|0)*3600+(r[2]|0)*60+(r[3]|0)+e/i.frameRate}function E(t,i){var r=c.exec(t);var e=Number(r[1]);var n=r[2];switch(n){case"h":return e*3600;case"m":return e*60;case"ms":return e*1e3;case"f":return e/i.frameRate;case"t":return e/i.tickRate}return e}},"./src/utils/logger.ts":
|
|
314
|
+
/*!*****************************!*\
|
|
315
|
+
!*** ./src/utils/logger.ts ***!
|
|
316
|
+
\*****************************/
|
|
317
|
+
/*! exports provided: enableLogs, logger */function(t,i,r){r.r(i);r.d(i,"enableLogs",(function(){return o}));r.d(i,"logger",(function(){return f}));var e=function t(){};var n={trace:e,debug:e,log:e,warn:e,info:e,error:e};var s=n;function a(t){var i=self.console[t];if(i){return i.bind(self.console,"["+t+"] >")}return e}function u(t){for(var i=arguments.length,r=new Array(i>1?i-1:0),e=1;e<i;e++){r[e-1]=arguments[e]}r.forEach((function(i){s[i]=t[i]?t[i].bind(t):a(i)}))}function o(t){if(self.console&&t===true||typeof t==="object"){u(t,"debug","log","info","warn","error");try{s.log()}catch(t){s=n}}else{s=n}}var f=s},"./src/utils/mediakeys-helper.ts":
|
|
318
|
+
/*!***************************************!*\
|
|
319
|
+
!*** ./src/utils/mediakeys-helper.ts ***!
|
|
320
|
+
\***************************************/
|
|
321
|
+
/*! exports provided: KeySystems, requestMediaKeySystemAccess */function(t,i,r){r.r(i);r.d(i,"KeySystems",(function(){return e}));r.d(i,"requestMediaKeySystemAccess",(function(){return n}));var e;(function(t){t["WIDEVINE"]="com.widevine.alpha";t["PLAYREADY"]="com.microsoft.playready"})(e||(e={}));var n=function(){if(typeof self!=="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess){return self.navigator.requestMediaKeySystemAccess.bind(self.navigator)}else{return null}}()},"./src/utils/mediasource-helper.ts":
|
|
322
|
+
/*!*****************************************!*\
|
|
323
|
+
!*** ./src/utils/mediasource-helper.ts ***!
|
|
324
|
+
\*****************************************/
|
|
325
|
+
/*! exports provided: getMediaSource */function(t,i,r){r.r(i);r.d(i,"getMediaSource",(function(){return e}));function e(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":
|
|
326
|
+
/*!********************************!*\
|
|
327
|
+
!*** ./src/utils/mp4-tools.ts ***!
|
|
328
|
+
\********************************/
|
|
329
|
+
/*! exports provided: bin2str, readUint16, readUint32, writeUint32, findBox, parseSegmentIndex, parseInitSegment, getStartDTS, getDuration, computeRawDurationFromSamples, offsetStartDTS, segmentValidRange, appendUint8Array */function(t,i,r){r.r(i);r.d(i,"bin2str",(function(){return u}));r.d(i,"readUint16",(function(){return o}));r.d(i,"readUint32",(function(){return f}));r.d(i,"writeUint32",(function(){return h}));r.d(i,"findBox",(function(){return l}));r.d(i,"parseSegmentIndex",(function(){return c}));r.d(i,"parseInitSegment",(function(){return v}));r.d(i,"getStartDTS",(function(){return d}));r.d(i,"getDuration",(function(){return m}));r.d(i,"computeRawDurationFromSamples",(function(){return p}));r.d(i,"offsetStartDTS",(function(){return g}));r.d(i,"segmentValidRange",(function(){return b}));r.d(i,"appendUint8Array",(function(){return y}));var e=r(/*! ./typed-array */"./src/utils/typed-array.ts");var n=r(/*! ../loader/fragment */"./src/loader/fragment.ts");var s=Math.pow(2,32)-1;var a=[].push;function u(t){return String.fromCharCode.apply(null,t)}function o(t,i){if("data"in t){i+=t.start;t=t.data}var r=t[i]<<8|t[i+1];return r<0?65536+r:r}function f(t,i){if("data"in t){i+=t.start;t=t.data}var r=t[i]<<24|t[i+1]<<16|t[i+2]<<8|t[i+3];return r<0?4294967296+r:r}function h(t,i,r){if("data"in t){i+=t.start;t=t.data}t[i]=r>>24;t[i+1]=r>>16&255;t[i+2]=r>>8&255;t[i+3]=r&255}function l(t,i){var r=[];if(!i.length){return r}var e;var n;var s;if("data"in t){e=t.data;n=t.start;s=t.end}else{e=t;n=0;s=e.byteLength}for(var o=n;o<s;){var h=f(e,o);var c=u(e.subarray(o+4,o+8));var v=h>1?o+h:s;if(c===i[0]){if(i.length===1){r.push({data:e,start:o+8,end:v})}else{var d=l({data:e,start:o+8,end:v},i.slice(1));if(d.length){a.apply(r,d)}}}o=v}return r}function c(t){var i=l(t,["moov"]);var r=i[0];var e=r?r.end:null;var n=l(t,["sidx"]);if(!n||!n[0]){return null}var s=[];var a=n[0];var u=a.data[0];var h=u===0?8:16;var c=f(a,h);h+=4;var v=0;var d=0;if(u===0){h+=8}else{h+=16}h+=2;var m=a.end+d;var p=o(a,h);h+=2;for(var g=0;g<p;g++){var b=h;var y=f(a,b);b+=4;var w=y&2147483647;var A=(y&2147483648)>>>31;if(A===1){console.warn("SIDX has hierarchical references (not supported)");return null}var k=f(a,b);b+=4;s.push({referenceSize:w,subsegmentDuration:k,info:{duration:k/c,start:m,end:m+w-1}});m+=w;b+=4;h=b}return{earliestPresentationTime:v,timescale:c,version:u,referencesCount:p,references:s,moovEndOffset:e}}function v(t){var i=[];var r=l(t,["moov","trak"]);for(var e=0;e<r.length;e++){var s=r[e];var a=l(s,["tkhd"])[0];if(a){var o=a.data[a.start];var h=o===0?12:20;var c=f(a,h);var v=l(s,["mdia","mdhd"])[0];if(v){o=v.data[v.start];h=o===0?12:20;var d=f(v,h);var m=l(s,["mdia","hdlr"])[0];if(m){var p=u(m.data.subarray(m.start+8,m.start+12));var g={soun:n["ElementaryStreamTypes"].AUDIO,vide:n["ElementaryStreamTypes"].VIDEO}[p];if(g){var b=l(s,["mdia","minf","stbl","stsd"])[0];var y=void 0;if(b){y=u(b.data.subarray(b.start+12,b.start+16))}i[c]={timescale:d,type:g};i[g]={timescale:d,id:c,codec:y}}}}}}var w=l(t,["moov","mvex","trex"]);w.forEach((function(t){var r=f(t,4);var e=i[r];if(e){e.default={duration:f(t,12),flags:f(t,20)}}}));return i}function d(t,i){return l(i,["moof","traf"]).reduce((function(i,r){var e=l(r,["tfdt"])[0];var n=e.data[e.start];var s=l(r,["tfhd"]).reduce((function(i,r){var s=f(r,4);var a=t[s];if(a){var u=f(e,4);if(n===1){u*=Math.pow(2,32);u+=f(e,8)}var o=a.timescale||9e4;var h=u/o;if(isFinite(h)&&(i===null||h<i)){return h}}return i}),null);if(s!==null&&isFinite(s)&&(i===null||s<i)){return s}return i}),null)||0}function m(t,i){var r=0;var e=0;var s=0;var a=l(t,["moof","traf"]);for(var u=0;u<a.length;u++){var o=a[u];var h=l(o,["tfhd"])[0];var v=f(h,4);var d=i[v];if(!d){continue}var m=d.default;var g=f(h,0)|(m===null||m===void 0?void 0:m.flags);var b=m===null||m===void 0?void 0:m.duration;if(g&8){if(g&2){b=f(h,12)}else{b=f(h,8)}}var y=d.timescale||9e4;var w=l(o,["trun"]);for(var A=0;A<w.length;A++){r=p(w[A]);if(!r&&b){var k=f(w[A],4);r=b*k}if(d.type===n["ElementaryStreamTypes"].VIDEO){e+=r/y}else if(d.type===n["ElementaryStreamTypes"].AUDIO){s+=r/y}}}if(e===0&&s===0){var T=c(t);if(T!==null&&T!==void 0&&T.references){return T.references.reduce((function(t,i){return t+i.info.duration||0}),0)}}if(e){return e}return s}function p(t){var i=f(t,0);var r=8;if(i&1){r+=4}if(i&4){r+=4}var e=0;var n=f(t,4);for(var s=0;s<n;s++){if(i&256){var a=f(t,r);e+=a;r+=4}if(i&512){r+=4}if(i&1024){r+=4}if(i&2048){r+=4}}return e}function g(t,i,r){l(i,["moof","traf"]).forEach((function(i){l(i,["tfhd"]).forEach((function(e){var n=f(e,4);var a=t[n];if(!a){return}var u=a.timescale||9e4;l(i,["tfdt"]).forEach((function(t){var i=t.data[t.start];var e=f(t,4);if(i===0){h(t,4,e-r*u)}else{e*=Math.pow(2,32);e+=f(t,8);e-=r*u;e=Math.max(e,0);var n=Math.floor(e/(s+1));var a=Math.floor(e%(s+1));h(t,4,n);h(t,8,a)}}))}))}))}function b(t){var i={valid:null,remainder:null};var r=l(t,["moof"]);if(!r){return i}else if(r.length<2){i.remainder=t;return i}var n=r[r.length-1];i.valid=Object(e["sliceUint8"])(t,0,n.start-8);i.remainder=Object(e["sliceUint8"])(t,n.start-8);return i}function y(t,i){var r=new Uint8Array(t.length+i.length);r.set(t);r.set(i,t.length);return r}},"./src/utils/output-filter.ts":
|
|
330
|
+
/*!************************************!*\
|
|
331
|
+
!*** ./src/utils/output-filter.ts ***!
|
|
332
|
+
\************************************/
|
|
333
|
+
/*! exports provided: default */function(t,i,r){r.r(i);r.d(i,"default",(function(){return e}));var e=function(){function t(t,i){this.timelineController=void 0;this.cueRanges=[];this.trackName=void 0;this.startTime=null;this.endTime=null;this.screen=null;this.timelineController=t;this.trackName=i}var i=t.prototype;i.dispatchCue=function t(){if(this.startTime===null){return}this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges);this.startTime=null};i.newCue=function t(i,r,e){if(this.startTime===null||this.startTime>i){this.startTime=i}this.endTime=r;this.screen=e;this.timelineController.createCaptionsTrack(this.trackName)};i.reset=function t(){this.cueRanges=[];this.startTime=null};return t}()},"./src/utils/texttrack-utils.ts":
|
|
334
|
+
/*!**************************************!*\
|
|
335
|
+
!*** ./src/utils/texttrack-utils.ts ***!
|
|
336
|
+
\**************************************/
|
|
337
|
+
/*! exports provided: sendAddTrackEvent, addCueToTrack, clearCurrentCues, removeCuesInRange, getCuesInRange */function(t,i,r){r.r(i);r.d(i,"sendAddTrackEvent",(function(){return n}));r.d(i,"addCueToTrack",(function(){return s}));r.d(i,"clearCurrentCues",(function(){return a}));r.d(i,"removeCuesInRange",(function(){return u}));r.d(i,"getCuesInRange",(function(){return f}));var e=r(/*! ./logger */"./src/utils/logger.ts");function n(t,i){var r;try{r=new Event("addtrack")}catch(t){r=document.createEvent("Event");r.initEvent("addtrack",false,false)}r.track=t;i.dispatchEvent(r)}function s(t,i){var r=t.mode;if(r==="disabled"){t.mode="hidden"}if(t.cues&&!t.cues.getCueById(i.id)){try{t.addCue(i);if(!t.cues.getCueById(i.id)){throw new Error("addCue is failed for: "+i)}}catch(r){e["logger"].debug("[texttrack-utils]: "+r);var n=new self.TextTrackCue(i.startTime,i.endTime,i.text);n.id=i.id;t.addCue(n)}}if(r==="disabled"){t.mode=r}}function a(t){var i=t.mode;if(i==="disabled"){t.mode="hidden"}if(t.cues){for(var r=t.cues.length;r--;){t.removeCue(t.cues[r])}}if(i==="disabled"){t.mode=i}}function u(t,i,r){var e=t.mode;if(e==="disabled"){t.mode="hidden"}if(t.cues&&t.cues.length>0){var n=f(t.cues,i,r);for(var s=0;s<n.length;s++){t.removeCue(n[s])}}if(e==="disabled"){t.mode=e}}function o(t,i){if(i<t[0].startTime){return 0}var r=t.length-1;if(i>t[r].endTime){return-1}var e=0;var n=r;while(e<=n){var s=Math.floor((n+e)/2);if(i<t[s].startTime){n=s-1}else if(i>t[s].startTime&&e<r){e=s+1}else{return s}}return t[e].startTime-i<i-t[n].startTime?e:n}function f(t,i,r){var e=[];var n=o(t,i);if(n>-1){for(var s=n,a=t.length;s<a;s++){var u=t[s];if(u.startTime>=i&&u.endTime<=r){e.push(u)}else if(u.startTime>r){return e}}}return e}},"./src/utils/time-ranges.ts":
|
|
338
|
+
/*!**********************************!*\
|
|
339
|
+
!*** ./src/utils/time-ranges.ts ***!
|
|
340
|
+
\**********************************/
|
|
341
|
+
/*! exports provided: default */function(t,i,r){r.r(i);var e={toString:function t(i){var r="";var e=i.length;for(var n=0;n<e;n++){r+="["+i.start(n).toFixed(3)+","+i.end(n).toFixed(3)+"]"}return r}};i["default"]=e},"./src/utils/timescale-conversion.ts":
|
|
342
|
+
/*!*******************************************!*\
|
|
343
|
+
!*** ./src/utils/timescale-conversion.ts ***!
|
|
344
|
+
\*******************************************/
|
|
345
|
+
/*! exports provided: toTimescaleFromBase, toTimescaleFromScale, toMsFromMpegTsClock, toMpegTsClockFromTimescale */function(t,i,r){r.r(i);r.d(i,"toTimescaleFromBase",(function(){return n}));r.d(i,"toTimescaleFromScale",(function(){return s}));r.d(i,"toMsFromMpegTsClock",(function(){return a}));r.d(i,"toMpegTsClockFromTimescale",(function(){return u}));var e=9e4;function n(t,i,r,e){if(r===void 0){r=1}if(e===void 0){e=false}var n=t*i*r;return e?Math.round(n):n}function s(t,i,r,e){if(r===void 0){r=1}if(e===void 0){e=false}return n(t,i,1/r,e)}function a(t,i){if(i===void 0){i=false}return n(t,1e3,1/e,i)}function u(t,i){if(i===void 0){i=1}return n(t,e,1/i)}},"./src/utils/typed-array.ts":
|
|
346
|
+
/*!**********************************!*\
|
|
347
|
+
!*** ./src/utils/typed-array.ts ***!
|
|
348
|
+
\**********************************/
|
|
349
|
+
/*! exports provided: sliceUint8 */function(t,i,r){r.r(i);r.d(i,"sliceUint8",(function(){return e}));function e(t,i,r){return Uint8Array.prototype.slice?t.slice(i,r):new Uint8Array(Array.prototype.slice.call(t,i,r))}},"./src/utils/vttcue.ts":
|
|
350
|
+
/*!*****************************!*\
|
|
351
|
+
!*** ./src/utils/vttcue.ts ***!
|
|
352
|
+
\*****************************/
|
|
353
|
+
/*! exports provided: default */function(t,i,r){r.r(i);i["default"]=function(){if(typeof self!=="undefined"&&self.VTTCue){return self.VTTCue}var t=["","lr","rl"];var i=["start","middle","end","left","right"];function r(t,i){if(typeof i!=="string"){return false}if(!Array.isArray(t)){return false}var r=i.toLowerCase();if(~t.indexOf(r)){return r}return false}function e(i){return r(t,i)}function n(t){return r(i,t)}function s(t){for(var i=arguments.length,r=new Array(i>1?i-1:0),e=1;e<i;e++){r[e-1]=arguments[e]}var n=1;for(;n<arguments.length;n++){var s=arguments[n];for(var a in s){t[a]=s[a]}}return t}function a(t,i,r){var a=this;var u={enumerable:true};a.hasBeenReset=false;var o="";var f=false;var h=t;var l=i;var c=r;var v=null;var d="";var m=true;var p="auto";var g="start";var b=50;var y="middle";var w=50;var A="middle";Object.defineProperty(a,"id",s({},u,{get:function t(){return o},set:function t(i){o=""+i}}));Object.defineProperty(a,"pauseOnExit",s({},u,{get:function t(){return f},set:function t(i){f=!!i}}));Object.defineProperty(a,"startTime",s({},u,{get:function t(){return h},set:function t(i){if(typeof i!=="number"){throw new TypeError("Start time must be set to a number.")}h=i;this.hasBeenReset=true}}));Object.defineProperty(a,"endTime",s({},u,{get:function t(){return l},set:function t(i){if(typeof i!=="number"){throw new TypeError("End time must be set to a number.")}l=i;this.hasBeenReset=true}}));Object.defineProperty(a,"text",s({},u,{get:function t(){return c},set:function t(i){c=""+i;this.hasBeenReset=true}}));Object.defineProperty(a,"region",s({},u,{get:function t(){return v},set:function t(i){v=i;this.hasBeenReset=true}}));Object.defineProperty(a,"vertical",s({},u,{get:function t(){return d},set:function t(i){var r=e(i);if(r===false){throw new SyntaxError("An invalid or illegal string was specified.")}d=r;this.hasBeenReset=true}}));Object.defineProperty(a,"snapToLines",s({},u,{get:function t(){return m},set:function t(i){m=!!i;this.hasBeenReset=true}}));Object.defineProperty(a,"line",s({},u,{get:function t(){return p},set:function t(i){if(typeof i!=="number"&&i!=="auto"){throw new SyntaxError("An invalid number or illegal string was specified.")}p=i;this.hasBeenReset=true}}));Object.defineProperty(a,"lineAlign",s({},u,{get:function t(){return g},set:function t(i){var r=n(i);if(!r){throw new SyntaxError("An invalid or illegal string was specified.")}g=r;this.hasBeenReset=true}}));Object.defineProperty(a,"position",s({},u,{get:function t(){return b},set:function t(i){if(i<0||i>100){throw new Error("Position must be between 0 and 100.")}b=i;this.hasBeenReset=true}}));Object.defineProperty(a,"positionAlign",s({},u,{get:function t(){return y},set:function t(i){var r=n(i);if(!r){throw new SyntaxError("An invalid or illegal string was specified.")}y=r;this.hasBeenReset=true}}));Object.defineProperty(a,"size",s({},u,{get:function t(){return w},set:function t(i){if(i<0||i>100){throw new Error("Size must be between 0 and 100.")}w=i;this.hasBeenReset=true}}));Object.defineProperty(a,"align",s({},u,{get:function t(){return A},set:function t(i){var r=n(i);if(!r){throw new SyntaxError("An invalid or illegal string was specified.")}A=r;this.hasBeenReset=true}}));a.displayState=undefined}a.prototype.getCueAsHTML=function(){var t=self.WebVTT;return t.convertCueToDOMTree(self,this.text)};return a}()},"./src/utils/vttparser.ts":
|
|
354
|
+
/*!********************************!*\
|
|
355
|
+
!*** ./src/utils/vttparser.ts ***!
|
|
356
|
+
\********************************/
|
|
357
|
+
/*! exports provided: parseTimeStamp, fixLineBreaks, VTTParser */function(t,i,r){r.r(i);r.d(i,"parseTimeStamp",(function(){return s}));r.d(i,"fixLineBreaks",(function(){return l}));r.d(i,"VTTParser",(function(){return c}));var e=r(/*! ./vttcue */"./src/utils/vttcue.ts");var n=function(){function t(){}var i=t.prototype;i.decode=function t(i,r){if(!i){return""}if(typeof i!=="string"){throw new Error("Error - expected string data.")}return decodeURIComponent(encodeURIComponent(i))};return t}();function s(t){function i(t,i,r,e){return(t|0)*3600+(i|0)*60+(r|0)+parseFloat(e||0)}var r=t.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);if(!r){return null}if(parseFloat(r[2])>59){return i(r[2],r[3],0,r[4])}return i(r[1],r[2],r[3],r[4])}var a=function(){function t(){this.values=Object.create(null)}var i=t.prototype;i.set=function t(i,r){if(!this.get(i)&&r!==""){this.values[i]=r}};i.get=function t(i,r,e){if(e){return this.has(i)?this.values[i]:r[e]}return this.has(i)?this.values[i]:r};i.has=function t(i){return i in this.values};i.alt=function t(i,r,e){for(var n=0;n<e.length;++n){if(r===e[n]){this.set(i,r);break}}};i.integer=function t(i,r){if(/^-?\d+$/.test(r)){this.set(i,parseInt(r,10))}};i.percent=function t(i,r){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(r)){var t=parseFloat(r);if(t>=0&&t<=100){this.set(i,t);return true}}return false};return t}();function u(t,i,r,e){var n=e?t.split(e):[t];for(var s in n){if(typeof n[s]!=="string"){continue}var a=n[s].split(r);if(a.length!==2){continue}var u=a[0];var o=a[1];i(u,o)}}var o=new e["default"](0,0,"");var f=o.align==="middle"?"middle":"center";function h(t,i,r){var e=t;function n(){var i=s(t);if(i===null){throw new Error("Malformed timestamp: "+e)}t=t.replace(/^[^\sa-zA-Z-]+/,"");return i}function h(t,i){var e=new a;u(t,(function(t,i){var n;switch(t){case"region":for(var s=r.length-1;s>=0;s--){if(r[s].id===i){e.set(t,r[s].region);break}}break;case"vertical":e.alt(t,i,["rl","lr"]);break;case"line":n=i.split(",");e.integer(t,n[0]);if(e.percent(t,n[0])){e.set("snapToLines",false)}e.alt(t,n[0],["auto"]);if(n.length===2){e.alt("lineAlign",n[1],["start",f,"end"])}break;case"position":n=i.split(",");e.percent(t,n[0]);if(n.length===2){e.alt("positionAlign",n[1],["start",f,"end","line-left","line-right","auto"])}break;case"size":e.percent(t,i);break;case"align":e.alt(t,i,["start",f,"end","left","right"]);break}}),/:/,/\s/);i.region=e.get("region",null);i.vertical=e.get("vertical","");var n=e.get("line","auto");if(n==="auto"&&o.line===-1){n=-1}i.line=n;i.lineAlign=e.get("lineAlign","start");i.snapToLines=e.get("snapToLines",true);i.size=e.get("size",100);i.align=e.get("align",f);var s=e.get("position","auto");if(s==="auto"&&o.position===50){s=i.align==="start"||i.align==="left"?0:i.align==="end"||i.align==="right"?100:50}i.position=s}function l(){t=t.replace(/^\s+/,"")}l();i.startTime=n();l();if(t.substr(0,3)!=="--\x3e"){throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+e)}t=t.substr(3);l();i.endTime=n();l();h(t,i)}function l(t){return t.replace(/<br(?: \/)?>/gi,"\n")}var c=function(){function t(){this.state="INITIAL";this.buffer="";this.decoder=new n;this.regionList=[];this.cue=null;this.oncue=void 0;this.onparsingerror=void 0;this.onflush=void 0}var i=t.prototype;i.parse=function t(i){var r=this;if(i){r.buffer+=r.decoder.decode(i,{stream:true})}function n(){var t=r.buffer;var i=0;t=l(t);while(i<t.length&&t[i]!=="\r"&&t[i]!=="\n"){++i}var e=t.substr(0,i);if(t[i]==="\r"){++i}if(t[i]==="\n"){++i}r.buffer=t.substr(i);return e}function s(t){u(t,(function(t,i){}),/:/)}try{var a="";if(r.state==="INITIAL"){if(!/\r\n|\n/.test(r.buffer)){return this}a=n();var o=a.match(/^()?WEBVTT([ \t].*)?$/);if(!o||!o[0]){throw new Error("Malformed WebVTT signature.")}r.state="HEADER"}var f=false;while(r.buffer){if(!/\r\n|\n/.test(r.buffer)){return this}if(!f){a=n()}else{f=false}switch(r.state){case"HEADER":if(/:/.test(a)){s(a)}else if(!a){r.state="ID"}continue;case"NOTE":if(!a){r.state="ID"}continue;case"ID":if(/^NOTE($|[ \t])/.test(a)){r.state="NOTE";break}if(!a){continue}r.cue=new e["default"](0,0,"");r.state="CUE";if(a.indexOf("--\x3e")===-1){r.cue.id=a;continue}case"CUE":if(!r.cue){r.state="BADCUE";continue}try{h(a,r.cue,r.regionList)}catch(t){r.cue=null;r.state="BADCUE";continue}r.state="CUETEXT";continue;case"CUETEXT":{var c=a.indexOf("--\x3e")!==-1;if(!a||c&&(f=true)){if(r.oncue&&r.cue){r.oncue(r.cue)}r.cue=null;r.state="ID";continue}if(r.cue===null){continue}if(r.cue.text){r.cue.text+="\n"}r.cue.text+=a}continue;case"BADCUE":if(!a){r.state="ID"}}}}catch(t){if(r.state==="CUETEXT"&&r.cue&&r.oncue){r.oncue(r.cue)}r.cue=null;r.state=r.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this};i.flush=function t(){var i=this;try{if(i.cue||i.state==="HEADER"){i.buffer+="\n\n";i.parse()}if(i.state==="INITIAL"||i.state==="BADWEBVTT"){throw new Error("Malformed WebVTT signature.")}}catch(t){if(i.onparsingerror){i.onparsingerror(t)}}if(i.onflush){i.onflush()}return this};return t}()},"./src/utils/webvtt-parser.ts":
|
|
358
|
+
/*!************************************!*\
|
|
359
|
+
!*** ./src/utils/webvtt-parser.ts ***!
|
|
360
|
+
\************************************/
|
|
361
|
+
/*! exports provided: generateCueId, parseWebVTT */function(t,i,r){r.r(i);r.d(i,"generateCueId",(function(){return c}));r.d(i,"parseWebVTT",(function(){return d}));var e=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");var n=r(/*! ./vttparser */"./src/utils/vttparser.ts");var s=r(/*! ../demux/id3 */"./src/demux/id3.ts");var a=r(/*! ./timescale-conversion */"./src/utils/timescale-conversion.ts");var u=r(/*! ../remux/mp4-remuxer */"./src/remux/mp4-remuxer.ts");var o=/\r\n|\n\r|\n|\r/g;var f=function t(i,r,e){if(e===void 0){e=0}return i.substr(e,r.length)===r};var h=function t(i){var r=parseInt(i.substr(-3));var n=parseInt(i.substr(-6,2));var s=parseInt(i.substr(-9,2));var a=i.length>9?parseInt(i.substr(0,i.indexOf(":"))):0;if(!Object(e["isFiniteNumber"])(r)||!Object(e["isFiniteNumber"])(n)||!Object(e["isFiniteNumber"])(s)||!Object(e["isFiniteNumber"])(a)){throw Error("Malformed X-TIMESTAMP-MAP: Local:"+i)}r+=1e3*n;r+=60*1e3*s;r+=60*60*1e3*a;return r};var l=function t(i){var t=5381;var r=i.length;while(r){t=t*33^i.charCodeAt(--r)}return(t>>>0).toString()};function c(t,i,r){return l(t.toString())+l(i.toString())+l(r)}var v=function t(i,r,e){var n=i[r];var s=i[n.prevCC];if(!s||!s.new&&n.new){i.ccOffset=i.presentationOffset=n.start;n.new=false;return}while((a=s)!==null&&a!==void 0&&a.new){var a;i.ccOffset+=n.start-s.start;n.new=false;n=s;s=i[n.prevCC]}i.presentationOffset=e};function d(t,i,r,e,l,d,m,p){var g=new n["VTTParser"];var b=Object(s["utf8ArrayToStr"])(new Uint8Array(t)).trim().replace(o,"\n").split("\n");var y=[];var w=Object(a["toMpegTsClockFromTimescale"])(i,r);var A="00:00.000";var k=0;var T=0;var E;var O=true;var S=false;g.oncue=function(t){var i=e[l];var r=e.ccOffset;var n=(k-w)/9e4;if(i!==null&&i!==void 0&&i.new){if(T!==undefined){r=e.ccOffset=i.start}else{v(e,l,n)}}if(n){r=n-e.presentationOffset}if(S){var s=t.endTime-t.startTime;var a=Object(u["normalizePts"])((t.startTime+r-T)*9e4,d*9e4)/9e4;t.startTime=a;t.endTime=a+s}var o=t.text.trim();t.text=decodeURIComponent(encodeURIComponent(o));if(!t.id){t.id=c(t.startTime,t.endTime,o)}if(t.endTime>0){y.push(t)}};g.onparsingerror=function(t){E=t};g.onflush=function(){if(E){p(E);return}m(y)};b.forEach((function(t){if(O){if(f(t,"X-TIMESTAMP-MAP=")){O=false;S=true;t.substr(16).split(",").forEach((function(t){if(f(t,"LOCAL:")){A=t.substr(6)}else if(f(t,"MPEGTS:")){k=parseInt(t.substr(7))}}));try{T=h(A)/1e3}catch(t){S=false;E=t}return}else if(t===""){O=false}}g.parse(t+"\n")}));g.flush()}},"./src/utils/xhr-loader.ts":
|
|
362
|
+
/*!*********************************!*\
|
|
363
|
+
!*** ./src/utils/xhr-loader.ts ***!
|
|
364
|
+
\*********************************/
|
|
365
|
+
/*! exports provided: default */function(t,i,r){r.r(i);var e=r(/*! ../utils/logger */"./src/utils/logger.ts");var n=r(/*! ../loader/load-stats */"./src/loader/load-stats.ts");var s=/^age:\s*[\d.]+\s*$/m;var a=function(){function t(t){this.xhrSetup=void 0;this.requestTimeout=void 0;this.retryTimeout=void 0;this.retryDelay=void 0;this.config=null;this.callbacks=null;this.context=void 0;this.loader=null;this.stats=void 0;this.xhrSetup=t?t.xhrSetup:null;this.stats=new n["LoadStats"];this.retryDelay=0}var i=t.prototype;i.destroy=function t(){this.callbacks=null;this.abortInternal();this.loader=null;this.config=null};i.abortInternal=function t(){var i=this.loader;self.clearTimeout(this.requestTimeout);self.clearTimeout(this.retryTimeout);if(i){i.onreadystatechange=null;i.onprogress=null;if(i.readyState!==4){this.stats.aborted=true;i.abort()}}};i.abort=function t(){var i;this.abortInternal();if((i=this.callbacks)!==null&&i!==void 0&&i.onAbort){this.callbacks.onAbort(this.stats,this.context,this.loader)}};i.load=function t(i,r,e){if(this.stats.loading.start){throw new Error("Loader can only be used once.")}this.stats.loading.start=self.performance.now();this.context=i;this.config=r;this.callbacks=e;this.retryDelay=r.retryDelay;this.loadInternal()};i.loadInternal=function t(){var i=this.config,r=this.context;if(!i){return}var e=this.loader=new self.XMLHttpRequest;var n=this.stats;n.loading.first=0;n.loaded=0;var s=this.xhrSetup;try{if(s){try{s(e,r.url)}catch(t){e.open("GET",r.url,true);s(e,r.url)}}if(!e.readyState){e.open("GET",r.url,true)}var a=this.context.headers;if(a){for(var u in a){e.setRequestHeader(u,a[u])}}}catch(t){this.callbacks.onError({code:e.status,text:t.message},r,e);return}if(r.rangeEnd){e.setRequestHeader("Range","bytes="+r.rangeStart+"-"+(r.rangeEnd-1))}e.onreadystatechange=this.readystatechange.bind(this);e.onprogress=this.loadprogress.bind(this);e.responseType=r.responseType;self.clearTimeout(this.requestTimeout);this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.timeout);e.send()};i.readystatechange=function t(){var i=this.context,r=this.loader,n=this.stats;if(!i||!r){return}var s=r.readyState;var a=this.config;if(n.aborted){return}if(s>=2){self.clearTimeout(this.requestTimeout);if(n.loading.first===0){n.loading.first=Math.max(self.performance.now(),n.loading.start)}if(s===4){r.onreadystatechange=null;r.onprogress=null;var u=r.status;if(u>=200&&u<300){n.loading.end=Math.max(self.performance.now(),n.loading.first);var o;var f;if(i.responseType==="arraybuffer"){o=r.response;f=o.byteLength}else{o=r.responseText;f=o.length}n.loaded=n.total=f;if(!this.callbacks){return}var h=this.callbacks.onProgress;if(h){h(n,i,o,r)}if(!this.callbacks){return}var l={url:r.responseURL,data:o};this.callbacks.onSuccess(l,n,i,r)}else{if(n.retry>=a.maxRetry||u>=400&&u<499){e["logger"].error(u+" while loading "+i.url);this.callbacks.onError({code:u,text:r.statusText},i,r)}else{e["logger"].warn(u+" while loading "+i.url+", retrying in "+this.retryDelay+"...");this.abortInternal();this.loader=null;self.clearTimeout(this.retryTimeout);this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay);this.retryDelay=Math.min(2*this.retryDelay,a.maxRetryDelay);n.retry++}}}else{self.clearTimeout(this.requestTimeout);this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),a.timeout)}}};i.loadtimeout=function t(){e["logger"].warn("timeout while loading "+this.context.url);var i=this.callbacks;if(i){this.abortInternal();i.onTimeout(this.stats,this.context,this.loader)}};i.loadprogress=function t(i){var r=this.stats;r.loaded=i.loaded;if(i.lengthComputable){r.total=i.total}};i.getCacheAge=function t(){var i=null;if(this.loader&&s.test(this.loader.getAllResponseHeaders())){var r=this.loader.getResponseHeader("age");i=r?parseFloat(r):null}return i};return t}();i["default"]=a}})["default"]}))}));const b=u(g);const y='.taro-video{display:inline-block;overflow:hidden;position:relative;width:100%;height:225px;line-height:0}.taro-video[hidden]{display:none}.taro-video-container{display:inline-block;position:absolute;left:0;top:0;width:100%;height:100%;background-color:#000;-o-object-position:inherit;object-position:inherit}.taro-video-container.taro-video-type-fullscreen{position:fixed;left:0;right:0;top:0;bottom:0;z-index:999}.taro-video-container.taro-video-type-fullscreen.taro-video-type-rotate-left{-webkit-transform:translate(-50%, -50%) rotate(-90deg);transform:translate(-50%, -50%) rotate(-90deg)}.taro-video-container.taro-video-type-fullscreen.taro-video-type-rotate-right{-webkit-transform:translate(-50%, -50%) rotate(90deg);transform:translate(-50%, -50%) rotate(90deg)}.taro-video-video{width:100%;height:100%;-o-object-position:inherit;object-position:inherit}.taro-video-cover{display:-ms-flexbox;display:flex;position:absolute;left:0;top:0;bottom:0;z-index:1;-ms-flex-direction:column;flex-direction:column;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center;width:100%;background-color:rgba(1, 1, 1, 0.5);-webkit-box-orient:vertical;-webkit-box-direction:normal;-webkit-box-pack:center;-webkit-box-align:center}.taro-video-cover-play-button{width:40px;height:40px;background-repeat:no-repeat;background-position:50% 50%;background-size:50%}.taro-video-cover-duration{margin-top:10px;line-height:1;font-size:16px;color:#fff}.taro-video-bar{display:-ms-flexbox;display:flex;visibility:hidden;overflow:hidden;position:absolute;right:0;bottom:0;z-index:1;-ms-flex-align:center;align-items:center;padding:0 10px;height:44px;background-color:rgba(0, 0, 0, 0.5);-webkit-box-align:center}.taro-video-bar.taro-video-bar-full{left:0}.taro-video-controls{display:-ms-flexbox;display:flex;-webkit-box-flex:1;-ms-flex-positive:1;flex-grow:1;margin:0 8.5px}.taro-video-control-button{-webkit-box-sizing:content-box;box-sizing:content-box;margin-left:-8.5px;padding:14.5px 12.5px;width:13px;height:15px}.taro-video-control-button::after{display:block;width:100%;height:100%;background-repeat:no-repeat;background-position:50% 50%;background-size:100%;content:""}.taro-video-control-button.taro-video-control-button-play::after,.taro-video-cover-play-button{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABoAAAAeCAYAAAAy2w7YAAAAAXNSR0IArs4c6QAAAWhJREFUSA1j+P///0cgBoHjQGzCQCsAtgJB/AMy5wCxGNXtQ9iBwvoA5BUCMQvVLEQxHpNzDSjkRhXLMM3GKrIeKKpEkYVYjcUu+AMo3ALE3GRZiN1MvKKPgbIRJFuG10j8koeA0gZEW4jfLIKyf4EqpgOxMEELCRpFnIJ3QGU5QMyM00LizCFa1SWgSkeslhFtBGkKVwGVy6FYSJp+klR/A6quB2JOkIWMIK0oNlOf8xBoZDE9LAI7nYn6HsBq4l96WHQEaLUpAyiOaASeAM2NgvuPBpaACt82IEYtfKls0UagecpwXyAzqGTRdaA57sjmYrAptAjUsCkGYlYMg9EFyLQI1IiZB8Ti6Obh5JNh0QmgHlOcBuKSIMGi50C18UDMiMssvOJEWPQLqKYbiHnxGkRIkoBF24DyaoTMIEoeh0W3geI+RBlArCI0iz4D+RVAzEasfqLVAQ19AcSg5LoYiKWI1kiiQgCMBLnEEcfDSgAAAABJRU5ErkJggg==")}.taro-video-control-button.taro-video-control-button-pause::after{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAAgCAYAAAAffCjxAAAAAXNSR0IArs4c6QAAAFlJREFUSA3tksEKACAIQ7X//5zq98wOgQayum8QaGweHhMzG/6OujzKAymn+0LMqivu1XznWmX8/echTIyMyAgTwA72iIwwAexgj8gIE8CO3aMRbDPMaEy5BRGaKcZv8YxRAAAAAElFTkSuQmCC")}.taro-video-current-time,.taro-video-duration{margin-top:15px;margin-bottom:14.5px;height:14.5px;line-height:14.5px;font-size:12px;color:#cbcbcb}.taro-video-progress-container{position:relative;-ms-flex-positive:2;flex-grow:2;-webkit-box-flex:2}.taro-video-progress{position:relative;margin:21px 12px;height:2px;background-color:rgba(255, 255, 255, 0.4)}.taro-video-progress-buffered{position:absolute;left:0;top:0;width:0;height:100%;background-color:rgba(255, 255, 255, 0.8);-webkit-transition:width 0.1s;transition:width 0.1s}.taro-video-ball{position:absolute;left:0;top:-21px;-webkit-box-sizing:content-box;box-sizing:content-box;margin-left:-22px;padding:14px;width:16px;height:16px}.taro-video-inner{border-radius:50%;width:100%;height:100%;background-color:#fff}.taro-video-danmu-button{margin:0 8.5px;padding:2px 10px;border:1px solid #fff;border-radius:5px;line-height:1;font-size:13px;color:#fff;white-space:nowrap}.taro-video-danmu-button.taro-video-danmu-button-active{border-color:#48c23d;color:#48c23d}.taro-video-fullscreen,.taro-video-mute{-webkit-box-sizing:content-box;box-sizing:content-box;padding:8.5px;width:17px;height:17px;background-repeat:no-repeat;background-position:50% 50%;background-size:50%}.taro-video-fullscreen{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAhUlEQVRYR+2WSwrAMAhEnZO3PfmULLooGEFTiIXJ2s/kRY2wzQeb85sE9CRA8jSzY1YfAFzhJBnU1AVgxH2dSiArCnD9QgGzRNnOech48SRABHoSyFb5in3PSbhyo6yvCPQkEM3u7BsPe/0FIvBfAh/vhKmVbO9SWun1qk/PSVi9TcVPBG6R1YIhgWwNpQAAAABJRU5ErkJggg==")}.taro-video-fullscreen.taro-video-type-fullscreen{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAABPUlEQVRYR+2Xu0pDURBF1/ZLxNcHKNiIlfhA7C0UBSEE8RNEBNFPUEQEEbGxFiSSSrCwEHsf5E/ccsSUuWfUhKQ40947+y42Z8+ZK/pcinzf9hhwD1xJ2q/qsb0JHAOzkl5y+lGAGnCWICQtZgAS6DxQk3TeLYA6cAo0JSXxjmW7CcwBdUkJurKiDhSA4kBvHbA9CqwBQx2O7BSw8ssU3ALPFRF4knT3nQLbr8B4LjLBOdAAFgJaLUkjbYC9n+zm+i4kXWbmwCqwnRMCHiXthuZAQOzPrxSA4kBxYDAcsH0EzATCfCLpJjOINoCtgFZabg7bk7AFDAeaGpKWgitZTu5N0kQbYBmYrujo9mX0CVxL+gidAdu9vY5zXhWA4sAgOND3X7NJ4AHYCaxkB8B62gslvecSFpoDOZH/PP8Cnt7hIaM5xCEAAAAASUVORK5CYII=")}.taro-video-mute{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAAsTAAALEwEAmpwYAAAGAGlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS42LWMxNDAgNzkuMTYwNDUxLCAyMDE3LzA1LzA2LTAxOjA4OjIxICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIgeG1sbnM6cGhvdG9zaG9wPSJodHRwOi8vbnMuYWRvYmUuY29tL3Bob3Rvc2hvcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RFdnQ9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZUV2ZW50IyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ0MgMjAxOCAoTWFjaW50b3NoKSIgeG1wOkNyZWF0ZURhdGU9IjIwMTktMDQtMTFUMTA6MTg6MjArMDg6MDAiIHhtcDpNb2RpZnlEYXRlPSIyMDE5LTA0LTExVDEwOjIyOjIyKzA4OjAwIiB4bXA6TWV0YWRhdGFEYXRlPSIyMDE5LTA0LTExVDEwOjIyOjIyKzA4OjAwIiBkYzpmb3JtYXQ9ImltYWdlL3BuZyIgcGhvdG9zaG9wOkNvbG9yTW9kZT0iMyIgcGhvdG9zaG9wOklDQ1Byb2ZpbGU9InNSR0IgSUVDNjE5NjYtMi4xIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOjk3YmE4Yjg0LTFhNTYtNGM1MS04NDVkLTNiZmYyMGI0ZDc0ZiIgeG1wTU06RG9jdW1lbnRJRD0iYWRvYmU6ZG9jaWQ6cGhvdG9zaG9wOjg1NGQ3MjlkLWUwNjctZjU0OC1hMTlhLTBlZjQ4OGRkYjJiOSIgeG1wTU06T3JpZ2luYWxEb2N1bWVudElEPSJ4bXAuZGlkOjA1ODY3ZDFlLWQ3NGEtNDgyNC04MDU3LTYzYmRmMTdjODk5ZSI+IDx4bXBNTTpIaXN0b3J5PiA8cmRmOlNlcT4gPHJkZjpsaSBzdEV2dDphY3Rpb249ImNyZWF0ZWQiIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6MDU4NjdkMWUtZDc0YS00ODI0LTgwNTctNjNiZGYxN2M4OTllIiBzdEV2dDp3aGVuPSIyMDE5LTA0LTExVDEwOjE4OjIwKzA4OjAwIiBzdEV2dDpzb2Z0d2FyZUFnZW50PSJBZG9iZSBQaG90b3Nob3AgQ0MgMjAxOCAoTWFjaW50b3NoKSIvPiA8cmRmOmxpIHN0RXZ0OmFjdGlvbj0ic2F2ZWQiIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6OTdiYThiODQtMWE1Ni00YzUxLTg0NWQtM2JmZjIwYjRkNzRmIiBzdEV2dDp3aGVuPSIyMDE5LTA0LTExVDEwOjIyOjIyKzA4OjAwIiBzdEV2dDpzb2Z0d2FyZUFnZW50PSJBZG9iZSBQaG90b3Nob3AgQ0MgMjAxOCAoTWFjaW50b3NoKSIgc3RFdnQ6Y2hhbmdlZD0iLyIvPiA8L3JkZjpTZXE+IDwveG1wTU06SGlzdG9yeT4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz459+FoAAABqElEQVRYhc2XPWsVQRSGnxPjF4oGRfxoRQKGWCU2Ft7CykrQWosEyf/If0hhIPgHDEmbNJZqCFxiQEgTUGxsBUVEHgvnyrjZZJO92V1fGIaZnTPvszPszNlQ6VIjnbr/DwCoDLMNak/dUVfUK0f2rQugnlcX/FevWgFQH6gf3autRgHUC+piiXHzAOmtPx9gXgug8itQx9SXwDpw47AGKXZWvXvQmNFCwE3gCXA2dY0Az4GrRzHONA9cU/vAbERsllEOyh31e8USV2mrMPdG9uyn+rDom2/BHHCm5puWKiKmgdtAnz+rvaxO5mNygEvHaZ5BfADuARvAaWBpP4DGFBHfgBngFzClTrUKkCDeA+9S837rAEnbqb7VFcCpVJ/oCmCw959aB1AfAROpudYqgDoOLKRmPyLelAF8bcD4pPoMeAtcB34AT4uDBqXXwFG8XXUU/72MIuK1OgE8Bs6l7mEvo8up7lN1Ge0n9aK6VHMFZvJTr9S3CiALaCQhqZOSvegMIAvu2UVSWpigLC1fbQ0gm6in7qpfLCQbhwGIYcyPQ53/G3YO8BtUtd35bvKcVwAAAABJRU5ErkJggg==")}.taro-video-mute.taro-video-type-mute{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACIAAAAgCAYAAAB3j6rJAAAACXBIWXMAAAsTAAALEwEAmpwYAAAGAGlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS42LWMxNDAgNzkuMTYwNDUxLCAyMDE3LzA1LzA2LTAxOjA4OjIxICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIgeG1sbnM6cGhvdG9zaG9wPSJodHRwOi8vbnMuYWRvYmUuY29tL3Bob3Rvc2hvcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RFdnQ9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZUV2ZW50IyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ0MgMjAxOCAoTWFjaW50b3NoKSIgeG1wOkNyZWF0ZURhdGU9IjIwMTktMDQtMTFUMTA6MTk6MDMrMDg6MDAiIHhtcDpNb2RpZnlEYXRlPSIyMDE5LTA0LTExVDEwOjIyOjMzKzA4OjAwIiB4bXA6TWV0YWRhdGFEYXRlPSIyMDE5LTA0LTExVDEwOjIyOjMzKzA4OjAwIiBkYzpmb3JtYXQ9ImltYWdlL3BuZyIgcGhvdG9zaG9wOkNvbG9yTW9kZT0iMyIgcGhvdG9zaG9wOklDQ1Byb2ZpbGU9InNSR0IgSUVDNjE5NjYtMi4xIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOjAzYjJmNjE2LTZmZTUtNDJjNC1iNTgwLTczNzZjZjI2NzdmNSIgeG1wTU06RG9jdW1lbnRJRD0iYWRvYmU6ZG9jaWQ6cGhvdG9zaG9wOjYzZjQ2NTYzLWE0ZjktOGQ0Mi1hM2FhLTY3ODJhNDBhYWNjMSIgeG1wTU06T3JpZ2luYWxEb2N1bWVudElEPSJ4bXAuZGlkOjIyYWNjMWFlLTg4ZmMtNDBlZi1iMWM1LTNmODgwY2QzYWI2MiI+IDx4bXBNTTpIaXN0b3J5PiA8cmRmOlNlcT4gPHJkZjpsaSBzdEV2dDphY3Rpb249ImNyZWF0ZWQiIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6MjJhY2MxYWUtODhmYy00MGVmLWIxYzUtM2Y4ODBjZDNhYjYyIiBzdEV2dDp3aGVuPSIyMDE5LTA0LTExVDEwOjE5OjAzKzA4OjAwIiBzdEV2dDpzb2Z0d2FyZUFnZW50PSJBZG9iZSBQaG90b3Nob3AgQ0MgMjAxOCAoTWFjaW50b3NoKSIvPiA8cmRmOmxpIHN0RXZ0OmFjdGlvbj0ic2F2ZWQiIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6MDNiMmY2MTYtNmZlNS00MmM0LWI1ODAtNzM3NmNmMjY3N2Y1IiBzdEV2dDp3aGVuPSIyMDE5LTA0LTExVDEwOjIyOjMzKzA4OjAwIiBzdEV2dDpzb2Z0d2FyZUFnZW50PSJBZG9iZSBQaG90b3Nob3AgQ0MgMjAxOCAoTWFjaW50b3NoKSIgc3RFdnQ6Y2hhbmdlZD0iLyIvPiA8L3JkZjpTZXE+IDwveG1wTU06SGlzdG9yeT4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz5PmxYVAAACLklEQVRYhc2XP2sVQRRHz40hKoqaQgVBCy1EozFlGiVFxMLGh4piYWEh+hkEP4YKAVFEEFTyughaCH6DqIVpAhYWEgIxoJE8cywyi5tNHu/tJmvyg2WZO3dmzt47/zZUtoJ6Nhsg09YDiYhKDzACTAFNYH9lEpUq80TdrT5wpV5n/ZV9KoGoo+pXV2uyKkipOaLuUceAt8DhUvQd1FsCYhR4ChzaSIBMHSOi7lOfsByFWiCgEBH1GHAF2JlMPcBt4GC3HUYEaj9wF3gVEVPtfNVTwAXgWX7CDKq/1piAZTSZBmim8qJ6sQ3EgDqb/L7kU3MH2NHtl3dQX3r3Ak21UYAYAj4A/cl0JB+RF+uMRj4iQ+p8zt7KYFLdXKHuRi0gacBhV6a6pd5bA6KRNagFJPU9qv5u47toLmW1HnoR8Q5oAK1CVQu4FBHj/wUkaXsb+4pzpVaQFPqXrN7Be4Fx9VztIOr1BLEtmX4A94E/qdwHTKjDWYM6lu81dSlnn3V570BtuLxaMs2rZ/IgYxsBovaoPwsQA4VoFWEm8ql5DiysNyURsQTMpOIMcDYiPhd8xoGr/FtNC2G6FKXD6ihwGdiVHMoeeh8jYlA9ANwE3kTEp3bO6vE03qOONzR1r/q4RGrquaFFxFxE3ALOA9+6jExpdb180y55AhirhaRTatq0GXEzL8+ZIuI9cBJ4WKiartJf9nWV/mty7UfUafW7erpqRGI9EBuprffvu9n6C1KOmsqwI5A1AAAAAElFTkSuQmCC")}.taro-video-danmu{overflow:visible;position:absolute;left:0;top:0;bottom:0;margin-top:14px;margin-bottom:44px;width:100%;line-height:14px;font-size:14px}.taro-video-danmu-item{position:absolute;left:100%;line-height:1;color:#fff;white-space:nowrap;-webkit-transform:translateX(0);transform:translateX(0);-webkit-transition-property:left, -webkit-transform;transition-property:left, -webkit-transform;transition-property:left, transform;transition-property:left, transform, -webkit-transform;-webkit-transition-duration:3s;transition-duration:3s;-webkit-transition-timing-function:linear;transition-timing-function:linear}.taro-video-toast{display:block;visibility:hidden;position:absolute;left:50%;top:50%;border-radius:5px;background-color:rgba(255, 255, 255, 0.8);pointer-events:none;color:#000;-webkit-transform:translate(-50%, -50%);transform:translate(-50%, -50%)}.taro-video-toast.taro-video-toast-volume{display:block;width:100px;height:100px}.taro-video-toast-volume .taro-video-toast-title{display:block;margin-top:10px;width:100%;line-height:16px;text-align:center;font-size:12px}.taro-video-toast-volume .taro-video-toast-icon{display:block;margin-left:25%;width:50%;height:50%;background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAFhklEQVR4Xu2aeaxfQxTHP1VBES0NIQitWtpaaxeCUkQtaYVa0tiClAq1ExIiQTVppaWxt8RWSa2tWkJQRGgtQaSIpUKEpG0ssbbk28yV2+mZO/e9e3vvu/e98897mZnfzPl+75mZs0wvurn06ub46SGgxwLqZaA3sB/wO/A+8G/V6tS5BU4BJgJbO9DvAMOB36okoQ4CNgAeBEYbQK8Bbm4zAdsBc4EdAyA/APZoKwHHAA8DG2UA/AnYrG0ErAVcD1yXA9gfQJ8c40obsqbPgH7AY8CROTVuFQFD3X7fJid4DWsNAWOAGZ0w58YTsDZwKzChA189PbTRBGwKzAYO6iT4srbAMHfTfAksjulS1iG4JzAH2Dy2YKS/qAVcCdzi1vgZOBZ4PWvNGAG6wgYCW0IwctzNmf06BcEXtYABwOeA4otEfgEOdnGGqV6IAAUopwM6zDYuAVjeKYpYwCjgCWOhH513+b2lhE+Avrj89NPyalzyuCIE6EN9BfQ1dHoPOAD40+9LE6D/5aoqSqtLsgiQC60DTiHzfGCFoaSsQAexZdlTgEuyCDgLuK8u5G7dEAHyKN8CBrtxLwDHAX8Z+l4N3GS0L3db4aN0X5opmc+2XZQAfb2LPd2eciG1lUSRJZ9qYHkZONwiYAjwSc3gs24BXWWWfzEVuMjQez13HljX8v7A28lvEgsInaBVcxLaAvr6sgJLtBWeNTrOB+4w2p8DRvoEnAPcXTVaY70QAbrbXwIONX7zBSAL/tvrk1+iviTllnRry2irr/QSEws4D7izCxMg1XQLLAQGGXpeCkw22kOWI49RMUujCJC+uwAfGtfcImAng4AtAMsBeg04pIkESOfbgQsMsNoGnxrtSrfv7rXrSlwXWN6kLZBgEBiB8iWUUZZPIN/AF1nMoiYSICDfAlt5iB4CxhpAzwXuMtqPBuY1lYB5wFEeqFeAwwyguvIUqvuiQO/xphJwP3Cmhyh0EKrOoGDIF7n+M5pKwEwXrqdBCaQSM77Ig7SSIicDs5pKwIvACA+pzFwZIF9OlKm36QyQV7jEqDDJk5VD58uFgGIGX1Se+6yJFqAKsqI6X84GdDb4Mh0Y5zUqjFYFakUTCXja5QLSmBQHbAL8ahAgT1AeYVreSKLLphGwF/CuAfLJQLldGSTFD75c5d4mNCoWyAqG9gYWGED1AOMKo12ZbiWA/idA++deY2DVTZ0Jh5UJPsFQtD/wDaAHGWl5EzgwaUi2gK4UXS11S0cTIjrMFBtYQdAk4DID0BnAAz4B6wNLgTKKG0VIDBHwqitwpOcW+OOB540FdeipNKbUWFrUtn06o5xOij4KyDuqU0IE3Obl/rLA63pTzm9XA8jKACjdniZAaSKFmUpB1yUhAlTsUEpMh913wEkuTe7rKTzPAHqO44vpKPkFhH3cWWBVV6ogJVYZUgz/tXtIYelzI3Ct0fExIGx6j7iKWBUUveyYBehv1RIjIEsfqziq8Xp4pSBJOYTVJFQcVY3wCFeKUjVGyYfQWB00+5bEVBECrNS+qsOKBpVHNCVWHs+LS7H5PV5pOu9v0+OKEOAXR39w1e1C7wM6AkJ1eLmkRcrpRQiQrqobXO5S3vL3/4kBKMsCknV0k+iasVLUMV3UX5SAPGtED8EOT+L9YENnCasUIXNO2goChFWHqAIRyxXN4qI1BCQg9dJESYq8LnbrCBAR8t50Lig6i0krCRBoVWhVlt45wkBrCRBuRZyPuAguxIPe9lXqhpd9DcZMXOvdkPF0Xu/8dohNUmZ/1QQkuitXr+d4fryuFx3jywQYm6suAqSX8vLTXKJDt4QqO6rtLYspXWZ/nQQkOJTAUJZGIav19q9MvKvN1RUIWKMAY5P3EBBjqO393d4C/gMVHwRQlpx21QAAAABJRU5ErkJggg==");background-repeat:no-repeat;background-position:50% 50%;background-size:50%;fill:#000}.taro-video-toast-volume .taro-video-toast-value{margin-left:10px;margin-top:5px;width:80px;height:5px}.taro-video-toast-volume .taro-video-toast-value>.taro-video-toast-value-content{overflow:hidden}.taro-video-toast-volume-grids{width:80px;height:5px}.taro-video-toast-volume-grids-item{float:left;width:7.1px;height:5px;background-color:#000}.taro-video-toast-volume-grids-item:not(:first-child){margin-left:1px}.taro-video-toast.taro-video-toast-progress{padding:6px;background-color:rgba(0, 0, 0, 0.8);line-height:18px;font-size:14px;color:#fff}';const w=class{constructor(i){t(this,i);this.onPlay=n(this,"play",7);this.onPause=n(this,"pause",7);this.onEnded=n(this,"ended",7);this.onTimeUpdate=n(this,"timeupdate",7);this.onError=n(this,"error",7);this.onFullScreenChange=n(this,"fullscreenchange",7);this.onProgress=n(this,"progress",7);this.onLoadedMetaData=n(this,"loadedmetadata",7);this.currentTime=0;this.isDraggingProgress=false;this.gestureType="none";this.analyzeGesture=t=>{var i;const r={type:"none"};const e=t.touches[0].screenX;const n=t.touches[0].screenY;const s=e-this.lastTouchScreenX;const a=n-this.lastTouchScreenY;const u=this.isFullScreen?this.vslideGestureInFullscreen:this.vslideGesture;if(this.gestureType==="none"){const t=l(s,a);if(t<10)return r;if(Math.abs(a)>=Math.abs(s)){if(u){this.gestureType="adjustVolume";this.lastVolume=this.videoRef.volume}else{return r}}else if(Math.abs(a)<Math.abs(s)){if(this.enableProgressGesture){this.gestureType="adjustProgress";this.lastPercentage=this.currentTime/((i=this.duration)!==null&&i!==void 0?i:this._duration)}else{return r}}}r.type=this.gestureType;r.dataX=c(s/200);r.dataY=c(a/200);return r};this.loadNativePlayer=()=>{if(this.videoRef){this.videoRef.src=this.src;this.videoRef.load()}};this.init=()=>{const{src:t,videoRef:i}=this;if(m(t)){if(b.isSupported()){if(this.hls){this.hls.destroy()}this.hls=new b;this.hls.loadSource(t);this.hls.attachMedia(i);this.hls.on(b.Events.MANIFEST_PARSED,(()=>{this.autoplay&&this.play()}));this.hls.on(b.Events.ERROR,((t,i)=>{this.handleError(i)}))}else if(i.canPlayType("application/vnd.apple.mpegurl")){this.loadNativePlayer()}else{console.error("该浏览器不支持 HLS 播放")}}else{this.loadNativePlayer()}};this.handlePlay=()=>{this.isPlaying=true;this.isFirst=false;this.controlsRef.toggleVisibility(true);this.onPlay.emit()};this.handlePause=()=>{this.isPlaying=false;this.controlsRef.toggleVisibility(true);this.onPause.emit()};this.handleEnded=()=>{this.isFirst=true;this.pause();this.controlsRef.toggleVisibility();this.onEnded.emit()};this.handleTimeUpdate=f((async t=>{var i,r;this.currentTime=this.videoRef.currentTime;const e=this.duration||this._duration;const n=await this.controlsRef.getIsDraggingProgressBall();if(this.controls&&this.showProgress){if(!n&&!this.isDraggingProgress){this.controlsRef.setProgressBall(this.currentTime/e);this.controlsRef.setCurrentTime(this.currentTime)}}this.danmuRef.tick(this.currentTime);this.onTimeUpdate.emit({duration:(i=t.target)===null||i===void 0?void 0:i.duration,currentTime:(r=t.target)===null||r===void 0?void 0:r.currentTime});if(this.duration){if(this.currentTime>=this.duration){this.seek(0);this.handleEnded()}}}),250);this.handleError=t=>{var i,r;if(this.hls){switch(t.type){case b.ErrorTypes.NETWORK_ERROR:this.onError.emit({errMsg:t.response});this.hls.startLoad();break;case b.ErrorTypes.MEDIA_ERROR:this.onError.emit({errMsg:t.reason||"媒体错误,请重试"});this.hls.recoverMediaError();break}}else{this.onError.emit({errMsg:(r=(i=t.target)===null||i===void 0?void 0:i.error)===null||r===void 0?void 0:r.message})}};this.handleDurationChange=()=>{this._duration=this.videoRef.duration};this.handleProgress=()=>{this.onProgress.emit()};this.handleLoadedMetaData=t=>{const i=t.target;this.onLoadedMetaData.emit({width:i.videoWidth,height:i.videoHeight,duration:i.duration})};this._play=()=>this.videoRef.play();this._pause=()=>this.videoRef.pause();this._stop=()=>{this.videoRef.pause();this._seek(0)};this._seek=t=>{this.videoRef.currentTime=t};this.onTouchStartContainer=t=>{this.lastTouchScreenX=t.touches[0].screenX;this.lastTouchScreenY=t.touches[0].screenY};this.onClickContainer=()=>{if(this.enablePlayGesture){const t=Date.now();if(t-this.lastClickedTime<300){this.isPlaying?this.pause():this.play()}this.lastClickedTime=t}this.controlsRef.toggleVisibility()};this.onClickFullScreenBtn=t=>{t.stopPropagation();this.toggleFullScreen()};this.handleFullScreenChange=t=>{const i=(new Date).getTime();if(!t.detail&&this.isFullScreen&&!document[d.fullscreenElement]&&i-this.fullScreenTimestamp>100){this.toggleFullScreen(false)}};this.toggleFullScreen=(t=!this.isFullScreen)=>{this.isFullScreen=t;this.controlsRef.toggleVisibility(true);this.fullScreenTimestamp=(new Date).getTime();this.onFullScreenChange.emit({fullScreen:this.isFullScreen,direction:"vertical"});if(this.isFullScreen&&!document[d.fullscreenElement]){setTimeout((()=>{this.videoRef[d.requestFullscreen]({navigationUI:"auto"})}),0)}};this.toggleMute=t=>{t.stopPropagation();this.videoRef.muted=!this.isMute;this.controlsRef.toggleVisibility(true);this.isMute=!this.isMute};this.toggleDanmu=t=>{t.stopPropagation();this.controlsRef.toggleVisibility(true);this._enableDanmu=!this._enableDanmu};this.src=undefined;this.duration=undefined;this.controls=true;this.autoplay=false;this.loop=false;this.muted=false;this.initialTime=0;this.poster=undefined;this.objectFit="contain";this.showProgress=true;this.showFullscreenBtn=true;this.showPlayBtn=true;this.showCenterPlayBtn=true;this.showMuteBtn=false;this.danmuList=undefined;this.danmuBtn=false;this.enableDanmu=false;this.enablePlayGesture=false;this.enableProgressGesture=true;this.vslideGesture=false;this.vslideGestureInFullscreen=true;this.nativeProps={};this._duration=undefined;this._enableDanmu=false;this.isPlaying=false;this.isFirst=true;this.isFullScreen=false;this.fullScreenTimestamp=(new Date).getTime();this.isMute=false}componentWillLoad(){this._enableDanmu=this.enableDanmu}componentDidLoad(){this.init();if(this.initialTime){this.videoRef.currentTime=this.initialTime}this.danmuRef.sendDanmu(this.danmuList);if(document.addEventListener){document.addEventListener(d.fullscreenchange,this.handleFullScreenChange)}if(this.videoRef&&v==="iOS"){this.videoRef.addEventListener("webkitendfullscreen",this.handleFullScreenChange)}}componentDidRender(){}disconnectedCallback(){if(document.removeEventListener){document.removeEventListener(d.fullscreenchange,this.handleFullScreenChange)}if(this.videoRef&&v==="iOS"){this.videoRef.removeEventListener("webkitendfullscreen",this.handleFullScreenChange)}}watchEnableDanmu(t){this._enableDanmu=t}watchSrc(){this.init()}async onDocumentTouchMove(t){if(this.lastTouchScreenX===undefined||this.lastTouchScreenY===undefined)return;if(await this.controlsRef.getIsDraggingProgressBall())return;const i=this.analyzeGesture(t);if(i.type==="adjustVolume"){this.toastVolumeRef.style.visibility="visible";const t=Math.max(Math.min(this.lastVolume-i.dataY,1),0);this.videoRef.volume=t;this.toastVolumeBarRef.style.width=`${t*100}%`}else if(i.type==="adjustProgress"){this.isDraggingProgress=true;this.nextPercentage=Math.max(Math.min(this.lastPercentage+i.dataX,1),0);if(this.controls&&this.showProgress){this.controlsRef.setProgressBall(this.nextPercentage);this.controlsRef.toggleVisibility(true)}const t=this.duration||this._duration;this.toastProgressTitleRef.innerHTML=`${h(this.nextPercentage*t)} / ${h(t)}`;this.toastProgressRef.style.visibility="visible"}}onDocumentTouchEnd(){var t;if(this.gestureType==="adjustVolume"){this.toastVolumeRef.style.visibility="hidden"}else if(this.gestureType==="adjustProgress"){this.toastProgressRef.style.visibility="hidden"}if(this.isDraggingProgress){this.isDraggingProgress=false;this.seek(this.nextPercentage*((t=this.duration)!==null&&t!==void 0?t:this._duration))}this.gestureType="none";this.lastTouchScreenX=undefined;this.lastTouchScreenY=undefined}async play(){this._play()}async pause(){this._pause()}async stop(){this._stop()}async seek(t){this._seek(t)}async requestFullScreen(){this.toggleFullScreen(true)}async exitFullScreen(){this.toggleFullScreen(false)}render(){const{controls:t,autoplay:e,loop:n,muted:s,poster:a,objectFit:u,isFirst:f,isMute:l,isFullScreen:c,showCenterPlayBtn:v,isPlaying:d,_enableDanmu:m,showMuteBtn:p,danmuBtn:g,showFullscreenBtn:b,nativeProps:y}=this;const w=this.duration||this._duration;const A=h(w);return i(r,{class:o("taro-video-container",{"taro-video-type-fullscreen":c}),onTouchStart:this.onTouchStartContainer,onClick:this.onClickContainer},i("video",Object.assign({class:"taro-video-video",style:{"object-fit":u},ref:t=>{if(t){this.videoRef=t}},autoplay:e,loop:n,muted:s,poster:t?a:undefined,playsinline:true,"webkit-playsinline":true,onPlay:this.handlePlay,onPause:this.handlePause,onEnded:this.handleEnded,onTimeUpdate:this.handleTimeUpdate,onError:this.handleError,onDurationChange:this.handleDurationChange,onProgress:this.handleProgress,onLoadedMetaData:this.handleLoadedMetaData},y),"暂时不支持播放该视频"),i("taro-video-danmu",{ref:t=>{if(t){this.danmuRef=t}},enable:m}),f&&v&&!d&&i("div",{class:"taro-video-cover"},i("div",{class:"taro-video-cover-play-button",onClick:()=>this.play()}),i("p",{class:"taro-video-cover-duration"},A)),i("taro-video-control",{ref:t=>{if(t){this.controlsRef=t}},controls:t,currentTime:this.currentTime,duration:w,isPlaying:this.isPlaying,pauseFunc:this._pause,playFunc:this._play,seekFunc:this._seek,showPlayBtn:this.showPlayBtn,showProgress:this.showProgress},p&&i("div",{class:o("taro-video-mute",{"taro-video-type-mute":l}),onClick:this.toggleMute}),g&&i("div",{class:o("taro-video-danmu-button",{"taro-video-danmu-button-active":m}),onClick:this.toggleDanmu},"弹幕"),b&&i("div",{class:o("taro-video-fullscreen",{"taro-video-type-fullscreen":c}),onClick:this.onClickFullScreenBtn})),i("div",{class:"taro-video-toast taro-video-toast-volume",ref:t=>{if(t){this.toastVolumeRef=t}}},i("div",{class:"taro-video-toast-title"},"音量"),i("div",{class:"taro-video-toast-icon"}),i("div",{class:"taro-video-toast-value"},i("div",{class:"taro-video-toast-value-content",ref:t=>{if(t){this.toastVolumeBarRef=t}}},i("div",{class:"taro-video-toast-volume-grids"},Array(10).fill(1).map((()=>i("div",{class:"taro-video-toast-volume-grids-item"}))))))),i("div",{class:"taro-video-toast taro-video-toast-progress",ref:t=>{if(t){this.toastProgressRef=t}}},i("div",{class:"taro-video-toast-title",ref:t=>{if(t){this.toastProgressTitleRef=t}}})))}get el(){return e(this)}static get watchers(){return{enableDanmu:["watchEnableDanmu"],src:["watchSrc"]}}};w.style=y;const A=class{constructor(i){t(this,i);this.list=[];this.danmuElList=[];this.currentTime=0;this.enable=false;this.danmuList=[]}ensureProperties(t){const i=Object.assign({},t);if(!("time"in t)){i.time=this.currentTime}i.key=Math.random();i.bottom=`${Math.random()*90+5}%`;return i}async sendDanmu(t=[]){if(Array.isArray(t)){this.list=[...this.list,...t.map((t=>this.ensureProperties(t)))]}else{const i=t;this.list=[...this.list,Object.assign({},this.ensureProperties(i))]}}async tick(t){this.currentTime=t;if(!this.enable)return;const i=this.list;const r=i.filter((({time:i})=>t-i<4&&t>i));let e=false;const n=this.danmuList;if(r.length!==n.length){e=true}else{e=r.some((({key:t})=>n.every((i=>t!==i.key))))}if(e){this.danmuList=r}}componentDidUpdate(){requestAnimationFrame((()=>{setTimeout((()=>{const t=this.danmuElList.splice(0);t.forEach((t=>{t.style.left="0";t.style.webkitTransform="translateX(-100%)";t.style.transform="translateX(-100%)"}))}))}))}render(){if(!this.enable)return"";return i(r,{class:"taro-video-danmu"},this.danmuList.map((({text:t,color:r,bottom:e,key:n})=>i("p",{class:"taro-video-danmu-item",key:n,style:{color:r,bottom:e},ref:t=>{if(t){this.danmuElList.push(t)}}},t))))}};export{p as taro_video_control,w as taro_video_core,A as taro_video_danmu};
|
|
366
|
+
//# sourceMappingURL=p-51de23e4.entry.js.map
|