@oat-sa/tao-core-ui 1.60.2 → 1.62.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/LICENSE +339 -339
- package/README.md +23 -18
- package/dist/actionbar.js +393 -410
- package/dist/adder.js +143 -156
- package/dist/animable/absorbable/absorbable.js +208 -211
- package/dist/animable/absorbable/css/absorb.css +7 -8
- package/dist/animable/absorbable/css/absorb.css.map +1 -1
- package/dist/animable/pulsable/css/pulse.css +7 -7
- package/dist/animable/pulsable/css/pulse.css.map +1 -1
- package/dist/animable/pulsable/pulsable.js +174 -174
- package/dist/areaBroker.js +59 -72
- package/dist/autocomplete/css/autocomplete.css +7 -8
- package/dist/autocomplete/css/autocomplete.css.map +1 -1
- package/dist/autocomplete.js +494 -604
- package/dist/autoscroll.js +23 -25
- package/dist/badge/badge.js +201 -199
- package/dist/badge/css/badge.css +7 -8
- package/dist/badge/css/badge.css.map +1 -1
- package/dist/breadcrumbs/css/breadcrumbs.css +7 -7
- package/dist/breadcrumbs/css/breadcrumbs.css.map +1 -1
- package/dist/breadcrumbs.js +286 -285
- package/dist/btngrouper.js +83 -95
- package/dist/bulkActionPopup/css/bulkActionPopup.css +7 -7
- package/dist/bulkActionPopup/css/bulkActionPopup.css.map +1 -1
- package/dist/bulkActionPopup.js +503 -503
- package/dist/button.js +300 -293
- package/dist/calculator/css/calculator.css +10 -10
- package/dist/calculator/css/calculator.css.map +1 -1
- package/dist/calculator.js +59 -72
- package/dist/cascadingComboBox.js +257 -256
- package/dist/ckeditor/ckConfigurator.js +130 -154
- package/dist/ckeditor/dtdHandler.js +305 -345
- package/dist/class/css/selector.css +7 -7
- package/dist/class/css/selector.css.map +1 -1
- package/dist/class/selector.js +437 -470
- package/dist/component/alignable.js +97 -121
- package/dist/component/containable.js +53 -58
- package/dist/component/css/components.css +7 -7
- package/dist/component/css/components.css.map +1 -1
- package/dist/component/css/windowComponent.css +7 -7
- package/dist/component/css/windowComponent.css.map +1 -1
- package/dist/component/draggable.js +34 -36
- package/dist/component/placeable.js +84 -102
- package/dist/component/resizable.js +79 -89
- package/dist/component/stackable.js +21 -27
- package/dist/component/windowed.js +284 -297
- package/dist/component.js +439 -467
- package/dist/container.js +79 -98
- package/dist/contextualPopup/css/contextualPopup.css +7 -7
- package/dist/contextualPopup/css/contextualPopup.css.map +1 -1
- package/dist/contextualPopup.js +417 -436
- package/dist/dashboard/css/dashboard.css +7 -7
- package/dist/dashboard/css/dashboard.css.map +1 -1
- package/dist/dashboard.js +302 -305
- package/dist/datalist/css/datalist.css +7 -7
- package/dist/datalist/css/datalist.css.map +1 -1
- package/dist/datalist.js +783 -791
- package/dist/datatable/css/datatable.css +11 -7
- package/dist/datatable/css/datatable.css.map +1 -1
- package/dist/datatable/filterStrategy/filterStrategy.js +28 -30
- package/dist/datatable/filterStrategy/multiple.js +26 -45
- package/dist/datatable/filterStrategy/single.js +28 -40
- package/dist/datatable.js +1591 -1616
- package/dist/dateRange/css/dateRange.css +7 -7
- package/dist/dateRange/css/dateRange.css.map +1 -1
- package/dist/dateRange/dateRange.js +398 -412
- package/dist/datetime/css/picker.css +7 -7
- package/dist/datetime/css/picker.css.map +1 -1
- package/dist/datetime/picker.js +670 -703
- package/dist/deleter.js +383 -398
- package/dist/destination/css/selector.css +7 -7
- package/dist/destination/css/selector.css.map +1 -1
- package/dist/destination/selector.js +295 -293
- package/dist/dialog/alert.js +30 -32
- package/dist/dialog/confirm.js +29 -32
- package/dist/dialog/confirmDelete.js +223 -221
- package/dist/dialog.js +651 -695
- package/dist/disabler.js +108 -119
- package/dist/documentViewer/css/documentViewer.css +7 -7
- package/dist/documentViewer/css/documentViewer.css.map +1 -1
- package/dist/documentViewer/providers/pdfViewer/fallback/viewer.js +172 -169
- package/dist/documentViewer/providers/pdfViewer/pdfjs/areaBroker.js +32 -29
- package/dist/documentViewer/providers/pdfViewer/pdfjs/findBar.js +523 -564
- package/dist/documentViewer/providers/pdfViewer/pdfjs/pageView.js +376 -393
- package/dist/documentViewer/providers/pdfViewer/pdfjs/pagesManager.js +53 -68
- package/dist/documentViewer/providers/pdfViewer/pdfjs/searchEngine.js +517 -567
- package/dist/documentViewer/providers/pdfViewer/pdfjs/textManager.js +73 -96
- package/dist/documentViewer/providers/pdfViewer/pdfjs/viewer.js +381 -392
- package/dist/documentViewer/providers/pdfViewer/pdfjs/wrapper.js +125 -152
- package/dist/documentViewer/providers/pdfViewer.js +189 -191
- package/dist/documentViewer/viewerFactory.js +76 -81
- package/dist/documentViewer.js +303 -311
- package/dist/dropdown/css/dropdown.css +7 -7
- package/dist/dropdown/css/dropdown.css.map +1 -1
- package/dist/dropdown.js +392 -412
- package/dist/durationer.js +77 -85
- package/dist/dynamicComponent/css/dynamicComponent.css +7 -7
- package/dist/dynamicComponent/css/dynamicComponent.css.map +1 -1
- package/dist/dynamicComponent.js +595 -630
- package/dist/feedback.js +365 -375
- package/dist/figure/FigureStateActive.js +246 -296
- package/dist/filesender.js +44 -54
- package/dist/filter.js +244 -240
- package/dist/form/css/dropdownForm.css +7 -7
- package/dist/form/css/dropdownForm.css.map +1 -1
- package/dist/form/css/form.css +7 -7
- package/dist/form/css/form.css.map +1 -1
- package/dist/form/dropdownForm.js +357 -362
- package/dist/form/form.js +703 -984
- package/dist/form/simpleForm.js +74 -77
- package/dist/form/validator/css/validator.css +7 -7
- package/dist/form/validator/css/validator.css.map +1 -1
- package/dist/form/validator/renderer.js +235 -241
- package/dist/form/validator/validator.js +181 -267
- package/dist/form/widget/css/widget.css +7 -7
- package/dist/form/widget/css/widget.css.map +1 -1
- package/dist/form/widget/definitions.js +27 -28
- package/dist/form/widget/loader.js +16 -16
- package/dist/form/widget/providers/checkBox.js +257 -264
- package/dist/form/widget/providers/comboBox.js +194 -193
- package/dist/form/widget/providers/default.js +44 -50
- package/dist/form/widget/providers/hidden.js +179 -176
- package/dist/form/widget/providers/hiddenBox.js +262 -272
- package/dist/form/widget/providers/radioBox.js +222 -223
- package/dist/form/widget/providers/textArea.js +197 -193
- package/dist/form/widget/providers/textBox.js +36 -37
- package/dist/form/widget/widget.js +480 -508
- package/dist/form.js +12 -17
- package/dist/formValidator/formValidator.js +74 -91
- package/dist/formValidator/highlighters/highlighter.js +43 -51
- package/dist/formValidator/highlighters/message.js +31 -32
- package/dist/formValidator/highlighters/tooltip.js +33 -35
- package/dist/generis/form/css/form.css +7 -7
- package/dist/generis/form/css/form.css.map +1 -1
- package/dist/generis/form/form.js +323 -331
- package/dist/generis/validator/css/validator.css +7 -7
- package/dist/generis/validator/css/validator.css.map +1 -1
- package/dist/generis/validator/validator.js +215 -216
- package/dist/generis/widget/checkBox/checkBox.js +227 -225
- package/dist/generis/widget/comboBox/comboBox.js +189 -183
- package/dist/generis/widget/css/widget.css +7 -7
- package/dist/generis/widget/css/widget.css.map +1 -1
- package/dist/generis/widget/hiddenBox/hiddenBox.js +231 -232
- package/dist/generis/widget/loader.js +21 -23
- package/dist/generis/widget/textBox/textBox.js +178 -172
- package/dist/generis/widget/widget.js +255 -266
- package/dist/groupedComboBox.js +231 -226
- package/dist/groupvalidator.js +30 -34
- package/dist/hider.js +43 -50
- package/dist/highlighter.js +946 -1057
- package/dist/image/ImgStateActive/extractLabel.js +20 -21
- package/dist/image/ImgStateActive/helper.js +21 -25
- package/dist/image/ImgStateActive/initHelper.js +133 -162
- package/dist/image/ImgStateActive/initMediaEditor.js +72 -92
- package/dist/image/ImgStateActive/mediaSizer.js +48 -58
- package/dist/image/ImgStateActive.js +185 -215
- package/dist/incrementer.js +91 -110
- package/dist/inplacer.js +108 -132
- package/dist/interactUtils.js +56 -67
- package/dist/itemButtonList/css/item-button-list.css +23 -24
- package/dist/itemButtonList/css/item-button-list.css.map +1 -1
- package/dist/itemButtonList.js +444 -469
- package/dist/keyNavigation/navigableDomElement.js +124 -158
- package/dist/keyNavigation/navigator.js +235 -312
- package/dist/listbox/css/listbox.css +7 -7
- package/dist/listbox/css/listbox.css.map +1 -1
- package/dist/listbox.js +463 -476
- package/dist/liststyler.js +75 -76
- package/dist/loadingButton/css/button.css +7 -7
- package/dist/loadingButton/css/button.css.map +1 -1
- package/dist/loadingButton/loadingButton.js +219 -218
- package/dist/lock.js +484 -509
- package/dist/login/login.js +471 -486
- package/dist/maths/calculator/basicCalculator.js +247 -242
- package/dist/maths/calculator/calculatorComponent.js +34 -36
- package/dist/maths/calculator/core/areaBroker.js +30 -28
- package/dist/maths/calculator/core/board.js +805 -872
- package/dist/maths/calculator/core/expression.js +500 -518
- package/dist/maths/calculator/core/labels.js +240 -235
- package/dist/maths/calculator/core/plugin.js +20 -20
- package/dist/maths/calculator/core/terms.js +27 -27
- package/dist/maths/calculator/core/tokenizer.js +119 -132
- package/dist/maths/calculator/core/tokens.js +157 -168
- package/dist/maths/calculator/css/calculator.css +7 -7
- package/dist/maths/calculator/css/calculator.css.map +1 -1
- package/dist/maths/calculator/defaultCalculator.js +24 -27
- package/dist/maths/calculator/plugins/core/degrad.js +22 -30
- package/dist/maths/calculator/plugins/core/history.js +55 -67
- package/dist/maths/calculator/plugins/core/remind.js +22 -25
- package/dist/maths/calculator/plugins/core/stepNavigation.js +33 -49
- package/dist/maths/calculator/plugins/keyboard/templateKeyboard/templateKeyboard.js +255 -258
- package/dist/maths/calculator/plugins/modifiers/pow10.js +47 -52
- package/dist/maths/calculator/plugins/modifiers/sign.js +103 -130
- package/dist/maths/calculator/plugins/screen/simpleScreen/simpleScreen.js +288 -293
- package/dist/maths/calculator/pluginsLoader.js +22 -22
- package/dist/maths/calculator/scientificCalculator.js +339 -334
- package/dist/mediaEditor/mediaEditorComponent.js +244 -249
- package/dist/mediaEditor/plugins/mediaAlignment/helper.js +28 -33
- package/dist/mediaEditor/plugins/mediaAlignment/mediaAlignmentComponent.js +228 -236
- package/dist/mediaEditor/plugins/mediaAlignment/style.css +7 -7
- package/dist/mediaEditor/plugins/mediaDimension/helper.js +81 -106
- package/dist/mediaEditor/plugins/mediaDimension/mediaDimensionComponent.js +597 -635
- package/dist/mediaEditor/plugins/mediaDimension/style.css +141 -141
- package/dist/mediaplayer/css/player.css +7 -7
- package/dist/mediaplayer/css/player.css.map +1 -1
- package/dist/mediaplayer/players/html5.js +646 -706
- package/dist/mediaplayer/players/youtube.js +393 -438
- package/dist/mediaplayer/players.js +19 -19
- package/dist/mediaplayer/support.js +66 -79
- package/dist/mediaplayer/utils/reminder.js +117 -128
- package/dist/mediaplayer/utils/timeObserver.js +106 -109
- package/dist/mediaplayer/youtubeManager.js +142 -170
- package/dist/mediaplayer.js +1484 -1774
- package/dist/mediasizer.js +633 -676
- package/dist/modal.js +137 -153
- package/dist/movableComponent.js +37 -37
- package/dist/pageSizeSelector.js +231 -224
- package/dist/pageStatus.js +43 -46
- package/dist/pagination/css/pagination.css +7 -7
- package/dist/pagination/css/pagination.css.map +1 -1
- package/dist/pagination/paginationStrategy.js +24 -25
- package/dist/pagination/providers/pages.js +281 -291
- package/dist/pagination/providers/simple.js +202 -196
- package/dist/pagination.js +49 -72
- package/dist/previewer.js +113 -138
- package/dist/progressbar.js +70 -80
- package/dist/propertySelector/css/propertySelector.css +74 -0
- package/dist/propertySelector/css/propertySelector.css.map +1 -0
- package/dist/propertySelector/propertySelector.js +489 -0
- package/dist/report.js +356 -359
- package/dist/resource/css/selector.css +7 -7
- package/dist/resource/css/selector.css.map +1 -1
- package/dist/resource/filters.js +275 -289
- package/dist/resource/list.js +1589 -1371
- package/dist/resource/selectable.js +101 -136
- package/dist/resource/selector.js +855 -914
- package/dist/resource/tree.js +1796 -1612
- package/dist/resourcemgr/css/resourcemgr.css +7 -7
- package/dist/resourcemgr/css/resourcemgr.css.map +1 -1
- package/dist/resourcemgr/fileBrowser.js +540 -587
- package/dist/resourcemgr/filePreview.js +16 -25
- package/dist/resourcemgr/fileSelector.js +520 -547
- package/dist/resourcemgr/util/updatePermissions.js +10 -18
- package/dist/resourcemgr.js +325 -332
- package/dist/scroller.js +29 -33
- package/dist/searchModal/advancedSearch.js +949 -833
- package/dist/searchModal/css/advancedSearch.css +7 -14
- package/dist/searchModal/css/advancedSearch.css.map +1 -1
- package/dist/searchModal/css/searchModal.css +28 -8
- package/dist/searchModal/css/searchModal.css.map +1 -1
- package/dist/searchModal.js +616 -335
- package/dist/selecter.js +21 -28
- package/dist/stacker.js +52 -60
- package/dist/switch/css/switch.css +7 -7
- package/dist/switch/css/switch.css.map +1 -1
- package/dist/switch/switch.js +305 -311
- package/dist/tableModel.js +39 -49
- package/dist/tabs/css/tabs.css +12 -12
- package/dist/tabs/css/tabs.css.map +1 -1
- package/dist/tabs.js +588 -639
- package/dist/taskQueue/css/taskQueue.css +7 -7
- package/dist/taskQueue/css/taskQueue.css.map +1 -1
- package/dist/taskQueue/status.js +317 -322
- package/dist/taskQueue/table.js +383 -394
- package/dist/taskQueue/taskQueue.js +19 -19
- package/dist/taskQueue/taskQueueModel.js +459 -538
- package/dist/taskQueue.js +49 -67
- package/dist/taskQueueButton/css/taskable.css +7 -7
- package/dist/taskQueueButton/css/taskable.css.map +1 -1
- package/dist/taskQueueButton/css/treeButton.css +7 -7
- package/dist/taskQueueButton/css/treeButton.css.map +1 -1
- package/dist/taskQueueButton/standardButton.js +45 -43
- package/dist/taskQueueButton/taskable.js +267 -272
- package/dist/taskQueueButton/treeButton.js +200 -198
- package/dist/themeLoader.js +109 -129
- package/dist/themes.js +86 -100
- package/dist/toggler.js +76 -88
- package/dist/tooltip.js +296 -311
- package/dist/tooltipster.js +17 -17
- package/dist/transformer.js +140 -169
- package/dist/tristateCheckboxGroup/css/tristateCheckboxGroup.css +7 -7
- package/dist/tristateCheckboxGroup/css/tristateCheckboxGroup.css.map +1 -1
- package/dist/tristateCheckboxGroup.js +319 -325
- package/dist/uploader.js +691 -724
- package/dist/validator/Report.js +1 -2
- package/dist/validator/Validator.js +6 -25
- package/dist/validator/validators.js +66 -80
- package/dist/validator.js +218 -254
- package/dist/waitForMedia.js +45 -51
- package/dist/waitingDialog/css/waitingDialog.css +7 -7
- package/dist/waitingDialog/css/waitingDialog.css.map +1 -1
- package/dist/waitingDialog/waitingDialog.js +59 -77
- package/package.json +109 -107
- package/scss/basic.scss +16 -16
- package/scss/ckeditor/skins/tao/scss/inc/_ck-icons.scss +59 -59
- package/scss/ckeditor/skins/tao/scss/inc/_tao.scss +59 -59
- package/scss/font/tao/tao.svg +234 -234
- package/scss/inc/_base.scss +495 -495
- package/scss/inc/_bootstrap.scss +6 -6
- package/scss/inc/_buttons.scss +114 -114
- package/scss/inc/_colors.scss +93 -88
- package/scss/inc/_feedback.scss +150 -150
- package/scss/inc/_flex-grid.scss +15 -15
- package/scss/inc/_fonts.scss +4 -4
- package/scss/inc/_forms.scss +832 -832
- package/scss/inc/_functions.scss +283 -283
- package/scss/inc/_jquery.nouislider.scss +254 -254
- package/scss/inc/_normalize.scss +528 -528
- package/scss/inc/_report.scss +67 -67
- package/scss/inc/_secondary-properties.scss +89 -89
- package/scss/inc/_select2.scss +634 -634
- package/scss/inc/_toolbars.scss +155 -155
- package/scss/inc/_tooltip.scss +312 -312
- package/scss/inc/_variables.scss +21 -21
- package/scss/inc/base/_highlight.scss +5 -5
- package/scss/inc/base/_list-style.scss +58 -58
- package/scss/inc/base/_svg.scss +3 -3
- package/scss/inc/base/_table.scss +62 -62
- package/scss/inc/fonts/_source-sans-pro.scss +29 -29
- package/scss/inc/fonts/_tao-icon-classes.scss +226 -226
- package/scss/inc/fonts/_tao-icon-def.scss +12 -12
- package/scss/inc/fonts/_tao-icon-vars.scss +240 -240
- package/src/actionbar/tpl/main.tpl +8 -8
- package/src/actionbar.js +251 -251
- package/src/adder.js +250 -250
- package/src/animable/absorbable/absorbable.js +134 -134
- package/src/animable/absorbable/css/absorb.css +7 -8
- package/src/animable/absorbable/css/absorb.css.map +1 -1
- package/src/animable/absorbable/scss/absorb.scss +37 -37
- package/src/animable/pulsable/css/pulse.css +7 -7
- package/src/animable/pulsable/css/pulse.css.map +1 -1
- package/src/animable/pulsable/pulsable.js +90 -90
- package/src/animable/pulsable/scss/pulse.scss +22 -22
- package/src/areaBroker.js +160 -160
- package/src/autocomplete/css/autocomplete.css +7 -8
- package/src/autocomplete/css/autocomplete.css.map +1 -1
- package/src/autocomplete/scss/autocomplete.scss +37 -37
- package/src/autocomplete.js +1029 -1029
- package/src/autoscroll.js +57 -57
- package/src/badge/badge.js +119 -119
- package/src/badge/css/badge.css +7 -8
- package/src/badge/css/badge.css.map +1 -1
- package/src/badge/scss/badge.scss +92 -92
- package/src/badge/tpl/badge.tpl +4 -4
- package/src/breadcrumbs/css/breadcrumbs.css +7 -7
- package/src/breadcrumbs/css/breadcrumbs.css.map +1 -1
- package/src/breadcrumbs/scss/breadcrumbs.scss +52 -52
- package/src/breadcrumbs/tpl/breadcrumbs.tpl +20 -20
- package/src/breadcrumbs.js +99 -99
- package/src/btngrouper.js +213 -213
- package/src/bulkActionPopup/css/bulkActionPopup.css +7 -7
- package/src/bulkActionPopup/css/bulkActionPopup.css.map +1 -1
- package/src/bulkActionPopup/scss/bulkActionPopup.scss +63 -63
- package/src/bulkActionPopup/tpl/layout.tpl +76 -76
- package/src/bulkActionPopup/tpl/select.tpl +8 -8
- package/src/bulkActionPopup.js +274 -274
- package/src/button/tpl/button.tpl +4 -4
- package/src/button.js +135 -135
- package/src/calculator/css/calculator.css +10 -10
- package/src/calculator/css/calculator.css.map +1 -1
- package/src/calculator/scss/calculator.scss +139 -139
- package/src/calculator.js +188 -188
- package/src/cascadingComboBox.js +126 -126
- package/src/ckeditor/ckConfigurator.js +736 -736
- package/src/ckeditor/dtdHandler.js +1030 -1030
- package/src/class/css/selector.css +7 -7
- package/src/class/css/selector.css.map +1 -1
- package/src/class/scss/selector.scss +101 -101
- package/src/class/selector.js +329 -329
- package/src/class/tpl/listItem.tpl +9 -9
- package/src/class/tpl/selector.tpl +10 -10
- package/src/component/alignable.js +274 -274
- package/src/component/containable.js +122 -122
- package/src/component/css/components.css +7 -7
- package/src/component/css/components.css.map +1 -1
- package/src/component/css/windowComponent.css +7 -7
- package/src/component/css/windowComponent.css.map +1 -1
- package/src/component/draggable.js +104 -104
- package/src/component/placeable.js +233 -233
- package/src/component/resizable.js +195 -195
- package/src/component/scss/components.scss +507 -507
- package/src/component/scss/windowComponent.scss +62 -62
- package/src/component/stackable.js +67 -67
- package/src/component/tpl/window.tpl +7 -7
- package/src/component/windowed.js +206 -206
- package/src/component.js +401 -401
- package/src/container.js +200 -200
- package/src/contextualPopup/css/contextualPopup.css +7 -7
- package/src/contextualPopup/css/contextualPopup.css.map +1 -1
- package/src/contextualPopup/scss/contextualPopup.scss +78 -78
- package/src/contextualPopup/tpl/popup.tpl +10 -10
- package/src/contextualPopup.js +297 -297
- package/src/css/basic.css +103 -106
- package/src/css/basic.css.map +1 -1
- package/src/dashboard/css/dashboard.css +7 -7
- package/src/dashboard/css/dashboard.css.map +1 -1
- package/src/dashboard/scss/dashboard.scss +93 -93
- package/src/dashboard/tpl/dashboard.tpl +16 -16
- package/src/dashboard/tpl/dashboardMetricsList.tpl +15 -15
- package/src/dashboard.js +184 -184
- package/src/datalist/css/datalist.css +7 -7
- package/src/datalist/css/datalist.css.map +1 -1
- package/src/datalist/scss/datalist.scss +116 -116
- package/src/datalist/tpl/list.tpl +24 -24
- package/src/datalist/tpl/main.tpl +44 -44
- package/src/datalist.js +500 -500
- package/src/datatable/css/datatable.css +11 -7
- package/src/datatable/css/datatable.css.map +1 -1
- package/src/datatable/filterStrategy/filterStrategy.js +70 -70
- package/src/datatable/filterStrategy/multiple.js +126 -126
- package/src/datatable/filterStrategy/single.js +108 -108
- package/src/datatable/scss/datatable.scss +149 -146
- package/src/datatable/tpl/button.tpl +6 -6
- package/src/datatable/tpl/layout.tpl +158 -158
- package/src/datatable.js +1056 -1056
- package/src/dateRange/css/dateRange.css +7 -7
- package/src/dateRange/css/dateRange.css.map +1 -1
- package/src/dateRange/dateRange.js +341 -341
- package/src/dateRange/scss/dateRange.scss +7 -7
- package/src/dateRange/tpl/select.tpl +18 -18
- package/src/datetime/css/picker.css +7 -7
- package/src/datetime/css/picker.css.map +1 -1
- package/src/datetime/picker.js +576 -576
- package/src/datetime/scss/picker.scss +192 -192
- package/src/datetime/tpl/picker.tpl +18 -18
- package/src/deleter/undo.tpl +6 -6
- package/src/deleter.js +296 -296
- package/src/destination/css/selector.css +7 -7
- package/src/destination/css/selector.css.map +1 -1
- package/src/destination/scss/selector.scss +36 -36
- package/src/destination/selector.js +195 -195
- package/src/destination/tpl/selector.tpl +13 -13
- package/src/dialog/alert.js +70 -70
- package/src/dialog/confirm.js +85 -85
- package/src/dialog/confirmDelete.js +95 -95
- package/src/dialog/tpl/body.tpl +24 -24
- package/src/dialog/tpl/buttons.tpl +6 -6
- package/src/dialog/tpl/checkbox.tpl +5 -5
- package/src/dialog.js +517 -517
- package/src/disabler.js +230 -230
- package/src/documentViewer/css/documentViewer.css +7 -7
- package/src/documentViewer/css/documentViewer.css.map +1 -1
- package/src/documentViewer/providers/pdfViewer/fallback/viewer.js +69 -69
- package/src/documentViewer/providers/pdfViewer/pdfjs/areaBroker.js +41 -41
- package/src/documentViewer/providers/pdfViewer/pdfjs/findBar.js +475 -475
- package/src/documentViewer/providers/pdfViewer/pdfjs/findBar.tpl +20 -20
- package/src/documentViewer/providers/pdfViewer/pdfjs/match.tpl +1 -1
- package/src/documentViewer/providers/pdfViewer/pdfjs/page.tpl +4 -4
- package/src/documentViewer/providers/pdfViewer/pdfjs/pageView.js +318 -318
- package/src/documentViewer/providers/pdfViewer/pdfjs/pagesManager.js +167 -167
- package/src/documentViewer/providers/pdfViewer/pdfjs/searchEngine.js +451 -451
- package/src/documentViewer/providers/pdfViewer/pdfjs/textManager.js +252 -252
- package/src/documentViewer/providers/pdfViewer/pdfjs/viewer.js +299 -299
- package/src/documentViewer/providers/pdfViewer/pdfjs/viewer.tpl +16 -16
- package/src/documentViewer/providers/pdfViewer/pdfjs/wrapper.js +351 -351
- package/src/documentViewer/providers/pdfViewer.js +93 -93
- package/src/documentViewer/scss/documentViewer.scss +184 -184
- package/src/documentViewer/viewerFactory.js +191 -191
- package/src/documentViewer.js +238 -238
- package/src/dropdown/css/dropdown.css +7 -7
- package/src/dropdown/css/dropdown.css.map +1 -1
- package/src/dropdown/scss/dropdown.scss +99 -99
- package/src/dropdown/tpl/dropdown.tpl +8 -8
- package/src/dropdown/tpl/list-item.tpl +4 -4
- package/src/dropdown.js +255 -255
- package/src/durationer.js +222 -222
- package/src/dynamicComponent/css/dynamicComponent.css +7 -7
- package/src/dynamicComponent/css/dynamicComponent.css.map +1 -1
- package/src/dynamicComponent/scss/dynamicComponent.scss +98 -98
- package/src/dynamicComponent/tpl/layout.tpl +17 -17
- package/src/dynamicComponent.js +554 -554
- package/src/feedback/feedback.tpl +7 -7
- package/src/feedback.js +295 -295
- package/src/figure/FigureStateActive.js +174 -174
- package/src/filesender.js +114 -114
- package/src/filter/template.tpl +5 -5
- package/src/filter.js +135 -135
- package/src/form/css/dropdownForm.css +7 -7
- package/src/form/css/dropdownForm.css.map +1 -1
- package/src/form/css/form.css +7 -7
- package/src/form/css/form.css.map +1 -1
- package/src/form/dropdownForm.js +281 -281
- package/src/form/form.js +688 -688
- package/src/form/scss/dropdownForm.scss +60 -60
- package/src/form/scss/form.scss +25 -25
- package/src/form/simpleForm.js +125 -125
- package/src/form/tpl/dropdownForm.tpl +4 -4
- package/src/form/tpl/form.tpl +7 -7
- package/src/form/validator/css/validator.css +7 -7
- package/src/form/validator/css/validator.css.map +1 -1
- package/src/form/validator/renderer.js +118 -118
- package/src/form/validator/scss/validator.scss +14 -14
- package/src/form/validator/tpl/message.tpl +1 -1
- package/src/form/validator/tpl/validator.tpl +1 -1
- package/src/form/validator/validator.js +220 -220
- package/src/form/widget/css/widget.css +7 -7
- package/src/form/widget/css/widget.css.map +1 -1
- package/src/form/widget/definitions.js +51 -51
- package/src/form/widget/loader.js +40 -40
- package/src/form/widget/providers/checkBox.js +138 -138
- package/src/form/widget/providers/comboBox.js +63 -63
- package/src/form/widget/providers/default.js +90 -90
- package/src/form/widget/providers/hidden.js +62 -62
- package/src/form/widget/providers/hiddenBox.js +152 -152
- package/src/form/widget/providers/radioBox.js +99 -99
- package/src/form/widget/providers/textArea.js +52 -52
- package/src/form/widget/providers/textBox.js +48 -48
- package/src/form/widget/scss/widget.scss +55 -55
- package/src/form/widget/tpl/checkBox.tpl +25 -25
- package/src/form/widget/tpl/comboBox.tpl +13 -13
- package/src/form/widget/tpl/hidden.tpl +1 -1
- package/src/form/widget/tpl/hiddenBox.tpl +17 -17
- package/src/form/widget/tpl/label.tpl +6 -6
- package/src/form/widget/tpl/radioBox.tpl +25 -25
- package/src/form/widget/tpl/textArea.tpl +8 -8
- package/src/form/widget/tpl/widget.tpl +8 -8
- package/src/form/widget/widget.js +372 -372
- package/src/form.js +53 -53
- package/src/formValidator/formValidator.js +253 -253
- package/src/formValidator/highlighters/highlighter.js +102 -102
- package/src/formValidator/highlighters/message.js +70 -70
- package/src/formValidator/highlighters/tooltip.js +78 -78
- package/src/generis/form/css/form.css +7 -7
- package/src/generis/form/css/form.css.map +1 -1
- package/src/generis/form/form.js +239 -239
- package/src/generis/form/readme.md +70 -70
- package/src/generis/form/scss/form.scss +23 -23
- package/src/generis/form/tpl/form.tpl +16 -16
- package/src/generis/validator/css/validator.css +7 -7
- package/src/generis/validator/css/validator.css.map +1 -1
- package/src/generis/validator/readme.md +46 -46
- package/src/generis/validator/scss/validator.scss +13 -13
- package/src/generis/validator/validator.js +128 -128
- package/src/generis/widget/checkBox/checkBox.js +112 -112
- package/src/generis/widget/checkBox/checkBox.tpl +18 -18
- package/src/generis/widget/comboBox/comboBox.js +67 -67
- package/src/generis/widget/comboBox/comboBox.tpl +12 -12
- package/src/generis/widget/css/widget.css +7 -7
- package/src/generis/widget/css/widget.css.map +1 -1
- package/src/generis/widget/hiddenBox/hiddenBox.js +132 -132
- package/src/generis/widget/hiddenBox/hiddenBox.tpl +16 -16
- package/src/generis/widget/loader.js +49 -49
- package/src/generis/widget/readme.md +59 -59
- package/src/generis/widget/scss/widget.scss +61 -61
- package/src/generis/widget/textBox/textBox.js +65 -65
- package/src/generis/widget/textBox/textBox.tpl +7 -7
- package/src/generis/widget/widget.js +164 -164
- package/src/generis/widget/widget.tpl +5 -5
- package/src/groupedComboBox.js +99 -99
- package/src/groupvalidator.js +84 -84
- package/src/hider.js +88 -88
- package/src/highlighter.js +1166 -1166
- package/src/image/ImgStateActive/extractLabel.js +29 -29
- package/src/image/ImgStateActive/helper.js +36 -36
- package/src/image/ImgStateActive/initHelper.js +137 -137
- package/src/image/ImgStateActive/initMediaEditor.js +92 -92
- package/src/image/ImgStateActive/mediaSizer.js +63 -63
- package/src/image/ImgStateActive.js +115 -115
- package/src/incrementer.js +319 -319
- package/src/inplacer.js +316 -316
- package/src/interactUtils.js +140 -140
- package/src/itemButtonList/css/item-button-list.css +23 -24
- package/src/itemButtonList/css/item-button-list.css.map +1 -1
- package/src/itemButtonList/scss/item-button-list.scss +236 -236
- package/src/itemButtonList/tpl/itemButtonList.tpl +21 -21
- package/src/itemButtonList.js +274 -274
- package/src/keyNavigation/navigableDomElement.js +282 -282
- package/src/keyNavigation/navigator.js +543 -543
- package/src/listbox/css/listbox.css +7 -7
- package/src/listbox/css/listbox.css.map +1 -1
- package/src/listbox/scss/listbox.scss +116 -116
- package/src/listbox/tpl/list.tpl +14 -14
- package/src/listbox/tpl/main.tpl +9 -9
- package/src/listbox.js +251 -251
- package/src/liststyler.js +155 -155
- package/src/loadingButton/css/button.css +7 -7
- package/src/loadingButton/css/button.css.map +1 -1
- package/src/loadingButton/loadingButton.js +110 -110
- package/src/loadingButton/scss/button.scss +41 -41
- package/src/loadingButton/tpl/button.tpl +5 -5
- package/src/lock/lock.tpl +16 -16
- package/src/lock.js +395 -395
- package/src/login/login.js +322 -322
- package/src/login/tpl/login.tpl +29 -29
- package/src/login/tpl/passwordReveal.tpl +7 -7
- package/src/maths/calculator/basicCalculator.js +55 -55
- package/src/maths/calculator/calculatorComponent.js +128 -128
- package/src/maths/calculator/core/areaBroker.js +38 -38
- package/src/maths/calculator/core/board.js +841 -841
- package/src/maths/calculator/core/expression.js +430 -430
- package/src/maths/calculator/core/labels.js +116 -116
- package/src/maths/calculator/core/plugin.js +40 -40
- package/src/maths/calculator/core/terms.js +459 -459
- package/src/maths/calculator/core/tokenizer.js +245 -245
- package/src/maths/calculator/core/tokens.js +178 -178
- package/src/maths/calculator/core/tpl/board.tpl +4 -4
- package/src/maths/calculator/css/calculator.css +7 -7
- package/src/maths/calculator/css/calculator.css.map +1 -1
- package/src/maths/calculator/defaultCalculator.js +66 -66
- package/src/maths/calculator/plugins/core/degrad.js +90 -90
- package/src/maths/calculator/plugins/core/history.js +166 -166
- package/src/maths/calculator/plugins/core/remind.js +96 -96
- package/src/maths/calculator/plugins/core/stepNavigation.js +175 -175
- package/src/maths/calculator/plugins/keyboard/templateKeyboard/defaultTemplate.tpl +36 -36
- package/src/maths/calculator/plugins/keyboard/templateKeyboard/templateKeyboard.js +91 -91
- package/src/maths/calculator/plugins/modifiers/pow10.js +143 -143
- package/src/maths/calculator/plugins/modifiers/sign.js +339 -339
- package/src/maths/calculator/plugins/screen/simpleScreen/defaultTemplate.tpl +3 -3
- package/src/maths/calculator/plugins/screen/simpleScreen/history.tpl +3 -3
- package/src/maths/calculator/plugins/screen/simpleScreen/simpleScreen.js +191 -191
- package/src/maths/calculator/pluginsLoader.js +46 -46
- package/src/maths/calculator/scientificCalculator.js +74 -74
- package/src/maths/calculator/scss/calculator.scss +396 -396
- package/src/maths/calculator/tpl/basicKeyboard.tpl +37 -37
- package/src/maths/calculator/tpl/basicScreen.tpl +2 -2
- package/src/maths/calculator/tpl/scientificKeyboard.tpl +61 -61
- package/src/maths/calculator/tpl/scientificScreen.tpl +3 -3
- package/src/mediaEditor/mediaEditorComponent.js +141 -141
- package/src/mediaEditor/plugins/mediaAlignment/helper.js +62 -62
- package/src/mediaEditor/plugins/mediaAlignment/mediaAlignmentComponent.js +99 -99
- package/src/mediaEditor/plugins/mediaAlignment/style.css +7 -7
- package/src/mediaEditor/plugins/mediaAlignment/tpl/mediaAlignment.tpl +25 -25
- package/src/mediaEditor/plugins/mediaDimension/helper.js +189 -189
- package/src/mediaEditor/plugins/mediaDimension/mediaDimensionComponent.js +561 -561
- package/src/mediaEditor/plugins/mediaDimension/style.css +141 -141
- package/src/mediaEditor/plugins/mediaDimension/tpl/mediaDimension.tpl +55 -55
- package/src/mediaEditor/tpl/editor.tpl +4 -4
- package/src/mediaplayer/css/player.css +7 -7
- package/src/mediaplayer/css/player.css.map +1 -1
- package/src/mediaplayer/players/html5.js +564 -564
- package/src/mediaplayer/players/youtube.js +323 -323
- package/src/mediaplayer/players.js +29 -29
- package/src/mediaplayer/readme.md +305 -305
- package/src/mediaplayer/scss/player.scss +569 -569
- package/src/mediaplayer/support.js +126 -126
- package/src/mediaplayer/tpl/audio.tpl +6 -6
- package/src/mediaplayer/tpl/player.tpl +37 -37
- package/src/mediaplayer/tpl/source.tpl +1 -1
- package/src/mediaplayer/tpl/video.tpl +6 -6
- package/src/mediaplayer/tpl/youtube.tpl +1 -1
- package/src/mediaplayer/utils/reminder.js +184 -184
- package/src/mediaplayer/utils/timeObserver.js +143 -143
- package/src/mediaplayer/youtubeManager.js +161 -161
- package/src/mediaplayer.js +1606 -1606
- package/src/mediasizer/mediasizer.tpl +55 -55
- package/src/mediasizer.js +635 -635
- package/src/modal.js +365 -365
- package/src/movableComponent.js +78 -78
- package/src/pageSizeSelector/tpl/pageSizeSelector.tpl +9 -9
- package/src/pageSizeSelector.js +107 -107
- package/src/pageStatus.js +147 -147
- package/src/pagination/css/pagination.css +7 -7
- package/src/pagination/css/pagination.css.map +1 -1
- package/src/pagination/paginationStrategy.js +53 -53
- package/src/pagination/providers/pages.js +161 -161
- package/src/pagination/providers/simple.js +74 -74
- package/src/pagination/providers/tpl/pages/page.tpl +1 -1
- package/src/pagination/providers/tpl/pages.tpl +8 -8
- package/src/pagination/providers/tpl/simple.tpl +7 -7
- package/src/pagination/scss/pagination.scss +111 -111
- package/src/pagination.js +237 -237
- package/src/previewer.js +300 -300
- package/src/progressbar.js +165 -165
- package/src/propertySelector/css/propertySelector.css +74 -0
- package/src/propertySelector/css/propertySelector.css.map +1 -0
- package/src/propertySelector/propertySelector.js +286 -0
- package/src/propertySelector/scss/propertySelector.scss +66 -0
- package/src/propertySelector/tpl/highlighted-text.tpl +1 -0
- package/src/propertySelector/tpl/property-description.tpl +13 -0
- package/src/propertySelector/tpl/property-selector.tpl +7 -0
- package/src/report/feedback.tpl +11 -11
- package/src/report/layout.tpl +10 -10
- package/src/report.js +184 -184
- package/src/resource/css/selector.css +7 -7
- package/src/resource/css/selector.css.map +1 -1
- package/src/resource/filters.js +208 -208
- package/src/resource/list.js +200 -200
- package/src/resource/scss/_filters.scss +26 -26
- package/src/resource/scss/_resource-list.scss +107 -107
- package/src/resource/scss/_resource-tree.scss +205 -205
- package/src/resource/scss/selector.scss +187 -187
- package/src/resource/selectable.js +322 -322
- package/src/resource/selector.js +871 -871
- package/src/resource/tpl/filters.tpl +2 -2
- package/src/resource/tpl/list.tpl +7 -7
- package/src/resource/tpl/listNode.tpl +4 -4
- package/src/resource/tpl/selector.tpl +46 -46
- package/src/resource/tpl/tree.tpl +4 -4
- package/src/resource/tpl/treeNode.tpl +30 -30
- package/src/resource/tree.js +400 -400
- package/src/resourcemgr/css/resourcemgr.css +7 -7
- package/src/resourcemgr/css/resourcemgr.css.map +1 -1
- package/src/resourcemgr/fileBrowser.js +381 -381
- package/src/resourcemgr/filePreview.js +73 -73
- package/src/resourcemgr/fileSelector.js +348 -348
- package/src/resourcemgr/scss/resourcemgr.scss +254 -254
- package/src/resourcemgr/tpl/fileSelect.tpl +39 -39
- package/src/resourcemgr/tpl/folder.tpl +11 -11
- package/src/resourcemgr/tpl/layout.tpl +84 -84
- package/src/resourcemgr/tpl/rootFolder.tpl +13 -13
- package/src/resourcemgr/util/updatePermissions.js +53 -53
- package/src/resourcemgr.js +216 -216
- package/src/scroller.js +94 -94
- package/src/scss/basic.scss +16 -16
- package/src/searchModal/advancedSearch.js +638 -601
- package/src/searchModal/css/advancedSearch.css +7 -14
- package/src/searchModal/css/advancedSearch.css.map +1 -1
- package/src/searchModal/css/searchModal.css +28 -8
- package/src/searchModal/css/searchModal.css.map +1 -1
- package/src/searchModal/scss/advancedSearch.scss +171 -177
- package/src/searchModal/scss/searchModal.scss +393 -375
- package/src/searchModal/tpl/advanced-search.tpl +9 -9
- package/src/searchModal/tpl/criteria-alias.tpl +1 -0
- package/src/searchModal/tpl/criteria-class-label.tpl +1 -0
- package/src/searchModal/tpl/criteria-label.tpl +1 -0
- package/src/searchModal/tpl/highlighted-text.tpl +1 -0
- package/src/searchModal/tpl/info-message.tpl +3 -3
- package/src/searchModal/tpl/invalid-criteria-warning.tpl +10 -10
- package/src/searchModal/tpl/layout.tpl +27 -25
- package/src/searchModal/tpl/list-checkbox-criterion.tpl +17 -12
- package/src/searchModal/tpl/list-select-criterion.tpl +12 -6
- package/src/searchModal/tpl/property-select-button.tpl +1 -0
- package/src/searchModal/tpl/results-container.tpl +1 -0
- package/src/searchModal/tpl/text-criterion.tpl +11 -6
- package/src/searchModal.js +761 -496
- package/src/selecter.js +43 -43
- package/src/stacker.js +133 -133
- package/src/switch/css/switch.css +7 -7
- package/src/switch/css/switch.css.map +1 -1
- package/src/switch/scss/switch.scss +83 -83
- package/src/switch/switch.js +195 -195
- package/src/switch/tpl/switch.tpl +7 -7
- package/src/tableModel.js +112 -112
- package/src/tabs/css/tabs.css +12 -12
- package/src/tabs/css/tabs.css.map +1 -1
- package/src/tabs/scss/tabs.scss +50 -50
- package/src/tabs/tpl/panel.tpl +3 -3
- package/src/tabs/tpl/tabs.tpl +10 -10
- package/src/tabs.js +528 -528
- package/src/taskQueue/css/taskQueue.css +7 -7
- package/src/taskQueue/css/taskQueue.css.map +1 -1
- package/src/taskQueue/scss/taskQueue.scss +47 -47
- package/src/taskQueue/status.js +228 -228
- package/src/taskQueue/table.js +350 -350
- package/src/taskQueue/taskQueue.js +33 -33
- package/src/taskQueue/taskQueueModel.js +548 -548
- package/src/taskQueue/tpl/statusMessage.tpl +7 -7
- package/src/taskQueue.js +218 -218
- package/src/taskQueueButton/css/taskable.css +7 -7
- package/src/taskQueueButton/css/taskable.css.map +1 -1
- package/src/taskQueueButton/css/treeButton.css +7 -7
- package/src/taskQueueButton/css/treeButton.css.map +1 -1
- package/src/taskQueueButton/scss/taskable.scss +4 -4
- package/src/taskQueueButton/scss/treeButton.scss +34 -34
- package/src/taskQueueButton/standardButton.js +108 -108
- package/src/taskQueueButton/taskable.js +202 -202
- package/src/taskQueueButton/tpl/report.tpl +5 -5
- package/src/taskQueueButton/tpl/treeButton.tpl +6 -6
- package/src/taskQueueButton/treeButton.js +109 -109
- package/src/themeLoader.js +252 -252
- package/src/themes.js +162 -162
- package/src/toggler.js +200 -200
- package/src/tooltip/default.tpl +3 -3
- package/src/tooltip.js +160 -160
- package/src/tooltipster.js +25 -25
- package/src/transformer.js +327 -327
- package/src/tristateCheckboxGroup/css/tristateCheckboxGroup.css +7 -7
- package/src/tristateCheckboxGroup/css/tristateCheckboxGroup.css.map +1 -1
- package/src/tristateCheckboxGroup/scss/tristateCheckboxGroup.scss +15 -15
- package/src/tristateCheckboxGroup/tpl/li.tpl +6 -6
- package/src/tristateCheckboxGroup.js +207 -207
- package/src/uploader/fileEntry.tpl +6 -6
- package/src/uploader/uploader.tpl +32 -32
- package/src/uploader.js +594 -594
- package/src/validator/Report.js +10 -10
- package/src/validator/Validator.js +108 -108
- package/src/validator/validators.js +220 -220
- package/src/validator.js +264 -264
- package/src/waitForMedia.js +82 -82
- package/src/waitingDialog/css/waitingDialog.css +7 -7
- package/src/waitingDialog/css/waitingDialog.css.map +1 -1
- package/src/waitingDialog/scss/waitingDialog.scss +34 -34
- package/src/waitingDialog/waitingDialog.js +240 -240
package/dist/mediaplayer.js
CHANGED
|
@@ -1,1876 +1,1586 @@
|
|
|
1
1
|
define(['jquery', 'lodash', 'async', 'util/urlParser', 'core/eventifier', 'core/mimetype', 'core/store', 'ui/mediaplayer/support', 'ui/mediaplayer/players', 'handlebars', 'i18n', 'lib/dompurify/purify', 'css!ui/mediaplayer/css/player.css', 'nouislider'], function ($$1, _, async, UrlParser, eventifier, mimetype, store, support, players, Handlebars, __, DOMPurify, player_css, nouislider) { 'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* https://github.com/cure53/DOMPurify
|
|
35
|
-
* with config SAFE_FOR_TEMPLATES: true
|
|
36
|
-
* to make output safe for template systems
|
|
37
|
-
*/
|
|
38
|
-
|
|
39
|
-
hb.registerHelper('dompurify', function (context) {
|
|
40
|
-
return DOMPurify.sanitize(context);
|
|
41
|
-
});
|
|
42
|
-
/**
|
|
43
|
-
* Register join helper
|
|
44
|
-
*
|
|
45
|
-
* Example :
|
|
46
|
-
* var values = {a:v1, b:v2, c:v3};
|
|
47
|
-
* Using {{{join attributes '=' ' ' '"'}}} will return : a="v1" b="v2" c="v3"
|
|
48
|
-
* Using {{{join values null ' or ' '*'}}} will return : *v1* or *v2* or *v3*
|
|
3
|
+
$$1 = $$1 && Object.prototype.hasOwnProperty.call($$1, 'default') ? $$1['default'] : $$1;
|
|
4
|
+
_ = _ && Object.prototype.hasOwnProperty.call(_, 'default') ? _['default'] : _;
|
|
5
|
+
async = async && Object.prototype.hasOwnProperty.call(async, 'default') ? async['default'] : async;
|
|
6
|
+
UrlParser = UrlParser && Object.prototype.hasOwnProperty.call(UrlParser, 'default') ? UrlParser['default'] : UrlParser;
|
|
7
|
+
eventifier = eventifier && Object.prototype.hasOwnProperty.call(eventifier, 'default') ? eventifier['default'] : eventifier;
|
|
8
|
+
mimetype = mimetype && Object.prototype.hasOwnProperty.call(mimetype, 'default') ? mimetype['default'] : mimetype;
|
|
9
|
+
store = store && Object.prototype.hasOwnProperty.call(store, 'default') ? store['default'] : store;
|
|
10
|
+
support = support && Object.prototype.hasOwnProperty.call(support, 'default') ? support['default'] : support;
|
|
11
|
+
players = players && Object.prototype.hasOwnProperty.call(players, 'default') ? players['default'] : players;
|
|
12
|
+
Handlebars = Handlebars && Object.prototype.hasOwnProperty.call(Handlebars, 'default') ? Handlebars['default'] : Handlebars;
|
|
13
|
+
__ = __ && Object.prototype.hasOwnProperty.call(__, 'default') ? __['default'] : __;
|
|
14
|
+
DOMPurify = DOMPurify && Object.prototype.hasOwnProperty.call(DOMPurify, 'default') ? DOMPurify['default'] : DOMPurify;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* This program is free software; you can redistribute it and/or
|
|
18
|
+
* modify it under the terms of the GNU General Public License
|
|
19
|
+
* as published by the Free Software Foundation; under version 2
|
|
20
|
+
* of the License (non-upgradable).
|
|
21
|
+
*
|
|
22
|
+
* This program is distributed in the hope that it will be useful,
|
|
23
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
24
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
25
|
+
* GNU General Public License for more details.
|
|
26
|
+
*
|
|
27
|
+
* You should have received a copy of the GNU General Public License
|
|
28
|
+
* along with this program; if not, write to the Free Software
|
|
29
|
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
30
|
+
*
|
|
31
|
+
* Copyright (c) 2013-2019 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
|
|
32
|
+
*
|
|
33
|
+
*
|
|
49
34
|
*/
|
|
35
|
+
function Helpers0 (hb) {
|
|
36
|
+
//register a i18n helper
|
|
37
|
+
hb.registerHelper('__', function (key) {
|
|
38
|
+
return __(key);
|
|
39
|
+
});
|
|
50
40
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Register dompurify helper
|
|
43
|
+
*
|
|
44
|
+
* https://github.com/cure53/DOMPurify
|
|
45
|
+
* with config SAFE_FOR_TEMPLATES: true
|
|
46
|
+
* to make output safe for template systems
|
|
47
|
+
*/
|
|
48
|
+
hb.registerHelper('dompurify', function (context) {
|
|
49
|
+
return DOMPurify.sanitize(context);
|
|
50
|
+
});
|
|
59
51
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
52
|
+
/**
|
|
53
|
+
* Register join helper
|
|
54
|
+
*
|
|
55
|
+
* Example :
|
|
56
|
+
* var values = {a:v1, b:v2, c:v3};
|
|
57
|
+
* Using {{{join attributes '=' ' ' '"'}}} will return : a="v1" b="v2" c="v3"
|
|
58
|
+
* Using {{{join values null ' or ' '*'}}} will return : *v1* or *v2* or *v3*
|
|
59
|
+
*/
|
|
60
|
+
hb.registerHelper('join', function (arr, keyValueGlue, fragmentGlue, wrapper) {
|
|
61
|
+
var fragments = [];
|
|
62
|
+
keyValueGlue = typeof keyValueGlue === 'string' ? keyValueGlue : undefined;
|
|
63
|
+
fragmentGlue = typeof fragmentGlue === 'string' ? fragmentGlue : ' ';
|
|
64
|
+
wrapper = typeof wrapper === 'string' ? wrapper : '"';
|
|
65
|
+
_.forIn(arr, function (value, key) {
|
|
66
|
+
var fragment = '';
|
|
67
|
+
if (value !== null || value !== undefined) {
|
|
68
|
+
if (typeof value === 'boolean') {
|
|
69
|
+
value = value ? 'true' : 'false';
|
|
70
|
+
} else if (typeof value === 'object') {
|
|
71
|
+
value = _.values(value).join(' ');
|
|
72
|
+
}
|
|
73
|
+
} else {
|
|
74
|
+
value = '';
|
|
65
75
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
76
|
+
if (keyValueGlue !== undefined) {
|
|
77
|
+
fragment += key + keyValueGlue;
|
|
78
|
+
}
|
|
79
|
+
fragment += wrapper + value + wrapper;
|
|
80
|
+
fragments.push(fragment);
|
|
81
|
+
});
|
|
82
|
+
return fragments.join(fragmentGlue);
|
|
83
|
+
});
|
|
69
84
|
|
|
70
|
-
|
|
71
|
-
|
|
85
|
+
//register a classic "for loop" helper
|
|
86
|
+
//it also adds a local variable "i" as the index in each iteration loop
|
|
87
|
+
hb.registerHelper('for', function (startIndex, stopIndex, increment, options) {
|
|
88
|
+
var ret = '';
|
|
89
|
+
startIndex = parseInt(startIndex);
|
|
90
|
+
stopIndex = parseInt(stopIndex);
|
|
91
|
+
increment = parseInt(increment);
|
|
92
|
+
for (var i = startIndex; i < stopIndex; i += increment) {
|
|
93
|
+
ret += options.fn(_.extend({}, this, {
|
|
94
|
+
i: i
|
|
95
|
+
}));
|
|
96
|
+
}
|
|
97
|
+
return ret;
|
|
98
|
+
});
|
|
99
|
+
hb.registerHelper('equal', function (var1, var2, options) {
|
|
100
|
+
if (var1 == var2) {
|
|
101
|
+
return options.fn(this);
|
|
102
|
+
} else {
|
|
103
|
+
return options.inverse(this);
|
|
72
104
|
}
|
|
73
|
-
|
|
74
|
-
fragment += wrapper + value + wrapper;
|
|
75
|
-
fragments.push(fragment);
|
|
76
105
|
});
|
|
77
106
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
var ret = '';
|
|
84
|
-
startIndex = parseInt(startIndex);
|
|
85
|
-
stopIndex = parseInt(stopIndex);
|
|
86
|
-
increment = parseInt(increment);
|
|
87
|
-
|
|
88
|
-
for (var i = startIndex; i < stopIndex; i += increment) {
|
|
89
|
-
ret += options.fn(_.extend({}, this, {
|
|
90
|
-
i: i
|
|
91
|
-
}));
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return ret;
|
|
95
|
-
});
|
|
96
|
-
hb.registerHelper('equal', function (var1, var2, options) {
|
|
97
|
-
if (var1 == var2) {
|
|
98
|
-
return options.fn(this);
|
|
99
|
-
} else {
|
|
100
|
-
return options.inverse(this);
|
|
101
|
-
}
|
|
102
|
-
}); // register a "get property" helper
|
|
103
|
-
// it gets the named property from the provided context
|
|
104
|
-
|
|
105
|
-
hb.registerHelper('property', function (name, context) {
|
|
106
|
-
return context[name] || '';
|
|
107
|
-
}); // register an 'includes' helper
|
|
108
|
-
// it checks if value is in array
|
|
109
|
-
|
|
110
|
-
hb.registerHelper('includes', function (haystack, needle, options) {
|
|
111
|
-
if (_.contains(haystack, needle)) {
|
|
112
|
-
return options.fn(this);
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
if (!Helpers0.__initialized) {
|
|
118
|
-
Helpers0(Handlebars);
|
|
119
|
-
Helpers0.__initialized = true;
|
|
120
|
-
}
|
|
121
|
-
var Template = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
|
|
122
|
-
this.compilerInfo = [4,'>= 1.0.0'];
|
|
123
|
-
helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|
124
|
-
var buffer = "", stack1, helper, options, functionType="function", escapeExpression=this.escapeExpression, helperMissing=helpers.helperMissing;
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
buffer += "<div class=\"mediaplayer ";
|
|
128
|
-
if (helper = helpers.type) { stack1 = helper.call(depth0, {hash:{},data:data}); }
|
|
129
|
-
else { helper = (depth0 && depth0.type); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
|
|
130
|
-
buffer += escapeExpression(stack1)
|
|
131
|
-
+ "\">\r\n <div class=\"player\">\r\n <div class=\"player-overlay\">\r\n <a class=\"action play\" data-control=\"play\"><span class=\"icon icon-play\" title=\""
|
|
132
|
-
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Play", options) : helperMissing.call(depth0, "__", "Play", options)))
|
|
133
|
-
+ "\"></span></a>\r\n <a class=\"action play\" data-control=\"pause\"><span class=\"icon icon-pause\" title=\""
|
|
134
|
-
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Pause", options) : helperMissing.call(depth0, "__", "Pause", options)))
|
|
135
|
-
+ "\"></span></a>\r\n <a class=\"action reload\" data-control=\"start\">\r\n <span class=\"icon icon-play\" title=\""
|
|
136
|
-
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Start", options) : helperMissing.call(depth0, "__", "Start", options)))
|
|
137
|
-
+ "\"></span>\r\n <div class=\"message\">"
|
|
138
|
-
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Click to start", options) : helperMissing.call(depth0, "__", "Click to start", options)))
|
|
139
|
-
+ "</div>\r\n </a>\r\n <a class=\"action reload\" data-control=\"reload\">\r\n <div class=\"icon icon-reload\" title=\""
|
|
140
|
-
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Reload", options) : helperMissing.call(depth0, "__", "Reload", options)))
|
|
141
|
-
+ "\"></div>\r\n <div class=\"message\">"
|
|
142
|
-
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "You are encountering a prolonged connectivity loss.", options) : helperMissing.call(depth0, "__", "You are encountering a prolonged connectivity loss.", options)))
|
|
143
|
-
+ " "
|
|
144
|
-
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Click to reload.", options) : helperMissing.call(depth0, "__", "Click to reload.", options)))
|
|
145
|
-
+ "</div>\r\n </a>\r\n </div>\r\n </div>\r\n <div class=\"controls\">\r\n <div class=\"bar\">\r\n <div class=\"control actions playback\">\r\n <a class=\"action play\" data-control=\"play\" title=\""
|
|
146
|
-
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Play", options) : helperMissing.call(depth0, "__", "Play", options)))
|
|
147
|
-
+ "\"><span class=\"icon icon-play\"></span></a>\r\n <a class=\"action play\" data-control=\"pause\" title=\""
|
|
148
|
-
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Pause", options) : helperMissing.call(depth0, "__", "Pause", options)))
|
|
149
|
-
+ "\"><span class=\"icon icon-pause\"></span></a>\r\n </div>\r\n <div class=\"control seek\"><div class=\"slider\"></div></div>\r\n <div class=\"control infos timer\">\r\n <span class=\"info time\" data-control=\"time-cur\" title=\""
|
|
150
|
-
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Current playback position", options) : helperMissing.call(depth0, "__", "Current playback position", options)))
|
|
151
|
-
+ "\">--:--</span>\r\n <span class=\"info time\" data-control=\"time-end\" title=\""
|
|
152
|
-
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Total duration", options) : helperMissing.call(depth0, "__", "Total duration", options)))
|
|
153
|
-
+ "\">--:--</span>\r\n </div>\r\n <div class=\"control actions sound\">\r\n <div class=\"volume\"><div class=\"slider\"></div></div>\r\n <a class=\"action mute\" data-control=\"mute\" title=\""
|
|
154
|
-
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Mute", options) : helperMissing.call(depth0, "__", "Mute", options)))
|
|
155
|
-
+ "\"><span class=\"icon icon-sound\"></span></a>\r\n <a class=\"action mute\" data-control=\"unmute\" title=\""
|
|
156
|
-
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Restore sound", options) : helperMissing.call(depth0, "__", "Restore sound", options)))
|
|
157
|
-
+ "\"><span class=\"icon icon-mute\"></span></a>\r\n </div>\r\n </div>\r\n </div>\r\n <div class=\"error\">\r\n <div class=\"message\">"
|
|
158
|
-
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "This media cannot be played!", options) : helperMissing.call(depth0, "__", "This media cannot be played!", options)))
|
|
159
|
-
+ "</div>\r\n </div>\r\n</div>\r\n";
|
|
160
|
-
return buffer;
|
|
161
|
-
});
|
|
162
|
-
function playerTpl(data, options, asString) {
|
|
163
|
-
var html = Template(data, options);
|
|
164
|
-
return (asString || true) ? html : $(html);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* This program is free software; you can redistribute it and/or
|
|
169
|
-
* modify it under the terms of the GNU General Public License
|
|
170
|
-
* as published by the Free Software Foundation; under version 2
|
|
171
|
-
* of the License (non-upgradable).
|
|
172
|
-
*
|
|
173
|
-
* This program is distributed in the hope that it will be useful,
|
|
174
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
175
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
176
|
-
* GNU General Public License for more details.
|
|
177
|
-
*
|
|
178
|
-
* You should have received a copy of the GNU General Public License
|
|
179
|
-
* along with this program; if not, write to the Free Software
|
|
180
|
-
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
181
|
-
*
|
|
182
|
-
* Copyright (c) 2015-2021 (original work) Open Assessment Technologies SA ;
|
|
183
|
-
*/
|
|
184
|
-
/**
|
|
185
|
-
* CSS namespace
|
|
186
|
-
* @type {String}
|
|
187
|
-
*/
|
|
188
|
-
|
|
189
|
-
var ns = '.mediaplayer';
|
|
190
|
-
/**
|
|
191
|
-
* Minimum value of the volume
|
|
192
|
-
* @type {Number}
|
|
193
|
-
*/
|
|
194
|
-
|
|
195
|
-
var volumeMin = 0;
|
|
196
|
-
/**
|
|
197
|
-
* Maximum value of the volume
|
|
198
|
-
* @type {Number}
|
|
199
|
-
*/
|
|
200
|
-
|
|
201
|
-
var volumeMax = 100;
|
|
202
|
-
/**
|
|
203
|
-
* Threshold (minimum required space above the player) to display the volume
|
|
204
|
-
* above the bar.
|
|
205
|
-
* @type {Number}
|
|
206
|
-
*/
|
|
207
|
-
|
|
208
|
-
var volumePositionThreshold = 200;
|
|
209
|
-
/**
|
|
210
|
-
* Some default values
|
|
211
|
-
* @type {Object}
|
|
212
|
-
*/
|
|
107
|
+
// register a "get property" helper
|
|
108
|
+
// it gets the named property from the provided context
|
|
109
|
+
hb.registerHelper('property', function (name, context) {
|
|
110
|
+
return context[name] || '';
|
|
111
|
+
});
|
|
213
112
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
width: '100%',
|
|
222
|
-
height: 'auto'
|
|
223
|
-
},
|
|
224
|
-
youtube: {
|
|
225
|
-
width: 640,
|
|
226
|
-
height: 360
|
|
227
|
-
},
|
|
228
|
-
options: {
|
|
229
|
-
volume: 80,
|
|
230
|
-
startMuted: false,
|
|
231
|
-
maxPlays: 0,
|
|
232
|
-
replayTimeout: 0,
|
|
233
|
-
canPause: true,
|
|
234
|
-
canSeek: true,
|
|
235
|
-
loop: false,
|
|
236
|
-
autoStart: false,
|
|
237
|
-
preview: true,
|
|
238
|
-
debug: false
|
|
113
|
+
// register an 'includes' helper
|
|
114
|
+
// it checks if value is in array
|
|
115
|
+
hb.registerHelper('includes', function (haystack, needle, options) {
|
|
116
|
+
if (_.contains(haystack, needle)) {
|
|
117
|
+
return options.fn(this);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
239
120
|
}
|
|
240
|
-
};
|
|
241
|
-
/**
|
|
242
|
-
* Ensures a value is a number
|
|
243
|
-
* @param {Number|String} value
|
|
244
|
-
* @returns {Number}
|
|
245
|
-
*/
|
|
246
|
-
|
|
247
|
-
var ensureNumber = function ensureNumber(value) {
|
|
248
|
-
var floatValue = parseFloat(value);
|
|
249
|
-
return isFinite(floatValue) ? floatValue : 0;
|
|
250
|
-
};
|
|
251
|
-
/**
|
|
252
|
-
* Format a number to string with leading zeros
|
|
253
|
-
* @param {Number} n
|
|
254
|
-
* @param {Number} len
|
|
255
|
-
* @returns {String}
|
|
256
|
-
*/
|
|
257
121
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
while (value.length < len) {
|
|
263
|
-
value = "0".concat(value);
|
|
122
|
+
if (!Helpers0.__initialized) {
|
|
123
|
+
Helpers0(Handlebars);
|
|
124
|
+
Helpers0.__initialized = true;
|
|
264
125
|
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
126
|
+
var Template = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
|
|
127
|
+
this.compilerInfo = [4,'>= 1.0.0'];
|
|
128
|
+
helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|
129
|
+
var buffer = "", stack1, helper, options, functionType="function", escapeExpression=this.escapeExpression, helperMissing=helpers.helperMissing;
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
buffer += "<div class=\"mediaplayer ";
|
|
133
|
+
if (helper = helpers.type) { stack1 = helper.call(depth0, {hash:{},data:data}); }
|
|
134
|
+
else { helper = (depth0 && depth0.type); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
|
|
135
|
+
buffer += escapeExpression(stack1)
|
|
136
|
+
+ "\">\n <div class=\"player\">\n <div class=\"player-overlay\">\n <a class=\"action play\" data-control=\"play\"><span class=\"icon icon-play\" title=\""
|
|
137
|
+
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Play", options) : helperMissing.call(depth0, "__", "Play", options)))
|
|
138
|
+
+ "\"></span></a>\n <a class=\"action play\" data-control=\"pause\"><span class=\"icon icon-pause\" title=\""
|
|
139
|
+
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Pause", options) : helperMissing.call(depth0, "__", "Pause", options)))
|
|
140
|
+
+ "\"></span></a>\n <a class=\"action reload\" data-control=\"start\">\n <span class=\"icon icon-play\" title=\""
|
|
141
|
+
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Start", options) : helperMissing.call(depth0, "__", "Start", options)))
|
|
142
|
+
+ "\"></span>\n <div class=\"message\">"
|
|
143
|
+
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Click to start", options) : helperMissing.call(depth0, "__", "Click to start", options)))
|
|
144
|
+
+ "</div>\n </a>\n <a class=\"action reload\" data-control=\"reload\">\n <div class=\"icon icon-reload\" title=\""
|
|
145
|
+
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Reload", options) : helperMissing.call(depth0, "__", "Reload", options)))
|
|
146
|
+
+ "\"></div>\n <div class=\"message\">"
|
|
147
|
+
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "You are encountering a prolonged connectivity loss.", options) : helperMissing.call(depth0, "__", "You are encountering a prolonged connectivity loss.", options)))
|
|
148
|
+
+ " "
|
|
149
|
+
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Click to reload.", options) : helperMissing.call(depth0, "__", "Click to reload.", options)))
|
|
150
|
+
+ "</div>\n </a>\n </div>\n </div>\n <div class=\"controls\">\n <div class=\"bar\">\n <div class=\"control actions playback\">\n <a class=\"action play\" data-control=\"play\" title=\""
|
|
151
|
+
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Play", options) : helperMissing.call(depth0, "__", "Play", options)))
|
|
152
|
+
+ "\"><span class=\"icon icon-play\"></span></a>\n <a class=\"action play\" data-control=\"pause\" title=\""
|
|
153
|
+
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Pause", options) : helperMissing.call(depth0, "__", "Pause", options)))
|
|
154
|
+
+ "\"><span class=\"icon icon-pause\"></span></a>\n </div>\n <div class=\"control seek\"><div class=\"slider\"></div></div>\n <div class=\"control infos timer\">\n <span class=\"info time\" data-control=\"time-cur\" title=\""
|
|
155
|
+
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Current playback position", options) : helperMissing.call(depth0, "__", "Current playback position", options)))
|
|
156
|
+
+ "\">--:--</span>\n <span class=\"info time\" data-control=\"time-end\" title=\""
|
|
157
|
+
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Total duration", options) : helperMissing.call(depth0, "__", "Total duration", options)))
|
|
158
|
+
+ "\">--:--</span>\n </div>\n <div class=\"control actions sound\">\n <div class=\"volume\"><div class=\"slider\"></div></div>\n <a class=\"action mute\" data-control=\"mute\" title=\""
|
|
159
|
+
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Mute", options) : helperMissing.call(depth0, "__", "Mute", options)))
|
|
160
|
+
+ "\"><span class=\"icon icon-sound\"></span></a>\n <a class=\"action mute\" data-control=\"unmute\" title=\""
|
|
161
|
+
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Restore sound", options) : helperMissing.call(depth0, "__", "Restore sound", options)))
|
|
162
|
+
+ "\"><span class=\"icon icon-mute\"></span></a>\n </div>\n </div>\n </div>\n <div class=\"error\">\n <div class=\"message\">"
|
|
163
|
+
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "This media cannot be played!", options) : helperMissing.call(depth0, "__", "This media cannot be played!", options)))
|
|
164
|
+
+ "</div>\n </div>\n</div>\n";
|
|
165
|
+
return buffer;
|
|
166
|
+
});
|
|
167
|
+
function playerTpl(data, options, asString) {
|
|
168
|
+
var html = Template(data, options);
|
|
169
|
+
return (asString || true) ? html : $(html);
|
|
283
170
|
}
|
|
284
171
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
* @returns {String}
|
|
303
|
-
*/
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
var getAdjustedType = function getAdjustedType(source) {
|
|
307
|
-
var type = 'video/ogg';
|
|
308
|
-
var url = source && source.src || source;
|
|
309
|
-
var ext = url && url.substr(-4);
|
|
310
|
-
|
|
311
|
-
if (ext === '.ogg' || ext === '.oga') {
|
|
312
|
-
type = 'audio/ogg';
|
|
313
|
-
}
|
|
172
|
+
/**
|
|
173
|
+
* This program is free software; you can redistribute it and/or
|
|
174
|
+
* modify it under the terms of the GNU General Public License
|
|
175
|
+
* as published by the Free Software Foundation; under version 2
|
|
176
|
+
* of the License (non-upgradable).
|
|
177
|
+
*
|
|
178
|
+
* This program is distributed in the hope that it will be useful,
|
|
179
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
180
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
181
|
+
* GNU General Public License for more details.
|
|
182
|
+
*
|
|
183
|
+
* You should have received a copy of the GNU General Public License
|
|
184
|
+
* along with this program; if not, write to the Free Software
|
|
185
|
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
186
|
+
*
|
|
187
|
+
* Copyright (c) 2015-2021 (original work) Open Assessment Technologies SA ;
|
|
188
|
+
*/
|
|
314
189
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
* @returns {Array}
|
|
321
|
-
*/
|
|
190
|
+
/**
|
|
191
|
+
* CSS namespace
|
|
192
|
+
* @type {String}
|
|
193
|
+
*/
|
|
194
|
+
const ns = '.mediaplayer';
|
|
322
195
|
|
|
196
|
+
/**
|
|
197
|
+
* Minimum value of the volume
|
|
198
|
+
* @type {Number}
|
|
199
|
+
*/
|
|
200
|
+
const volumeMin = 0;
|
|
323
201
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
202
|
+
/**
|
|
203
|
+
* Maximum value of the volume
|
|
204
|
+
* @type {Number}
|
|
205
|
+
*/
|
|
206
|
+
const volumeMax = 100;
|
|
327
207
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
208
|
+
/**
|
|
209
|
+
* Threshold (minimum required space above the player) to display the volume
|
|
210
|
+
* above the bar.
|
|
211
|
+
* @type {Number}
|
|
212
|
+
*/
|
|
213
|
+
const volumePositionThreshold = 200;
|
|
331
214
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
215
|
+
/**
|
|
216
|
+
* Some default values
|
|
217
|
+
* @type {Object}
|
|
218
|
+
*/
|
|
219
|
+
const defaults = {
|
|
220
|
+
type: 'video/mp4',
|
|
221
|
+
video: {
|
|
222
|
+
width: '100%',
|
|
223
|
+
height: 'auto'
|
|
224
|
+
},
|
|
225
|
+
audio: {
|
|
226
|
+
width: '100%',
|
|
227
|
+
height: 'auto'
|
|
228
|
+
},
|
|
229
|
+
youtube: {
|
|
230
|
+
width: 640,
|
|
231
|
+
height: 360
|
|
232
|
+
},
|
|
233
|
+
options: {
|
|
234
|
+
volume: 80,
|
|
235
|
+
startMuted: false,
|
|
236
|
+
maxPlays: 0,
|
|
237
|
+
replayTimeout: 0,
|
|
238
|
+
canPause: true,
|
|
239
|
+
canSeek: true,
|
|
240
|
+
loop: false,
|
|
241
|
+
autoStart: false,
|
|
242
|
+
preview: true,
|
|
243
|
+
debug: false
|
|
335
244
|
}
|
|
245
|
+
};
|
|
336
246
|
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
*/
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
var isResponsiveSize = function isResponsiveSize(sizeProps) {
|
|
350
|
-
return /%/.test(sizeProps) || sizeProps === 'auto';
|
|
351
|
-
};
|
|
352
|
-
/**
|
|
353
|
-
* Builds a media player instance
|
|
354
|
-
* @param {Object} config
|
|
355
|
-
* @param {String} config.type - The type of media to play, say `audio`, `video`, or `youtube`. The default is `video`.
|
|
356
|
-
* It might also contain the MIME type of the media as a shorthand.
|
|
357
|
-
* @param {String|Array} [config.url] - The URL to the media. If several media are proposed as alternatives,
|
|
358
|
-
* please look at the `sources` option instead.
|
|
359
|
-
* @param {String} [config.mimeType] - The MIME type of the media. If omitted, the player will try to extract it
|
|
360
|
-
* from the `type` property, otherwise it will request the server to get the content-type.
|
|
361
|
-
* @param {Array} [config.sources] - A list of URL if several media can be proposed. Each entry may be either a
|
|
362
|
-
* string (single URL), or an object containing both the URL and the MIME type ({src: string, type: string}).
|
|
363
|
-
* @param {String|jQuery|HTMLElement} [config.renderTo] - An optional container in which renders the player
|
|
364
|
-
* @param {Boolean} [config.canSeek] - The player allows to reach an arbitrary position within the media using the duration bar
|
|
365
|
-
* @param {Boolean} [config.loop] - The media will be played continuously
|
|
366
|
-
* @param {Boolean} [config.canPause] - The player can be paused
|
|
367
|
-
* @param {Boolean} [config.startMuted] - The player should be initially muted
|
|
368
|
-
* @param {Boolean} [config.autoStart] - The player starts as soon as it is displayed
|
|
369
|
-
* @param {Number} [config.autoStartAt] - The time position at which the player should start
|
|
370
|
-
* @param {Number} [config.maxPlays] - Sets a few number of plays (default: infinite)
|
|
371
|
-
* @param {Number} [config.replayTimeout] - disable the possibility to replay a media after this timeout, in seconds (default: 0)
|
|
372
|
-
* @param {Number} [config.volume] - Sets the sound volume (default: 80)
|
|
373
|
-
* @param {Number} [config.width] - Sets the width of the player (default: depends on media type)
|
|
374
|
-
* @param {Number} [config.height] - Sets the height of the player (default: depends on media type)
|
|
375
|
-
* @param {Boolean} [config.preview] - Enables the media preview (load media metadata)
|
|
376
|
-
* @param {Boolean} [config.debug] - Enables the debug mode
|
|
377
|
-
* @param {number} [config.config.stalledDetectionDelay] - The delay before considering a media is stalled
|
|
378
|
-
* @event render - Event triggered when the player is rendering
|
|
379
|
-
* @event error - Event triggered when the player throws an unrecoverable error
|
|
380
|
-
* @event ready - Event triggered when the player is fully ready
|
|
381
|
-
* @event play - Event triggered when the playback is starting
|
|
382
|
-
* @event update - Event triggered while the player is playing
|
|
383
|
-
* @event pause - Event triggered when the playback is paused
|
|
384
|
-
* @event ended - Event triggered when the playback is ended
|
|
385
|
-
* @event limitreached - Event triggered when the play limit has been reached
|
|
386
|
-
* @event destroy - Event triggered when the player is destroying
|
|
387
|
-
* @returns {mediaplayer}
|
|
388
|
-
*/
|
|
247
|
+
/**
|
|
248
|
+
* Ensures a value is a number
|
|
249
|
+
* @param {Number|String} value
|
|
250
|
+
* @returns {Number}
|
|
251
|
+
*/
|
|
252
|
+
const ensureNumber = value => {
|
|
253
|
+
const floatValue = parseFloat(value);
|
|
254
|
+
return isFinite(floatValue) ? floatValue : 0;
|
|
255
|
+
};
|
|
389
256
|
|
|
257
|
+
/**
|
|
258
|
+
* Format a number to string with leading zeros
|
|
259
|
+
* @param {Number} n
|
|
260
|
+
* @param {Number} len
|
|
261
|
+
* @returns {String}
|
|
262
|
+
*/
|
|
263
|
+
const leadingZero = (n, len) => {
|
|
264
|
+
let value = n.toString();
|
|
265
|
+
while (value.length < len) {
|
|
266
|
+
value = `0${value}`;
|
|
267
|
+
}
|
|
268
|
+
return value;
|
|
269
|
+
};
|
|
390
270
|
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
*
|
|
394
|
-
* @
|
|
271
|
+
/**
|
|
272
|
+
* Formats a time value to string
|
|
273
|
+
* @param {Number} time
|
|
274
|
+
* @returns {String}
|
|
395
275
|
*/
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
276
|
+
const timerFormat = time => {
|
|
277
|
+
const seconds = Math.floor(time % 60);
|
|
278
|
+
const minutes = Math.floor(time / 60) % 60;
|
|
279
|
+
const hours = Math.floor(time / 3600);
|
|
280
|
+
const parts = [];
|
|
281
|
+
if (hours) {
|
|
282
|
+
parts.push(hours);
|
|
283
|
+
}
|
|
284
|
+
parts.push(leadingZero(minutes, 2));
|
|
285
|
+
parts.push(leadingZero(seconds, 2));
|
|
286
|
+
return parts.join(':');
|
|
287
|
+
};
|
|
404
288
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
289
|
+
/**
|
|
290
|
+
* Checks if a type needs to be adjusted
|
|
291
|
+
* @param {String} type
|
|
292
|
+
* @returns {Boolean}
|
|
293
|
+
*/
|
|
294
|
+
const needTypeAdjust = type => {
|
|
295
|
+
return 'string' === typeof type && type.indexOf('application') === 0;
|
|
296
|
+
};
|
|
409
297
|
|
|
410
|
-
|
|
298
|
+
/**
|
|
299
|
+
* Adjust bad type by apllying heuristic on URI
|
|
300
|
+
* @param {Object|String} source
|
|
301
|
+
* @returns {String}
|
|
302
|
+
*/
|
|
303
|
+
const getAdjustedType = source => {
|
|
304
|
+
let type = 'video/ogg';
|
|
305
|
+
const url = source && source.src || source;
|
|
306
|
+
const ext = url && url.substr(-4);
|
|
307
|
+
if (ext === '.ogg' || ext === '.oga') {
|
|
308
|
+
type = 'audio/ogg';
|
|
309
|
+
}
|
|
310
|
+
return type;
|
|
311
|
+
};
|
|
411
312
|
|
|
412
|
-
|
|
413
|
-
|
|
313
|
+
/**
|
|
314
|
+
* Extract a list of media sources from a config object
|
|
315
|
+
* @param {Object} config
|
|
316
|
+
* @returns {Array}
|
|
317
|
+
*/
|
|
318
|
+
const configToSources = config => {
|
|
319
|
+
let sources = config.sources || [];
|
|
320
|
+
let url = config.url;
|
|
321
|
+
if (!_.isArray(sources)) {
|
|
322
|
+
sources = [sources];
|
|
323
|
+
}
|
|
324
|
+
if (url) {
|
|
325
|
+
if (!_.isArray(config.url)) {
|
|
326
|
+
url = [url];
|
|
414
327
|
}
|
|
328
|
+
sources = sources.concat(url);
|
|
329
|
+
}
|
|
330
|
+
return sources;
|
|
331
|
+
};
|
|
415
332
|
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
this._initSources(function () {
|
|
425
|
-
if (!_this.is('youtube')) {
|
|
426
|
-
_.forEach(_this.config.sources, function (source) {
|
|
427
|
-
if (source && source.type && source.type.indexOf('audio') === 0) {
|
|
428
|
-
_this._setType(source.type);
|
|
429
|
-
|
|
430
|
-
_this._initType();
|
|
333
|
+
/**
|
|
334
|
+
* Checks if the browser can play media
|
|
335
|
+
* @param {String} sizeProps Width or Height
|
|
336
|
+
* @returns {Boolean}
|
|
337
|
+
*/
|
|
338
|
+
const isResponsiveSize = sizeProps => {
|
|
339
|
+
return /%/.test(sizeProps) || sizeProps === 'auto';
|
|
340
|
+
};
|
|
431
341
|
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
342
|
+
/**
|
|
343
|
+
* Builds a media player instance
|
|
344
|
+
* @param {Object} config
|
|
345
|
+
* @param {String} config.type - The type of media to play, say `audio`, `video`, or `youtube`. The default is `video`.
|
|
346
|
+
* It might also contain the MIME type of the media as a shorthand.
|
|
347
|
+
* @param {String|Array} [config.url] - The URL to the media. If several media are proposed as alternatives,
|
|
348
|
+
* please look at the `sources` option instead.
|
|
349
|
+
* @param {String} [config.mimeType] - The MIME type of the media. If omitted, the player will try to extract it
|
|
350
|
+
* from the `type` property, otherwise it will request the server to get the content-type.
|
|
351
|
+
* @param {Array} [config.sources] - A list of URL if several media can be proposed. Each entry may be either a
|
|
352
|
+
* string (single URL), or an object containing both the URL and the MIME type ({src: string, type: string}).
|
|
353
|
+
* @param {String|jQuery|HTMLElement} [config.renderTo] - An optional container in which renders the player
|
|
354
|
+
* @param {Boolean} [config.canSeek] - The player allows to reach an arbitrary position within the media using the duration bar
|
|
355
|
+
* @param {Boolean} [config.loop] - The media will be played continuously
|
|
356
|
+
* @param {Boolean} [config.canPause] - The player can be paused
|
|
357
|
+
* @param {Boolean} [config.startMuted] - The player should be initially muted
|
|
358
|
+
* @param {Boolean} [config.autoStart] - The player starts as soon as it is displayed
|
|
359
|
+
* @param {Number} [config.autoStartAt] - The time position at which the player should start
|
|
360
|
+
* @param {Number} [config.maxPlays] - Sets a few number of plays (default: infinite)
|
|
361
|
+
* @param {Number} [config.replayTimeout] - disable the possibility to replay a media after this timeout, in seconds (default: 0)
|
|
362
|
+
* @param {Number} [config.volume] - Sets the sound volume (default: 80)
|
|
363
|
+
* @param {Number} [config.width] - Sets the width of the player (default: depends on media type)
|
|
364
|
+
* @param {Number} [config.height] - Sets the height of the player (default: depends on media type)
|
|
365
|
+
* @param {Boolean} [config.preview] - Enables the media preview (load media metadata)
|
|
366
|
+
* @param {Boolean} [config.debug] - Enables the debug mode
|
|
367
|
+
* @param {number} [config.config.stalledDetectionDelay] - The delay before considering a media is stalled
|
|
368
|
+
* @event render - Event triggered when the player is rendering
|
|
369
|
+
* @event error - Event triggered when the player throws an unrecoverable error
|
|
370
|
+
* @event ready - Event triggered when the player is fully ready
|
|
371
|
+
* @event play - Event triggered when the playback is starting
|
|
372
|
+
* @event update - Event triggered while the player is playing
|
|
373
|
+
* @event pause - Event triggered when the playback is paused
|
|
374
|
+
* @event ended - Event triggered when the playback is ended
|
|
375
|
+
* @event limitreached - Event triggered when the play limit has been reached
|
|
376
|
+
* @event destroy - Event triggered when the player is destroying
|
|
377
|
+
* @returns {mediaplayer}
|
|
378
|
+
*/
|
|
379
|
+
function mediaplayerFactory(config) {
|
|
380
|
+
/**
|
|
381
|
+
* Defines a media player object
|
|
382
|
+
* @type {Object}
|
|
383
|
+
*/
|
|
384
|
+
const mediaplayer = {
|
|
385
|
+
/**
|
|
386
|
+
* Initializes the media player
|
|
387
|
+
* @param {Object} config
|
|
388
|
+
* @returns {mediaplayer}
|
|
389
|
+
*/
|
|
390
|
+
init(config) {
|
|
391
|
+
// load the config set, discard null values in order to allow defaults to be set
|
|
392
|
+
this.config = _.omit(config || {}, value => typeof value === 'undefined' || value === null);
|
|
393
|
+
_.defaults(this.config, defaults.options);
|
|
394
|
+
if (!this.config.mimeType && 'string' === typeof this.config.type && this.config.type.indexOf('/') > 0) {
|
|
395
|
+
this.config.mimeType = this.config.type;
|
|
435
396
|
}
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
397
|
+
this._setType(this.config.type || defaults.type);
|
|
398
|
+
this._reset();
|
|
399
|
+
this._updateVolumeFromStore();
|
|
400
|
+
this._initEvents();
|
|
401
|
+
this._initSources(() => {
|
|
402
|
+
if (!this.is('youtube')) {
|
|
403
|
+
_.forEach(this.config.sources, source => {
|
|
404
|
+
if (source && source.type && source.type.indexOf('audio') === 0) {
|
|
405
|
+
this._setType(source.type);
|
|
406
|
+
this._initType();
|
|
407
|
+
return false;
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
if (this.config.renderTo) {
|
|
412
|
+
_.defer(() => this.render());
|
|
413
|
+
}
|
|
414
|
+
});
|
|
415
|
+
return this;
|
|
416
|
+
},
|
|
417
|
+
/**
|
|
418
|
+
* Uninstalls the media player
|
|
419
|
+
* @returns {mediaplayer}
|
|
420
|
+
*/
|
|
421
|
+
destroy() {
|
|
422
|
+
/**
|
|
423
|
+
* Triggers a destroy event
|
|
424
|
+
* @event mediaplayer#destroy
|
|
425
|
+
*/
|
|
426
|
+
this.trigger('destroy');
|
|
427
|
+
if (this.player) {
|
|
428
|
+
this.player.destroy();
|
|
441
429
|
}
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
*
|
|
454
|
-
* @
|
|
430
|
+
if (this.$component) {
|
|
431
|
+
this._unbindEvents();
|
|
432
|
+
this._destroySlider(this.$seekSlider);
|
|
433
|
+
this._destroySlider(this.$volumeSlider);
|
|
434
|
+
this.$component.remove();
|
|
435
|
+
}
|
|
436
|
+
this._reset();
|
|
437
|
+
return this;
|
|
438
|
+
},
|
|
439
|
+
/**
|
|
440
|
+
* Renders the media player according to the media type
|
|
441
|
+
* @param {String|jQuery|HTMLElement} [to]
|
|
442
|
+
* @returns {mediaplayer}
|
|
455
443
|
*/
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
this.
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
this.
|
|
468
|
-
|
|
469
|
-
this
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
render: function render(to) {
|
|
483
|
-
var renderTo = to || this.config.renderTo || this.$container;
|
|
484
|
-
|
|
485
|
-
if (this.$component) {
|
|
486
|
-
this.destroy();
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
this._initState();
|
|
490
|
-
|
|
491
|
-
this._buildDom();
|
|
492
|
-
|
|
493
|
-
if (this.config.preview) {
|
|
494
|
-
this._updateDuration(0);
|
|
495
|
-
|
|
496
|
-
this._updatePosition(0);
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
this._bindEvents();
|
|
500
|
-
|
|
501
|
-
this._playingState(false, true);
|
|
502
|
-
|
|
503
|
-
this._initPlayer();
|
|
504
|
-
|
|
505
|
-
this._initSize(); // Resize for old items with defined height to avoid big jump
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
if (this.config.height && this.config.height !== 'auto') {
|
|
509
|
-
this.resize('100%', 'auto');
|
|
510
|
-
} else {
|
|
511
|
-
this.resize(this.config.width, this.config.height);
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
this.config.is.rendered = true;
|
|
515
|
-
|
|
516
|
-
if (renderTo) {
|
|
517
|
-
this.$container = $$1(renderTo).append(this.$component);
|
|
518
|
-
} // add class if it is stalled
|
|
444
|
+
render(to) {
|
|
445
|
+
const renderTo = to || this.config.renderTo || this.$container;
|
|
446
|
+
if (this.$component) {
|
|
447
|
+
this.destroy();
|
|
448
|
+
}
|
|
449
|
+
this._initState();
|
|
450
|
+
this._buildDom();
|
|
451
|
+
if (this.config.preview) {
|
|
452
|
+
this._updateDuration(0);
|
|
453
|
+
this._updatePosition(0);
|
|
454
|
+
}
|
|
455
|
+
this._bindEvents();
|
|
456
|
+
this._playingState(false, true);
|
|
457
|
+
this._initPlayer();
|
|
458
|
+
this._initSize();
|
|
459
|
+
|
|
460
|
+
// Resize for old items with defined height to avoid big jump
|
|
461
|
+
if (this.config.height && this.config.height !== 'auto') {
|
|
462
|
+
this.resize('100%', 'auto');
|
|
463
|
+
} else {
|
|
464
|
+
this.resize(this.config.width, this.config.height);
|
|
465
|
+
}
|
|
466
|
+
this.config.is.rendered = true;
|
|
467
|
+
if (renderTo) {
|
|
468
|
+
this.$container = $$1(renderTo).append(this.$component);
|
|
469
|
+
}
|
|
519
470
|
|
|
471
|
+
// add class if it is stalled
|
|
472
|
+
if (this.is('stalled')) {
|
|
473
|
+
this._setState('stalled', true);
|
|
474
|
+
}
|
|
520
475
|
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
476
|
+
/**
|
|
477
|
+
* Triggers a render event
|
|
478
|
+
* @event mediaplayer#render
|
|
479
|
+
* @param {jQuery} $component
|
|
480
|
+
*/
|
|
481
|
+
this.trigger('render', this.$component);
|
|
482
|
+
return this;
|
|
483
|
+
},
|
|
484
|
+
/**
|
|
485
|
+
* Reloads media player after it was stalled
|
|
528
486
|
*/
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
487
|
+
reload() {
|
|
488
|
+
/**
|
|
489
|
+
* Triggers a reload event
|
|
490
|
+
* @event mediaplayer#reload
|
|
491
|
+
*/
|
|
492
|
+
this.trigger('reload');
|
|
493
|
+
if (this.player) {
|
|
494
|
+
this.player.recover();
|
|
495
|
+
}
|
|
496
|
+
this._setState('stalled', false);
|
|
497
|
+
this.setInitialStates();
|
|
498
|
+
},
|
|
499
|
+
/**
|
|
500
|
+
* Set initial states
|
|
542
501
|
*/
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
this.player.recover();
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
this._setState('stalled', false);
|
|
550
|
-
|
|
551
|
-
this.setInitialStates();
|
|
552
|
-
},
|
|
553
|
-
|
|
554
|
-
/**
|
|
555
|
-
* Set initial states
|
|
556
|
-
*/
|
|
557
|
-
setInitialStates: function setInitialStates() {
|
|
558
|
-
if (!this.is('stalled')) {
|
|
559
|
-
this._setState('ready', true);
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
this._setState('canplay', true);
|
|
563
|
-
|
|
564
|
-
this._setState('canpause', this.config.canPause);
|
|
565
|
-
|
|
566
|
-
this._setState('canseek', this.config.canSeek);
|
|
567
|
-
|
|
568
|
-
this._setState('loading', false);
|
|
569
|
-
},
|
|
570
|
-
|
|
571
|
-
/**
|
|
572
|
-
* Sets the start position inside the media
|
|
573
|
-
* @param {Number} time - The start position in seconds
|
|
574
|
-
* @param {*} [internal] - Internal use
|
|
575
|
-
* @returns {mediaplayer}
|
|
576
|
-
*/
|
|
577
|
-
seek: function seek(time, internal) {
|
|
578
|
-
if (this._canPlay()) {
|
|
579
|
-
this._updatePosition(time, internal);
|
|
580
|
-
|
|
581
|
-
this.execute('seek', this.position);
|
|
582
|
-
|
|
583
|
-
if (!this.is('ready')) {
|
|
584
|
-
this.autoStartAt = this.position;
|
|
502
|
+
setInitialStates() {
|
|
503
|
+
if (!this.is('stalled')) {
|
|
504
|
+
this._setState('ready', true);
|
|
585
505
|
}
|
|
586
|
-
|
|
587
|
-
this.
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
this.
|
|
506
|
+
this._setState('canplay', true);
|
|
507
|
+
this._setState('canpause', this.config.canPause);
|
|
508
|
+
this._setState('canseek', this.config.canSeek);
|
|
509
|
+
this._setState('loading', false);
|
|
510
|
+
},
|
|
511
|
+
/**
|
|
512
|
+
* Sets the start position inside the media
|
|
513
|
+
* @param {Number} time - The start position in seconds
|
|
514
|
+
* @param {*} [internal] - Internal use
|
|
515
|
+
* @returns {mediaplayer}
|
|
516
|
+
*/
|
|
517
|
+
seek(time, internal) {
|
|
518
|
+
if (this._canPlay()) {
|
|
519
|
+
this._updatePosition(time, internal);
|
|
520
|
+
this.execute('seek', this.position);
|
|
521
|
+
if (!this.is('ready')) {
|
|
522
|
+
this.autoStartAt = this.position;
|
|
523
|
+
}
|
|
524
|
+
this.loop = !!this.config.loop;
|
|
602
525
|
}
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
526
|
+
return this;
|
|
527
|
+
},
|
|
528
|
+
/**
|
|
529
|
+
* Plays the media
|
|
530
|
+
* @param {Number} [time] - An optional start position in seconds
|
|
531
|
+
* @returns {mediaplayer}
|
|
532
|
+
*/
|
|
533
|
+
play(time) {
|
|
534
|
+
if (this._canPlay()) {
|
|
535
|
+
if (typeof time !== 'undefined') {
|
|
536
|
+
this.seek(time);
|
|
537
|
+
}
|
|
538
|
+
this.execute('play');
|
|
539
|
+
if (!this.is('ready')) {
|
|
540
|
+
this.autoStart = true;
|
|
541
|
+
}
|
|
542
|
+
this.loop = !!this.config.loop;
|
|
543
|
+
if (this.timerId) {
|
|
544
|
+
cancelAnimationFrame(this.timerId);
|
|
545
|
+
}
|
|
608
546
|
}
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
547
|
+
return this;
|
|
548
|
+
},
|
|
549
|
+
/**
|
|
550
|
+
* Pauses the media
|
|
551
|
+
* @param {Number} [time] - An optional time position in seconds
|
|
552
|
+
* @returns {mediaplayer}
|
|
553
|
+
*/
|
|
554
|
+
pause(time) {
|
|
555
|
+
if (this._canPause()) {
|
|
556
|
+
if (typeof time !== 'undefined') {
|
|
557
|
+
this.seek(time);
|
|
558
|
+
}
|
|
559
|
+
this.execute('pause');
|
|
560
|
+
if (!this.is('ready')) {
|
|
561
|
+
this.autoStart = false;
|
|
562
|
+
}
|
|
614
563
|
}
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
*/
|
|
625
|
-
pause: function pause(time) {
|
|
626
|
-
if (this._canPause()) {
|
|
627
|
-
if (typeof time !== 'undefined') {
|
|
628
|
-
this.seek(time);
|
|
564
|
+
return this;
|
|
565
|
+
},
|
|
566
|
+
/**
|
|
567
|
+
* Resumes the media
|
|
568
|
+
* @returns {mediaplayer}
|
|
569
|
+
*/
|
|
570
|
+
resume() {
|
|
571
|
+
if (this._canResume()) {
|
|
572
|
+
this.play();
|
|
629
573
|
}
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
574
|
+
return this;
|
|
575
|
+
},
|
|
576
|
+
/**
|
|
577
|
+
* Stops the playback
|
|
578
|
+
* @returns {mediaplayer}
|
|
579
|
+
*/
|
|
580
|
+
stop() {
|
|
581
|
+
this.loop = false;
|
|
582
|
+
this.execute('stop');
|
|
633
583
|
if (!this.is('ready')) {
|
|
634
584
|
this.autoStart = false;
|
|
635
585
|
}
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
resume: function resume() {
|
|
646
|
-
if (this._canResume()) {
|
|
586
|
+
return this;
|
|
587
|
+
},
|
|
588
|
+
/**
|
|
589
|
+
* Starts the media
|
|
590
|
+
* @returns {mediaplayer}
|
|
591
|
+
*/
|
|
592
|
+
start() {
|
|
593
|
+
this._setState('preview', true);
|
|
594
|
+
this._setState('loading', true);
|
|
647
595
|
this.play();
|
|
648
|
-
}
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
this.
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
this._setState('preview', true);
|
|
674
|
-
|
|
675
|
-
this._setState('loading', true);
|
|
676
|
-
|
|
677
|
-
this.play();
|
|
678
|
-
},
|
|
679
|
-
|
|
680
|
-
/**
|
|
681
|
-
* Restarts the media from the beginning
|
|
682
|
-
* @returns {mediaplayer}
|
|
683
|
-
*/
|
|
684
|
-
restart: function restart() {
|
|
685
|
-
this.play(0);
|
|
686
|
-
return this;
|
|
687
|
-
},
|
|
688
|
-
|
|
689
|
-
/**
|
|
690
|
-
* Rewind the media to the beginning
|
|
691
|
-
* @returns {mediaplayer}
|
|
692
|
-
*/
|
|
693
|
-
rewind: function rewind() {
|
|
694
|
-
this.seek(0);
|
|
695
|
-
return this;
|
|
696
|
-
},
|
|
697
|
-
|
|
698
|
-
/**
|
|
699
|
-
* Mutes the media
|
|
700
|
-
* @param {Boolean} [state] - A flag to set the mute state (default: true)
|
|
701
|
-
* @returns {mediaplayer}
|
|
702
|
-
*/
|
|
703
|
-
mute: function mute(state) {
|
|
704
|
-
if (typeof state === 'undefined') {
|
|
705
|
-
state = true;
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
this.execute('mute', state);
|
|
709
|
-
|
|
710
|
-
this._setState('muted', state);
|
|
711
|
-
|
|
712
|
-
if (!this.is('ready')) {
|
|
713
|
-
this.startMuted = state;
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
return this;
|
|
717
|
-
},
|
|
718
|
-
|
|
719
|
-
/**
|
|
720
|
-
* Restore the sound of the media after a mute
|
|
721
|
-
* @returns {mediaplayer}
|
|
722
|
-
*/
|
|
723
|
-
unmute: function unmute() {
|
|
724
|
-
this.mute(false);
|
|
725
|
-
return this;
|
|
726
|
-
},
|
|
727
|
-
|
|
728
|
-
/**
|
|
729
|
-
* Sets the sound volume of the media being played
|
|
730
|
-
* @param {Number} value - A value between 0 and 100
|
|
731
|
-
* @param {*} [internal] - Internal use
|
|
732
|
-
* @returns {mediaplayer}
|
|
733
|
-
*/
|
|
734
|
-
setVolume: function setVolume(value, internal) {
|
|
735
|
-
this._updateVolume(value, internal);
|
|
736
|
-
|
|
737
|
-
this.execute('setVolume', this.volume);
|
|
738
|
-
return this;
|
|
739
|
-
},
|
|
740
|
-
|
|
741
|
-
/**
|
|
742
|
-
* Gets the sound volume applied to the media being played
|
|
743
|
-
* @returns {Number} Returns a value between 0 and 100
|
|
744
|
-
*/
|
|
745
|
-
getVolume: function getVolume() {
|
|
746
|
-
return this.volume;
|
|
747
|
-
},
|
|
748
|
-
|
|
749
|
-
/**
|
|
750
|
-
* Gets the current displayed position inside the media
|
|
751
|
-
* @returns {Number}
|
|
752
|
-
*/
|
|
753
|
-
getPosition: function getPosition() {
|
|
754
|
-
return this.position;
|
|
755
|
-
},
|
|
756
|
-
|
|
757
|
-
/**
|
|
758
|
-
* Gets the duration of the media
|
|
759
|
-
* @returns {Number}
|
|
760
|
-
*/
|
|
761
|
-
getDuration: function getDuration() {
|
|
762
|
-
return this.duration;
|
|
763
|
-
},
|
|
764
|
-
|
|
765
|
-
/**
|
|
766
|
-
* Gets the number of times the media has been played
|
|
767
|
-
* @returns {Number}
|
|
768
|
-
*/
|
|
769
|
-
getTimesPlayed: function getTimesPlayed() {
|
|
770
|
-
return this.timesPlayed;
|
|
771
|
-
},
|
|
772
|
-
|
|
773
|
-
/**
|
|
774
|
-
* Gets the type of player
|
|
775
|
-
* @returns {String}
|
|
776
|
-
*/
|
|
777
|
-
getType: function getType() {
|
|
778
|
-
return this.type;
|
|
779
|
-
},
|
|
780
|
-
|
|
781
|
-
/**
|
|
782
|
-
* Gets the DOM container
|
|
783
|
-
* @returns {jQuery}
|
|
784
|
-
*/
|
|
785
|
-
getContainer: function getContainer() {
|
|
786
|
-
if (!this.$container && this.$component) {
|
|
787
|
-
var $container = this.$component.parent();
|
|
788
|
-
|
|
789
|
-
if ($container.length) {
|
|
790
|
-
this.$container = $container;
|
|
596
|
+
},
|
|
597
|
+
/**
|
|
598
|
+
* Restarts the media from the beginning
|
|
599
|
+
* @returns {mediaplayer}
|
|
600
|
+
*/
|
|
601
|
+
restart() {
|
|
602
|
+
this.play(0);
|
|
603
|
+
return this;
|
|
604
|
+
},
|
|
605
|
+
/**
|
|
606
|
+
* Rewind the media to the beginning
|
|
607
|
+
* @returns {mediaplayer}
|
|
608
|
+
*/
|
|
609
|
+
rewind() {
|
|
610
|
+
this.seek(0);
|
|
611
|
+
return this;
|
|
612
|
+
},
|
|
613
|
+
/**
|
|
614
|
+
* Mutes the media
|
|
615
|
+
* @param {Boolean} [state] - A flag to set the mute state (default: true)
|
|
616
|
+
* @returns {mediaplayer}
|
|
617
|
+
*/
|
|
618
|
+
mute(state) {
|
|
619
|
+
if (typeof state === 'undefined') {
|
|
620
|
+
state = true;
|
|
791
621
|
}
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
/**
|
|
798
|
-
* Gets the underlying DOM element
|
|
799
|
-
* @returns {jQuery}
|
|
800
|
-
*/
|
|
801
|
-
getElement: function getElement() {
|
|
802
|
-
return this.$component;
|
|
803
|
-
},
|
|
804
|
-
|
|
805
|
-
/**
|
|
806
|
-
* Gets the list of media
|
|
807
|
-
* @returns {Array}
|
|
808
|
-
*/
|
|
809
|
-
getSources: function getSources() {
|
|
810
|
-
return this.config.sources.slice();
|
|
811
|
-
},
|
|
812
|
-
|
|
813
|
-
/**
|
|
814
|
-
* Sets the media source. If a source has been already set, it will be replaced.
|
|
815
|
-
* @param {String|Object} src - The media URL, or an object containing the source and the type
|
|
816
|
-
* @param {Function} [callback] - A function called to provide the added media source object
|
|
817
|
-
* @returns {mediaplayer}
|
|
818
|
-
*/
|
|
819
|
-
setSource: function setSource(src, callback) {
|
|
820
|
-
var _this2 = this;
|
|
821
|
-
|
|
822
|
-
this._getSource(src, function (source) {
|
|
823
|
-
_this2.config.sources = [source];
|
|
824
|
-
|
|
825
|
-
if (_this2.is('rendered')) {
|
|
826
|
-
_this2.player.setMedia(source.src, source.type);
|
|
622
|
+
this.execute('mute', state);
|
|
623
|
+
this._setState('muted', state);
|
|
624
|
+
if (!this.is('ready')) {
|
|
625
|
+
this.startMuted = state;
|
|
827
626
|
}
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
627
|
+
return this;
|
|
628
|
+
},
|
|
629
|
+
/**
|
|
630
|
+
* Restore the sound of the media after a mute
|
|
631
|
+
* @returns {mediaplayer}
|
|
632
|
+
*/
|
|
633
|
+
unmute() {
|
|
634
|
+
this.mute(false);
|
|
635
|
+
return this;
|
|
636
|
+
},
|
|
637
|
+
/**
|
|
638
|
+
* Sets the sound volume of the media being played
|
|
639
|
+
* @param {Number} value - A value between 0 and 100
|
|
640
|
+
* @param {*} [internal] - Internal use
|
|
641
|
+
* @returns {mediaplayer}
|
|
642
|
+
*/
|
|
643
|
+
setVolume(value, internal) {
|
|
644
|
+
this._updateVolume(value, internal);
|
|
645
|
+
this.execute('setVolume', this.volume);
|
|
646
|
+
return this;
|
|
647
|
+
},
|
|
648
|
+
/**
|
|
649
|
+
* Gets the sound volume applied to the media being played
|
|
650
|
+
* @returns {Number} Returns a value between 0 and 100
|
|
651
|
+
*/
|
|
652
|
+
getVolume() {
|
|
653
|
+
return this.volume;
|
|
654
|
+
},
|
|
655
|
+
/**
|
|
656
|
+
* Gets the current displayed position inside the media
|
|
657
|
+
* @returns {Number}
|
|
658
|
+
*/
|
|
659
|
+
getPosition() {
|
|
660
|
+
return this.position;
|
|
661
|
+
},
|
|
662
|
+
/**
|
|
663
|
+
* Gets the duration of the media
|
|
664
|
+
* @returns {Number}
|
|
665
|
+
*/
|
|
666
|
+
getDuration() {
|
|
667
|
+
return this.duration;
|
|
668
|
+
},
|
|
669
|
+
/**
|
|
670
|
+
* Gets the number of times the media has been played
|
|
671
|
+
* @returns {Number}
|
|
672
|
+
*/
|
|
673
|
+
getTimesPlayed() {
|
|
674
|
+
return this.timesPlayed;
|
|
675
|
+
},
|
|
676
|
+
/**
|
|
677
|
+
* Gets the type of player
|
|
678
|
+
* @returns {String}
|
|
679
|
+
*/
|
|
680
|
+
getType() {
|
|
681
|
+
return this.type;
|
|
682
|
+
},
|
|
683
|
+
/**
|
|
684
|
+
* Gets the DOM container
|
|
685
|
+
* @returns {jQuery}
|
|
686
|
+
*/
|
|
687
|
+
getContainer() {
|
|
688
|
+
if (!this.$container && this.$component) {
|
|
689
|
+
let $container = this.$component.parent();
|
|
690
|
+
if ($container.length) {
|
|
691
|
+
this.$container = $container;
|
|
692
|
+
}
|
|
831
693
|
}
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
694
|
+
return this.$container;
|
|
695
|
+
},
|
|
696
|
+
/**
|
|
697
|
+
* Gets the underlying DOM element
|
|
698
|
+
* @returns {jQuery}
|
|
699
|
+
*/
|
|
700
|
+
getElement() {
|
|
701
|
+
return this.$component;
|
|
702
|
+
},
|
|
703
|
+
/**
|
|
704
|
+
* Gets the list of media
|
|
705
|
+
* @returns {Array}
|
|
706
|
+
*/
|
|
707
|
+
getSources() {
|
|
708
|
+
return this.config.sources.slice();
|
|
709
|
+
},
|
|
710
|
+
/**
|
|
711
|
+
* Sets the media source. If a source has been already set, it will be replaced.
|
|
712
|
+
* @param {String|Object} src - The media URL, or an object containing the source and the type
|
|
713
|
+
* @param {Function} [callback] - A function called to provide the added media source object
|
|
714
|
+
* @returns {mediaplayer}
|
|
715
|
+
*/
|
|
716
|
+
setSource(src, callback) {
|
|
717
|
+
this._getSource(src, source => {
|
|
718
|
+
this.config.sources = [source];
|
|
719
|
+
if (this.is('rendered')) {
|
|
720
|
+
this.player.setMedia(source.src, source.type);
|
|
721
|
+
}
|
|
722
|
+
if (callback) {
|
|
723
|
+
callback.call(this, source);
|
|
724
|
+
}
|
|
725
|
+
});
|
|
726
|
+
return this;
|
|
727
|
+
},
|
|
728
|
+
/**
|
|
729
|
+
* Adds a media source.
|
|
730
|
+
* @param {String|Object} src - The media URL, or an object containing the source and the type
|
|
731
|
+
* @param {Function} [callback] - A function called to provide the added media source object
|
|
732
|
+
* @returns {mediaplayer}
|
|
733
|
+
*/
|
|
734
|
+
addSource(src, callback) {
|
|
735
|
+
this._getSource(src, source => {
|
|
736
|
+
this.config.sources.push(source);
|
|
737
|
+
if (this.is('rendered')) {
|
|
738
|
+
this.player.addMedia(source.src, source.type);
|
|
739
|
+
}
|
|
740
|
+
if (callback) {
|
|
741
|
+
callback.call(this, source);
|
|
742
|
+
}
|
|
743
|
+
});
|
|
744
|
+
return this;
|
|
745
|
+
},
|
|
746
|
+
/**
|
|
747
|
+
* Tells if the media is in a particular state
|
|
748
|
+
* @param {String} state
|
|
749
|
+
* @returns {Boolean}
|
|
750
|
+
*/
|
|
751
|
+
is(state) {
|
|
752
|
+
return !!this.config.is[state];
|
|
753
|
+
},
|
|
754
|
+
/**
|
|
755
|
+
* Changes the size of the player
|
|
756
|
+
* @param {Number} width
|
|
757
|
+
* @param {Number} height
|
|
758
|
+
* @returns {mediaplayer}
|
|
759
|
+
*/
|
|
760
|
+
resize(width, height) {
|
|
761
|
+
if (isResponsiveSize(width) && !isResponsiveSize(height) || this.is('youtube')) {
|
|
762
|
+
// responsive width height should be auto
|
|
763
|
+
// for youtube iframe height is limited by ration
|
|
764
|
+
height = 'auto';
|
|
851
765
|
}
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
766
|
+
this.execute('setSize', width, height);
|
|
767
|
+
return this;
|
|
768
|
+
},
|
|
769
|
+
/**
|
|
770
|
+
* Enables the media player
|
|
771
|
+
* @returns {mediaplayer}
|
|
772
|
+
*/
|
|
773
|
+
enable() {
|
|
774
|
+
this._fromState('disabled');
|
|
775
|
+
return this;
|
|
776
|
+
},
|
|
777
|
+
/**
|
|
778
|
+
* Disables the media player
|
|
779
|
+
* @returns {mediaplayer}
|
|
780
|
+
*/
|
|
781
|
+
disable() {
|
|
782
|
+
this._toState('disabled');
|
|
783
|
+
this.trigger('disabled');
|
|
784
|
+
return this;
|
|
785
|
+
},
|
|
786
|
+
/**
|
|
787
|
+
* Shows the media player
|
|
788
|
+
* @returns {mediaplayer}
|
|
789
|
+
*/
|
|
790
|
+
show() {
|
|
791
|
+
this._fromState('hidden');
|
|
792
|
+
return this;
|
|
793
|
+
},
|
|
794
|
+
/**
|
|
795
|
+
* hides the media player
|
|
796
|
+
* @returns {mediaplayer}
|
|
797
|
+
*/
|
|
798
|
+
hide() {
|
|
799
|
+
this._toState('hidden');
|
|
800
|
+
return this;
|
|
801
|
+
},
|
|
802
|
+
/**
|
|
803
|
+
* get media original size
|
|
804
|
+
* @returns {Object}
|
|
805
|
+
*/
|
|
806
|
+
getMediaOriginalSize() {
|
|
807
|
+
if (this.is('youtube')) {
|
|
808
|
+
return defaults.youtube;
|
|
855
809
|
}
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
return this;
|
|
859
|
-
},
|
|
860
|
-
|
|
861
|
-
/**
|
|
862
|
-
* Tells if the media is in a particular state
|
|
863
|
-
* @param {String} state
|
|
864
|
-
* @returns {Boolean}
|
|
865
|
-
*/
|
|
866
|
-
is: function is(state) {
|
|
867
|
-
return !!this.config.is[state];
|
|
868
|
-
},
|
|
869
|
-
|
|
870
|
-
/**
|
|
871
|
-
* Changes the size of the player
|
|
872
|
-
* @param {Number} width
|
|
873
|
-
* @param {Number} height
|
|
874
|
-
* @returns {mediaplayer}
|
|
875
|
-
*/
|
|
876
|
-
resize: function resize(width, height) {
|
|
877
|
-
if (isResponsiveSize(width) && !isResponsiveSize(height) || this.is('youtube')) {
|
|
878
|
-
// responsive width height should be auto
|
|
879
|
-
// for youtube iframe height is limited by ration
|
|
880
|
-
height = 'auto';
|
|
881
|
-
}
|
|
882
|
-
|
|
883
|
-
this.execute('setSize', width, height);
|
|
884
|
-
return this;
|
|
885
|
-
},
|
|
886
|
-
|
|
887
|
-
/**
|
|
888
|
-
* Enables the media player
|
|
889
|
-
* @returns {mediaplayer}
|
|
890
|
-
*/
|
|
891
|
-
enable: function enable() {
|
|
892
|
-
this._fromState('disabled');
|
|
893
|
-
|
|
894
|
-
return this;
|
|
895
|
-
},
|
|
896
|
-
|
|
897
|
-
/**
|
|
898
|
-
* Disables the media player
|
|
899
|
-
* @returns {mediaplayer}
|
|
900
|
-
*/
|
|
901
|
-
disable: function disable() {
|
|
902
|
-
this._toState('disabled');
|
|
903
|
-
|
|
904
|
-
this.trigger('disabled');
|
|
905
|
-
return this;
|
|
906
|
-
},
|
|
907
|
-
|
|
908
|
-
/**
|
|
909
|
-
* Shows the media player
|
|
910
|
-
* @returns {mediaplayer}
|
|
911
|
-
*/
|
|
912
|
-
show: function show() {
|
|
913
|
-
this._fromState('hidden');
|
|
914
|
-
|
|
915
|
-
return this;
|
|
916
|
-
},
|
|
917
|
-
|
|
918
|
-
/**
|
|
919
|
-
* hides the media player
|
|
920
|
-
* @returns {mediaplayer}
|
|
921
|
-
*/
|
|
922
|
-
hide: function hide() {
|
|
923
|
-
this._toState('hidden');
|
|
924
|
-
|
|
925
|
-
return this;
|
|
926
|
-
},
|
|
927
|
-
|
|
928
|
-
/**
|
|
929
|
-
* get media original size
|
|
930
|
-
* @returns {Object}
|
|
931
|
-
*/
|
|
932
|
-
getMediaOriginalSize: function getMediaOriginalSize() {
|
|
933
|
-
if (this.is('youtube')) {
|
|
934
|
-
return defaults.youtube;
|
|
935
|
-
}
|
|
936
|
-
|
|
937
|
-
if (this.is('video') && this.player) {
|
|
938
|
-
return this.player.getMediaSize();
|
|
939
|
-
}
|
|
940
|
-
|
|
941
|
-
return {};
|
|
942
|
-
},
|
|
943
|
-
|
|
944
|
-
/**
|
|
945
|
-
* Ensures the right media type is set
|
|
946
|
-
* @param {String} type
|
|
947
|
-
* @private
|
|
948
|
-
*/
|
|
949
|
-
_setType: function _setType(type) {
|
|
950
|
-
if (type.indexOf('youtube') !== -1) {
|
|
951
|
-
this.type = 'youtube';
|
|
952
|
-
} else if (type.indexOf('audio') === 0) {
|
|
953
|
-
this.type = 'audio';
|
|
954
|
-
} else {
|
|
955
|
-
this.type = 'video';
|
|
956
|
-
}
|
|
957
|
-
},
|
|
958
|
-
|
|
959
|
-
/**
|
|
960
|
-
* Ensures the type is correctly applied
|
|
961
|
-
* @private
|
|
962
|
-
*/
|
|
963
|
-
_initType: function _initType() {
|
|
964
|
-
var is = this.config.is;
|
|
965
|
-
is.youtube = 'youtube' === this.type;
|
|
966
|
-
is.video = 'video' === this.type || 'youtube' === this.type;
|
|
967
|
-
is.audio = 'audio' === this.type;
|
|
968
|
-
},
|
|
969
|
-
|
|
970
|
-
/**
|
|
971
|
-
* Gets a source descriptor.
|
|
972
|
-
* @param {String|Object} src - The media URL, or an object containing the source and the type
|
|
973
|
-
* @param {Function} callback - A function called to provide the media source object
|
|
974
|
-
*/
|
|
975
|
-
_getSource: function _getSource(src, callback) {
|
|
976
|
-
var _this4 = this;
|
|
977
|
-
|
|
978
|
-
var source;
|
|
979
|
-
|
|
980
|
-
var done = function done() {
|
|
981
|
-
if (needTypeAdjust(source.type)) {
|
|
982
|
-
source.type = getAdjustedType(source);
|
|
810
|
+
if (this.is('video') && this.player) {
|
|
811
|
+
return this.player.getMediaSize();
|
|
983
812
|
}
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
source.type = defaults.type;
|
|
999
|
-
} else if (this.config.mimeType) {
|
|
1000
|
-
source.type = this.config.mimeType;
|
|
813
|
+
return {};
|
|
814
|
+
},
|
|
815
|
+
/**
|
|
816
|
+
* Ensures the right media type is set
|
|
817
|
+
* @param {String} type
|
|
818
|
+
* @private
|
|
819
|
+
*/
|
|
820
|
+
_setType(type) {
|
|
821
|
+
if (type.indexOf('youtube') !== -1) {
|
|
822
|
+
this.type = 'youtube';
|
|
823
|
+
} else if (type.indexOf('audio') === 0) {
|
|
824
|
+
this.type = 'audio';
|
|
825
|
+
} else {
|
|
826
|
+
this.type = 'video';
|
|
1001
827
|
}
|
|
1002
|
-
}
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
828
|
+
},
|
|
829
|
+
/**
|
|
830
|
+
* Ensures the type is correctly applied
|
|
831
|
+
* @private
|
|
832
|
+
*/
|
|
833
|
+
_initType() {
|
|
834
|
+
const is = this.config.is;
|
|
835
|
+
is.youtube = 'youtube' === this.type;
|
|
836
|
+
is.video = 'video' === this.type || 'youtube' === this.type;
|
|
837
|
+
is.audio = 'audio' === this.type;
|
|
838
|
+
},
|
|
839
|
+
/**
|
|
840
|
+
* Gets a source descriptor.
|
|
841
|
+
* @param {String|Object} src - The media URL, or an object containing the source and the type
|
|
842
|
+
* @param {Function} callback - A function called to provide the media source object
|
|
843
|
+
*/
|
|
844
|
+
_getSource(src, callback) {
|
|
845
|
+
let source;
|
|
846
|
+
const done = () => {
|
|
847
|
+
if (needTypeAdjust(source.type)) {
|
|
848
|
+
source.type = getAdjustedType(source);
|
|
1008
849
|
}
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
/**
|
|
1019
|
-
* Ensures the sources are correctly set
|
|
1020
|
-
* @param {Function} callback - A function called once all sources have been initialized
|
|
1021
|
-
* @private
|
|
1022
|
-
*/
|
|
1023
|
-
_initSources: function _initSources(callback) {
|
|
1024
|
-
var _this5 = this;
|
|
1025
|
-
|
|
1026
|
-
var sources = configToSources(this.config);
|
|
1027
|
-
this.config.sources = [];
|
|
1028
|
-
async.each(sources, function (source, cb) {
|
|
1029
|
-
_this5.addSource(source, function (src) {
|
|
1030
|
-
return cb(null, src);
|
|
1031
|
-
});
|
|
1032
|
-
}, callback);
|
|
1033
|
-
},
|
|
1034
|
-
|
|
1035
|
-
/**
|
|
1036
|
-
* Installs the events manager onto the instance
|
|
1037
|
-
* @private
|
|
1038
|
-
*/
|
|
1039
|
-
_initEvents: function _initEvents() {
|
|
1040
|
-
eventifier(this);
|
|
1041
|
-
var triggerEvent = this.trigger;
|
|
1042
|
-
|
|
1043
|
-
this.trigger = function trigger(eventName) {
|
|
1044
|
-
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
1045
|
-
args[_key - 1] = arguments[_key];
|
|
850
|
+
callback.call(this, source);
|
|
851
|
+
};
|
|
852
|
+
if (_.isString(src)) {
|
|
853
|
+
source = {
|
|
854
|
+
src: src
|
|
855
|
+
};
|
|
856
|
+
} else {
|
|
857
|
+
source = _.clone(src);
|
|
1046
858
|
}
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
859
|
+
if (!source.type) {
|
|
860
|
+
if (this.is('youtube')) {
|
|
861
|
+
source.type = defaults.type;
|
|
862
|
+
} else if (this.config.mimeType) {
|
|
863
|
+
source.type = this.config.mimeType;
|
|
864
|
+
}
|
|
1052
865
|
}
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
/**
|
|
1059
|
-
* Ensures the right size is set according to the media type
|
|
1060
|
-
* @private
|
|
1061
|
-
*/
|
|
1062
|
-
_initSize: function _initSize() {
|
|
1063
|
-
var type = this.is('video') ? 'video' : 'audio';
|
|
1064
|
-
var mediaConfig = defaults[type] || defaults.video;
|
|
1065
|
-
this.config.width = this.config.width || mediaConfig.width;
|
|
1066
|
-
this.config.height = this.config.height || mediaConfig.height;
|
|
1067
|
-
|
|
1068
|
-
if (isResponsiveSize(this.config.width) && !isResponsiveSize(this.config.height) || this.is('youtube')) {
|
|
1069
|
-
// responsive width height should be auto
|
|
1070
|
-
// for youtube iframe height is limited by ration
|
|
1071
|
-
this.config.height = 'auto';
|
|
1072
|
-
}
|
|
1073
|
-
},
|
|
1074
|
-
|
|
1075
|
-
/**
|
|
1076
|
-
* Initializes the right player instance
|
|
1077
|
-
* @private
|
|
1078
|
-
*/
|
|
1079
|
-
_initPlayer: function _initPlayer() {
|
|
1080
|
-
var _this6 = this;
|
|
1081
|
-
|
|
1082
|
-
var playerFactory = players[this.type];
|
|
1083
|
-
var error;
|
|
1084
|
-
|
|
1085
|
-
if (support.canPlay(this.type)) {
|
|
1086
|
-
if (_.isFunction(playerFactory)) {
|
|
1087
|
-
var playerConfig = {
|
|
1088
|
-
type: this.getType(),
|
|
1089
|
-
sources: this.getSources(),
|
|
1090
|
-
preview: this.config.preview,
|
|
1091
|
-
debug: this.config.debug,
|
|
1092
|
-
stalledDetectionDelay: this.config.stalledDetectionDelay
|
|
1093
|
-
};
|
|
1094
|
-
this.player = playerFactory(this.$player, playerConfig).on('resize', function (width, height) {
|
|
1095
|
-
if (_this6.$component) {
|
|
1096
|
-
_this6.$component.width(width).height(height);
|
|
866
|
+
if (!source.type) {
|
|
867
|
+
mimetype.getResourceType(source.src, (err, type) => {
|
|
868
|
+
if (err) {
|
|
869
|
+
type = defaults.type;
|
|
1097
870
|
}
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
}).on('play', function () {
|
|
1101
|
-
return _this6._onPlay();
|
|
1102
|
-
}).on('pause', function () {
|
|
1103
|
-
return _this6._onPause();
|
|
1104
|
-
}).on('timeupdate', function () {
|
|
1105
|
-
return _this6._onTimeUpdate();
|
|
1106
|
-
}).on('stalled', function () {
|
|
1107
|
-
return _this6._onStalled();
|
|
1108
|
-
}).on('playing', function () {
|
|
1109
|
-
return _this6._onPlaying();
|
|
1110
|
-
}).on('end', function () {
|
|
1111
|
-
return _this6._onEnd();
|
|
1112
|
-
}).on('error', function () {
|
|
1113
|
-
return _this6._onError();
|
|
871
|
+
source.type = type;
|
|
872
|
+
done();
|
|
1114
873
|
});
|
|
874
|
+
} else {
|
|
875
|
+
done();
|
|
1115
876
|
}
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
877
|
+
},
|
|
878
|
+
/**
|
|
879
|
+
* Ensures the sources are correctly set
|
|
880
|
+
* @param {Function} callback - A function called once all sources have been initialized
|
|
881
|
+
* @private
|
|
882
|
+
*/
|
|
883
|
+
_initSources(callback) {
|
|
884
|
+
const sources = configToSources(this.config);
|
|
885
|
+
this.config.sources = [];
|
|
886
|
+
async.each(sources, (source, cb) => {
|
|
887
|
+
this.addSource(source, src => cb(null, src));
|
|
888
|
+
}, callback);
|
|
889
|
+
},
|
|
890
|
+
/**
|
|
891
|
+
* Installs the events manager onto the instance
|
|
892
|
+
* @private
|
|
893
|
+
*/
|
|
894
|
+
_initEvents() {
|
|
895
|
+
eventifier(this);
|
|
896
|
+
const triggerEvent = this.trigger;
|
|
897
|
+
this.trigger = function trigger(eventName) {
|
|
898
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
899
|
+
args[_key - 1] = arguments[_key];
|
|
900
|
+
}
|
|
901
|
+
if (this.$component) {
|
|
902
|
+
this.$component.trigger(eventName + ns, ...args);
|
|
903
|
+
}
|
|
904
|
+
return triggerEvent.call(this, eventName, ...args);
|
|
905
|
+
};
|
|
906
|
+
},
|
|
907
|
+
/**
|
|
908
|
+
* Ensures the right size is set according to the media type
|
|
909
|
+
* @private
|
|
910
|
+
*/
|
|
911
|
+
_initSize() {
|
|
912
|
+
const type = this.is('video') ? 'video' : 'audio';
|
|
913
|
+
const mediaConfig = defaults[type] || defaults.video;
|
|
914
|
+
this.config.width = this.config.width || mediaConfig.width;
|
|
915
|
+
this.config.height = this.config.height || mediaConfig.height;
|
|
916
|
+
if (isResponsiveSize(this.config.width) && !isResponsiveSize(this.config.height) || this.is('youtube')) {
|
|
917
|
+
// responsive width height should be auto
|
|
918
|
+
// for youtube iframe height is limited by ration
|
|
919
|
+
this.config.height = 'auto';
|
|
920
|
+
}
|
|
921
|
+
},
|
|
922
|
+
/**
|
|
923
|
+
* Initializes the right player instance
|
|
924
|
+
* @private
|
|
925
|
+
*/
|
|
926
|
+
_initPlayer() {
|
|
927
|
+
const playerFactory = players[this.type];
|
|
928
|
+
let error;
|
|
929
|
+
if (support.canPlay(this.type)) {
|
|
930
|
+
if (_.isFunction(playerFactory)) {
|
|
931
|
+
const playerConfig = {
|
|
932
|
+
type: this.getType(),
|
|
933
|
+
sources: this.getSources(),
|
|
934
|
+
preview: this.config.preview,
|
|
935
|
+
debug: this.config.debug,
|
|
936
|
+
stalledDetectionDelay: this.config.stalledDetectionDelay
|
|
937
|
+
};
|
|
938
|
+
this.player = playerFactory(this.$player, playerConfig).on('resize', (width, height) => {
|
|
939
|
+
if (this.$component) {
|
|
940
|
+
this.$component.width(width).height(height);
|
|
941
|
+
}
|
|
942
|
+
}).on('ready', () => this._onReady()).on('play', () => this._onPlay()).on('pause', () => this._onPause()).on('timeupdate', () => this._onTimeUpdate()).on('stalled', () => this._onStalled()).on('playing', () => this._onPlaying()).on('end', () => this._onEnd()).on('error', () => this._onError());
|
|
943
|
+
}
|
|
944
|
+
if (this.player) {
|
|
945
|
+
error = !this.player.init();
|
|
946
|
+
} else {
|
|
947
|
+
error = true;
|
|
948
|
+
}
|
|
1119
949
|
} else {
|
|
1120
950
|
error = true;
|
|
1121
951
|
}
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
this._setState('preview', this.config.preview);
|
|
1131
|
-
|
|
1132
|
-
this._setState('loading', !error);
|
|
1133
|
-
|
|
1134
|
-
if (error) {
|
|
1135
|
-
this._setState('ready', true);
|
|
1136
|
-
|
|
1137
|
-
this.trigger('ready');
|
|
1138
|
-
}
|
|
1139
|
-
},
|
|
1140
|
-
|
|
1141
|
-
/**
|
|
1142
|
-
* Initializes the player state
|
|
1143
|
-
* @private
|
|
1144
|
-
*/
|
|
1145
|
-
_initState: function _initState() {
|
|
1146
|
-
var isCORS = false;
|
|
1147
|
-
var page;
|
|
1148
|
-
|
|
1149
|
-
if (!this.is('youtube')) {
|
|
1150
|
-
page = new UrlParser(window.location);
|
|
1151
|
-
isCORS = _.some(this.config.sources, function (source) {
|
|
1152
|
-
return !page.sameDomain(source.src);
|
|
1153
|
-
});
|
|
1154
|
-
}
|
|
1155
|
-
|
|
1156
|
-
this._setState('cors', isCORS);
|
|
1157
|
-
|
|
1158
|
-
this._setState('ready', false);
|
|
1159
|
-
},
|
|
1160
|
-
|
|
1161
|
-
/**
|
|
1162
|
-
* Resets the internals attributes
|
|
1163
|
-
* @private
|
|
1164
|
-
*/
|
|
1165
|
-
_reset: function _reset() {
|
|
1166
|
-
this.config.is = {};
|
|
1167
|
-
|
|
1168
|
-
this._initType();
|
|
1169
|
-
|
|
1170
|
-
this.$component = null;
|
|
1171
|
-
this.$container = null;
|
|
1172
|
-
this.$player = null;
|
|
1173
|
-
this.$controls = null;
|
|
1174
|
-
this.$seek = null;
|
|
1175
|
-
this.$seekSlider = null;
|
|
1176
|
-
this.$sound = null;
|
|
1177
|
-
this.$volume = null;
|
|
1178
|
-
this.$volumeControl = null;
|
|
1179
|
-
this.$volumeSlider = null;
|
|
1180
|
-
this.$position = null;
|
|
1181
|
-
this.$duration = null;
|
|
1182
|
-
this.player = null;
|
|
1183
|
-
this.duration = 0;
|
|
1184
|
-
this.position = 0;
|
|
1185
|
-
this.timesPlayed = 0;
|
|
1186
|
-
this.volume = this.config.volume;
|
|
1187
|
-
this.autoStart = this.config.autoStart;
|
|
1188
|
-
this.autoStartAt = this.config.autoStartAt;
|
|
1189
|
-
this.startMuted = this.config.startMuted;
|
|
1190
|
-
},
|
|
1191
|
-
|
|
1192
|
-
/**
|
|
1193
|
-
* Builds the DOM content
|
|
1194
|
-
* @private
|
|
1195
|
-
*/
|
|
1196
|
-
_buildDom: function _buildDom() {
|
|
1197
|
-
var configForTemplate = _.clone(this.config);
|
|
1198
|
-
|
|
1199
|
-
configForTemplate.type = this.type;
|
|
1200
|
-
this.$component = $$1(playerTpl(configForTemplate));
|
|
1201
|
-
this.$player = this.$component.find('.player');
|
|
1202
|
-
this.$controls = this.$component.find('.controls');
|
|
1203
|
-
this.$seek = this.$controls.find('.seek .slider');
|
|
1204
|
-
this.$sound = this.$controls.find('.sound');
|
|
1205
|
-
this.$volumeControl = this.$controls.find('.volume');
|
|
1206
|
-
this.$volume = this.$controls.find('.volume .slider');
|
|
1207
|
-
this.$position = this.$controls.find('[data-control="time-cur"]');
|
|
1208
|
-
this.$duration = this.$controls.find('[data-control="time-end"]');
|
|
1209
|
-
this.$volumeSlider = this._renderSlider(this.$volume, this.volume, volumeMin, volumeMax, true);
|
|
1210
|
-
},
|
|
1211
|
-
|
|
1212
|
-
/**
|
|
1213
|
-
* Renders a slider onto an element
|
|
1214
|
-
* @param {jQuery} $elt - The element on which renders the slider
|
|
1215
|
-
* @param {Number} [value] - The current value of the slider
|
|
1216
|
-
* @param {Number} [min] - The min value of the slider
|
|
1217
|
-
* @param {Number} [max] - The max value of the slider
|
|
1218
|
-
* @param {Boolean} [vertical] - Tells if the slider must be vertical
|
|
1219
|
-
* @returns {jQuery} - Returns the element
|
|
1220
|
-
* @private
|
|
1221
|
-
*/
|
|
1222
|
-
_renderSlider: function _renderSlider($elt, value, min, max, vertical) {
|
|
1223
|
-
var orientation, direction;
|
|
1224
|
-
|
|
1225
|
-
if (vertical) {
|
|
1226
|
-
orientation = 'vertical';
|
|
1227
|
-
direction = 'rtl';
|
|
1228
|
-
} else {
|
|
1229
|
-
orientation = 'horizontal';
|
|
1230
|
-
direction = 'ltr';
|
|
1231
|
-
}
|
|
1232
|
-
|
|
1233
|
-
return $elt.noUiSlider({
|
|
1234
|
-
start: ensureNumber(value) || 0,
|
|
1235
|
-
step: 1,
|
|
1236
|
-
connect: 'lower',
|
|
1237
|
-
orientation: orientation,
|
|
1238
|
-
direction: direction,
|
|
1239
|
-
animate: true,
|
|
1240
|
-
range: {
|
|
1241
|
-
min: ensureNumber(min) || 0,
|
|
1242
|
-
max: ensureNumber(max) || 0
|
|
952
|
+
this._setState('error', error);
|
|
953
|
+
this._setState('nogui', !support.canControl());
|
|
954
|
+
this._setState('preview', this.config.preview);
|
|
955
|
+
this._setState('loading', !error);
|
|
956
|
+
if (error) {
|
|
957
|
+
this._setState('ready', true);
|
|
958
|
+
this.trigger('ready');
|
|
1243
959
|
}
|
|
1244
|
-
}
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
}
|
|
1256
|
-
},
|
|
1257
|
-
|
|
1258
|
-
/**
|
|
1259
|
-
* Binds events onto the rendered player
|
|
1260
|
-
* @private
|
|
1261
|
-
*/
|
|
1262
|
-
_bindEvents: function _bindEvents() {
|
|
1263
|
-
var _this7 = this;
|
|
1264
|
-
|
|
1265
|
-
var overing = false;
|
|
1266
|
-
this.$component.on("contextmenu".concat(ns), function (event) {
|
|
1267
|
-
return event.preventDefault();
|
|
1268
|
-
});
|
|
1269
|
-
this.$controls.on("click".concat(ns), '.action', function (event) {
|
|
1270
|
-
var $target = $$1(event.target);
|
|
1271
|
-
var $action = $target.closest('.action');
|
|
1272
|
-
var id = $action.data('control');
|
|
1273
|
-
|
|
1274
|
-
if (_.isFunction(_this7[id])) {
|
|
1275
|
-
_this7[id]();
|
|
960
|
+
},
|
|
961
|
+
/**
|
|
962
|
+
* Initializes the player state
|
|
963
|
+
* @private
|
|
964
|
+
*/
|
|
965
|
+
_initState() {
|
|
966
|
+
let isCORS = false;
|
|
967
|
+
let page;
|
|
968
|
+
if (!this.is('youtube')) {
|
|
969
|
+
page = new UrlParser(window.location);
|
|
970
|
+
isCORS = _.some(this.config.sources, source => !page.sameDomain(source.src));
|
|
1276
971
|
}
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
972
|
+
this._setState('cors', isCORS);
|
|
973
|
+
this._setState('ready', false);
|
|
974
|
+
},
|
|
975
|
+
/**
|
|
976
|
+
* Resets the internals attributes
|
|
977
|
+
* @private
|
|
978
|
+
*/
|
|
979
|
+
_reset() {
|
|
980
|
+
this.config.is = {};
|
|
981
|
+
this._initType();
|
|
982
|
+
this.$component = null;
|
|
983
|
+
this.$container = null;
|
|
984
|
+
this.$player = null;
|
|
985
|
+
this.$controls = null;
|
|
986
|
+
this.$seek = null;
|
|
987
|
+
this.$seekSlider = null;
|
|
988
|
+
this.$sound = null;
|
|
989
|
+
this.$volume = null;
|
|
990
|
+
this.$volumeControl = null;
|
|
991
|
+
this.$volumeSlider = null;
|
|
992
|
+
this.$position = null;
|
|
993
|
+
this.$duration = null;
|
|
994
|
+
this.player = null;
|
|
995
|
+
this.duration = 0;
|
|
996
|
+
this.position = 0;
|
|
997
|
+
this.timesPlayed = 0;
|
|
998
|
+
this.volume = this.config.volume;
|
|
999
|
+
this.autoStart = this.config.autoStart;
|
|
1000
|
+
this.autoStartAt = this.config.autoStartAt;
|
|
1001
|
+
this.startMuted = this.config.startMuted;
|
|
1002
|
+
},
|
|
1003
|
+
/**
|
|
1004
|
+
* Builds the DOM content
|
|
1005
|
+
* @private
|
|
1006
|
+
*/
|
|
1007
|
+
_buildDom() {
|
|
1008
|
+
const configForTemplate = _.clone(this.config);
|
|
1009
|
+
configForTemplate.type = this.type;
|
|
1010
|
+
this.$component = $$1(playerTpl(configForTemplate));
|
|
1011
|
+
this.$player = this.$component.find('.player');
|
|
1012
|
+
this.$controls = this.$component.find('.controls');
|
|
1013
|
+
this.$seek = this.$controls.find('.seek .slider');
|
|
1014
|
+
this.$sound = this.$controls.find('.sound');
|
|
1015
|
+
this.$volumeControl = this.$controls.find('.volume');
|
|
1016
|
+
this.$volume = this.$controls.find('.volume .slider');
|
|
1017
|
+
this.$position = this.$controls.find('[data-control="time-cur"]');
|
|
1018
|
+
this.$duration = this.$controls.find('[data-control="time-end"]');
|
|
1019
|
+
this.$volumeSlider = this._renderSlider(this.$volume, this.volume, volumeMin, volumeMax, true);
|
|
1020
|
+
},
|
|
1021
|
+
/**
|
|
1022
|
+
* Renders a slider onto an element
|
|
1023
|
+
* @param {jQuery} $elt - The element on which renders the slider
|
|
1024
|
+
* @param {Number} [value] - The current value of the slider
|
|
1025
|
+
* @param {Number} [min] - The min value of the slider
|
|
1026
|
+
* @param {Number} [max] - The max value of the slider
|
|
1027
|
+
* @param {Boolean} [vertical] - Tells if the slider must be vertical
|
|
1028
|
+
* @returns {jQuery} - Returns the element
|
|
1029
|
+
* @private
|
|
1030
|
+
*/
|
|
1031
|
+
_renderSlider($elt, value, min, max, vertical) {
|
|
1032
|
+
let orientation, direction;
|
|
1033
|
+
if (vertical) {
|
|
1034
|
+
orientation = 'vertical';
|
|
1035
|
+
direction = 'rtl';
|
|
1288
1036
|
} else {
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1037
|
+
orientation = 'horizontal';
|
|
1038
|
+
direction = 'ltr';
|
|
1039
|
+
}
|
|
1040
|
+
return $elt.noUiSlider({
|
|
1041
|
+
start: ensureNumber(value) || 0,
|
|
1042
|
+
step: 1,
|
|
1043
|
+
connect: 'lower',
|
|
1044
|
+
orientation: orientation,
|
|
1045
|
+
direction: direction,
|
|
1046
|
+
animate: true,
|
|
1047
|
+
range: {
|
|
1048
|
+
min: ensureNumber(min) || 0,
|
|
1049
|
+
max: ensureNumber(max) || 0
|
|
1294
1050
|
}
|
|
1051
|
+
});
|
|
1052
|
+
},
|
|
1053
|
+
/**
|
|
1054
|
+
* Destroys a slider bound to an element
|
|
1055
|
+
* @param {jQuery} $elt
|
|
1056
|
+
* @private
|
|
1057
|
+
*/
|
|
1058
|
+
_destroySlider($elt) {
|
|
1059
|
+
if ($elt) {
|
|
1060
|
+
$elt.get(0).destroy();
|
|
1295
1061
|
}
|
|
1296
|
-
}
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
if (
|
|
1318
|
-
|
|
1062
|
+
},
|
|
1063
|
+
/**
|
|
1064
|
+
* Binds events onto the rendered player
|
|
1065
|
+
* @private
|
|
1066
|
+
*/
|
|
1067
|
+
_bindEvents() {
|
|
1068
|
+
let overing = false;
|
|
1069
|
+
this.$component.on(`contextmenu${ns}`, event => event.preventDefault());
|
|
1070
|
+
this.$controls.on(`click${ns}`, '.action', event => {
|
|
1071
|
+
const $target = $$1(event.target);
|
|
1072
|
+
const $action = $target.closest('.action');
|
|
1073
|
+
const id = $action.data('control');
|
|
1074
|
+
if (_.isFunction(this[id])) {
|
|
1075
|
+
this[id]();
|
|
1076
|
+
}
|
|
1077
|
+
});
|
|
1078
|
+
this.$player.on(`click${ns}`, event => {
|
|
1079
|
+
const $target = $$1(event.target);
|
|
1080
|
+
const $action = $target.closest('.action');
|
|
1081
|
+
|
|
1082
|
+
// if action was clicked
|
|
1083
|
+
if ($action.length) {
|
|
1084
|
+
const id = $action.data('control');
|
|
1085
|
+
if (_.isFunction(this[id])) {
|
|
1086
|
+
this[id]();
|
|
1087
|
+
}
|
|
1319
1088
|
} else {
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1089
|
+
// default action is toggle play
|
|
1090
|
+
if (this.is('playing')) {
|
|
1091
|
+
this.pause();
|
|
1092
|
+
} else {
|
|
1093
|
+
this.play();
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
});
|
|
1097
|
+
this.$seek.on(`change${ns}`, (event, value) => {
|
|
1098
|
+
this.seek(value, true);
|
|
1099
|
+
});
|
|
1100
|
+
$$1(document).on(`updateVolume${ns}`, (event, value) => {
|
|
1101
|
+
this.setVolume(value);
|
|
1102
|
+
});
|
|
1103
|
+
this.$volume.on(`change${ns}`, (event, value) => {
|
|
1104
|
+
this.unmute();
|
|
1105
|
+
$$1(document).trigger(`updateVolume${ns}`, value);
|
|
1106
|
+
this.setVolume(value, true);
|
|
1107
|
+
});
|
|
1108
|
+
this.$sound.on(`mouseover${ns}`, 'a', () => {
|
|
1109
|
+
let position;
|
|
1110
|
+
if (!overing && !this.$volumeControl.hasClass('up') && !this.$volumeControl.hasClass('down')) {
|
|
1111
|
+
overing = true;
|
|
1112
|
+
position = this.$controls[0].getBoundingClientRect();
|
|
1113
|
+
if (position && position.top && position.top < volumePositionThreshold) {
|
|
1114
|
+
this.$volumeControl.addClass('down');
|
|
1115
|
+
} else {
|
|
1116
|
+
this.$volumeControl.addClass('up');
|
|
1327
1117
|
}
|
|
1328
1118
|
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1119
|
+
//close the volume control after 15s
|
|
1120
|
+
this.overingTimer = _.delay(() => {
|
|
1121
|
+
if (this.$volumeControl) {
|
|
1122
|
+
this.$volumeControl.removeClass('up down');
|
|
1123
|
+
}
|
|
1124
|
+
overing = false;
|
|
1125
|
+
}, 15000);
|
|
1126
|
+
this.$volumeControl.one(`mouseleave${ns}`, () => {
|
|
1127
|
+
this.$volumeControl.removeClass('up down');
|
|
1128
|
+
overing = false;
|
|
1129
|
+
});
|
|
1130
|
+
}
|
|
1131
|
+
});
|
|
1132
|
+
},
|
|
1133
|
+
/**
|
|
1134
|
+
* Unbinds events from the rendered player
|
|
1135
|
+
* @private
|
|
1136
|
+
*/
|
|
1137
|
+
_unbindEvents() {
|
|
1138
|
+
this.$component.off(ns);
|
|
1139
|
+
this.$player.off(ns);
|
|
1140
|
+
this.$controls.off(ns);
|
|
1141
|
+
this.$seek.off(ns);
|
|
1142
|
+
this.$volume.off(ns);
|
|
1143
|
+
|
|
1144
|
+
//if the volume is opened and the player destroyed,
|
|
1145
|
+
//prevent the callback to run
|
|
1146
|
+
if (this.overingTimer) {
|
|
1147
|
+
clearTimeout(this.overingTimer);
|
|
1148
|
+
}
|
|
1149
|
+
$$1(document).off(ns);
|
|
1150
|
+
},
|
|
1151
|
+
/**
|
|
1152
|
+
* Updates the volume slider
|
|
1153
|
+
* @param {Number} value
|
|
1154
|
+
* @private
|
|
1155
|
+
*/
|
|
1156
|
+
_updateVolumeSlider(value) {
|
|
1157
|
+
if (this.$volumeSlider) {
|
|
1158
|
+
this.$volumeSlider.val(value);
|
|
1159
|
+
}
|
|
1160
|
+
},
|
|
1161
|
+
/**
|
|
1162
|
+
* Updates the displayed volume
|
|
1163
|
+
* @param {Number} value
|
|
1164
|
+
* @param {*} [internal]
|
|
1165
|
+
* @private
|
|
1166
|
+
*/
|
|
1167
|
+
_updateVolume(value, internal) {
|
|
1168
|
+
this.volume = Math.max(volumeMin, Math.min(volumeMax, parseFloat(value)));
|
|
1169
|
+
this._storeVolume(this.volume);
|
|
1170
|
+
if (!internal) {
|
|
1171
|
+
this._updateVolumeSlider(value);
|
|
1172
|
+
}
|
|
1173
|
+
},
|
|
1174
|
+
/**
|
|
1175
|
+
* Updates the time slider
|
|
1176
|
+
* @param {Number} value
|
|
1177
|
+
* @private
|
|
1178
|
+
*/
|
|
1179
|
+
_updatePositionSlider(value) {
|
|
1180
|
+
if (this.$seekSlider) {
|
|
1181
|
+
this.$seekSlider.val(value);
|
|
1182
|
+
}
|
|
1183
|
+
},
|
|
1184
|
+
/**
|
|
1185
|
+
* Updates the time label
|
|
1186
|
+
* @param {Number} value
|
|
1187
|
+
* @private
|
|
1188
|
+
*/
|
|
1189
|
+
_updatePositionLabel(value) {
|
|
1190
|
+
if (this.$position) {
|
|
1191
|
+
this.$position.text(timerFormat(value));
|
|
1192
|
+
}
|
|
1193
|
+
},
|
|
1194
|
+
/**
|
|
1195
|
+
* Updates the displayed time position
|
|
1196
|
+
* @param {Number} value
|
|
1197
|
+
* @param {*} [internal]
|
|
1198
|
+
* @private
|
|
1199
|
+
*/
|
|
1200
|
+
_updatePosition(value, internal) {
|
|
1201
|
+
this.position = Math.max(0, Math.min(this.duration || +Infinity, parseFloat(value)));
|
|
1202
|
+
if (!internal && this.duration) {
|
|
1203
|
+
this._updatePositionSlider(this.position);
|
|
1204
|
+
}
|
|
1205
|
+
this._updatePositionLabel(this.position);
|
|
1206
|
+
},
|
|
1207
|
+
/**
|
|
1208
|
+
* Updates the duration slider
|
|
1209
|
+
* @param {Number} value
|
|
1210
|
+
* @private
|
|
1211
|
+
*/
|
|
1212
|
+
_updateDurationSlider(value) {
|
|
1213
|
+
if (this.$seekSlider) {
|
|
1214
|
+
this._destroySlider(this.$seekSlider);
|
|
1215
|
+
this.$seekSlider = null;
|
|
1337
1216
|
}
|
|
1338
|
-
});
|
|
1339
|
-
},
|
|
1340
|
-
|
|
1341
|
-
/**
|
|
1342
|
-
* Unbinds events from the rendered player
|
|
1343
|
-
* @private
|
|
1344
|
-
*/
|
|
1345
|
-
_unbindEvents: function _unbindEvents() {
|
|
1346
|
-
this.$component.off(ns);
|
|
1347
|
-
this.$player.off(ns);
|
|
1348
|
-
this.$controls.off(ns);
|
|
1349
|
-
this.$seek.off(ns);
|
|
1350
|
-
this.$volume.off(ns); //if the volume is opened and the player destroyed,
|
|
1351
|
-
//prevent the callback to run
|
|
1352
|
-
|
|
1353
|
-
if (this.overingTimer) {
|
|
1354
|
-
clearTimeout(this.overingTimer);
|
|
1355
|
-
}
|
|
1356
|
-
|
|
1357
|
-
$$1(document).off(ns);
|
|
1358
|
-
},
|
|
1359
|
-
|
|
1360
|
-
/**
|
|
1361
|
-
* Updates the volume slider
|
|
1362
|
-
* @param {Number} value
|
|
1363
|
-
* @private
|
|
1364
|
-
*/
|
|
1365
|
-
_updateVolumeSlider: function _updateVolumeSlider(value) {
|
|
1366
|
-
if (this.$volumeSlider) {
|
|
1367
|
-
this.$volumeSlider.val(value);
|
|
1368
|
-
}
|
|
1369
|
-
},
|
|
1370
|
-
|
|
1371
|
-
/**
|
|
1372
|
-
* Updates the displayed volume
|
|
1373
|
-
* @param {Number} value
|
|
1374
|
-
* @param {*} [internal]
|
|
1375
|
-
* @private
|
|
1376
|
-
*/
|
|
1377
|
-
_updateVolume: function _updateVolume(value, internal) {
|
|
1378
|
-
this.volume = Math.max(volumeMin, Math.min(volumeMax, parseFloat(value)));
|
|
1379
|
-
|
|
1380
|
-
this._storeVolume(this.volume);
|
|
1381
|
-
|
|
1382
|
-
if (!internal) {
|
|
1383
|
-
this._updateVolumeSlider(value);
|
|
1384
|
-
}
|
|
1385
|
-
},
|
|
1386
|
-
|
|
1387
|
-
/**
|
|
1388
|
-
* Updates the time slider
|
|
1389
|
-
* @param {Number} value
|
|
1390
|
-
* @private
|
|
1391
|
-
*/
|
|
1392
|
-
_updatePositionSlider: function _updatePositionSlider(value) {
|
|
1393
|
-
if (this.$seekSlider) {
|
|
1394
|
-
this.$seekSlider.val(value);
|
|
1395
|
-
}
|
|
1396
|
-
},
|
|
1397
|
-
|
|
1398
|
-
/**
|
|
1399
|
-
* Updates the time label
|
|
1400
|
-
* @param {Number} value
|
|
1401
|
-
* @private
|
|
1402
|
-
*/
|
|
1403
|
-
_updatePositionLabel: function _updatePositionLabel(value) {
|
|
1404
|
-
if (this.$position) {
|
|
1405
|
-
this.$position.text(timerFormat(value));
|
|
1406
|
-
}
|
|
1407
|
-
},
|
|
1408
|
-
|
|
1409
|
-
/**
|
|
1410
|
-
* Updates the displayed time position
|
|
1411
|
-
* @param {Number} value
|
|
1412
|
-
* @param {*} [internal]
|
|
1413
|
-
* @private
|
|
1414
|
-
*/
|
|
1415
|
-
_updatePosition: function _updatePosition(value, internal) {
|
|
1416
|
-
this.position = Math.max(0, Math.min(this.duration || +Infinity, parseFloat(value)));
|
|
1417
|
-
|
|
1418
|
-
if (!internal && this.duration) {
|
|
1419
|
-
this._updatePositionSlider(this.position);
|
|
1420
|
-
}
|
|
1421
|
-
|
|
1422
|
-
this._updatePositionLabel(this.position);
|
|
1423
|
-
},
|
|
1424
|
-
|
|
1425
|
-
/**
|
|
1426
|
-
* Updates the duration slider
|
|
1427
|
-
* @param {Number} value
|
|
1428
|
-
* @private
|
|
1429
|
-
*/
|
|
1430
|
-
_updateDurationSlider: function _updateDurationSlider(value) {
|
|
1431
|
-
if (this.$seekSlider) {
|
|
1432
|
-
this._destroySlider(this.$seekSlider);
|
|
1433
|
-
|
|
1434
|
-
this.$seekSlider = null;
|
|
1435
|
-
}
|
|
1436
|
-
|
|
1437
|
-
if (value && isFinite(value)) {
|
|
1438
|
-
this.$seekSlider = this._renderSlider(this.$seek, 0, 0, value);
|
|
1439
|
-
this.$seekSlider.attr('disabled', !this.config.canSeek);
|
|
1440
|
-
}
|
|
1441
|
-
},
|
|
1442
|
-
|
|
1443
|
-
/**
|
|
1444
|
-
* Updates the duration label
|
|
1445
|
-
* @param {Number} value
|
|
1446
|
-
* @private
|
|
1447
|
-
*/
|
|
1448
|
-
_updateDurationLabel: function _updateDurationLabel(value) {
|
|
1449
|
-
if (this.$duration) {
|
|
1450
1217
|
if (value && isFinite(value)) {
|
|
1451
|
-
this.$
|
|
1452
|
-
|
|
1453
|
-
this.$duration.hide();
|
|
1218
|
+
this.$seekSlider = this._renderSlider(this.$seek, 0, 0, value);
|
|
1219
|
+
this.$seekSlider.attr('disabled', !this.config.canSeek);
|
|
1454
1220
|
}
|
|
1455
|
-
}
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
* @param {Number|String} value
|
|
1461
|
-
* @private
|
|
1462
|
-
*/
|
|
1463
|
-
_updateDuration: function _updateDuration(value) {
|
|
1464
|
-
var duration = Math.abs(parseFloat(value));
|
|
1465
|
-
|
|
1466
|
-
if (duration !== this.duration) {
|
|
1467
|
-
this.duration = duration;
|
|
1468
|
-
|
|
1469
|
-
this._updateDurationSlider(this.duration);
|
|
1470
|
-
|
|
1471
|
-
this._updateDurationLabel(this.duration);
|
|
1472
|
-
}
|
|
1473
|
-
},
|
|
1474
|
-
|
|
1475
|
-
/**
|
|
1476
|
-
* Event called when the media is ready
|
|
1477
|
-
* @private
|
|
1478
|
-
*/
|
|
1479
|
-
_onReady: function _onReady() {
|
|
1480
|
-
if (this.is('error')) {
|
|
1481
|
-
this._setState('error', false);
|
|
1482
|
-
}
|
|
1483
|
-
|
|
1484
|
-
var duration = this.player.getDuration();
|
|
1485
|
-
var timePreview = this.config.preview || duration;
|
|
1486
|
-
|
|
1487
|
-
if (timePreview) {
|
|
1488
|
-
this._updateDuration(duration);
|
|
1489
|
-
}
|
|
1490
|
-
|
|
1491
|
-
this.setInitialStates();
|
|
1492
|
-
/**
|
|
1493
|
-
* Triggers a media ready event
|
|
1494
|
-
* @event mediaplayer#ready
|
|
1221
|
+
},
|
|
1222
|
+
/**
|
|
1223
|
+
* Updates the duration label
|
|
1224
|
+
* @param {Number} value
|
|
1225
|
+
* @private
|
|
1495
1226
|
*/
|
|
1227
|
+
_updateDurationLabel(value) {
|
|
1228
|
+
if (this.$duration) {
|
|
1229
|
+
if (value && isFinite(value)) {
|
|
1230
|
+
this.$duration.text(timerFormat(value)).show();
|
|
1231
|
+
} else {
|
|
1232
|
+
this.$duration.hide();
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
},
|
|
1236
|
+
/**
|
|
1237
|
+
* Updates the displayed duration
|
|
1238
|
+
* @param {Number|String} value
|
|
1239
|
+
* @private
|
|
1240
|
+
*/
|
|
1241
|
+
_updateDuration(value) {
|
|
1242
|
+
const duration = Math.abs(parseFloat(value));
|
|
1243
|
+
if (duration !== this.duration) {
|
|
1244
|
+
this.duration = duration;
|
|
1245
|
+
this._updateDurationSlider(this.duration);
|
|
1246
|
+
this._updateDurationLabel(this.duration);
|
|
1247
|
+
}
|
|
1248
|
+
},
|
|
1249
|
+
/**
|
|
1250
|
+
* Event called when the media is ready
|
|
1251
|
+
* @private
|
|
1252
|
+
*/
|
|
1253
|
+
_onReady() {
|
|
1254
|
+
if (this.is('error')) {
|
|
1255
|
+
this._setState('error', false);
|
|
1256
|
+
}
|
|
1257
|
+
const duration = this.player.getDuration();
|
|
1258
|
+
const timePreview = this.config.preview || duration;
|
|
1259
|
+
if (timePreview) {
|
|
1260
|
+
this._updateDuration(duration);
|
|
1261
|
+
}
|
|
1262
|
+
this.setInitialStates();
|
|
1496
1263
|
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
if (this.autoStartAt) {
|
|
1503
|
-
this.seek(this.autoStartAt);
|
|
1504
|
-
} else if (this.autoStart) {
|
|
1505
|
-
this.play();
|
|
1506
|
-
}
|
|
1507
|
-
|
|
1508
|
-
if (this.config.preview && this.$container && this.config.height && this.config.height !== 'auto') {
|
|
1509
|
-
this._setMaxHeight();
|
|
1510
|
-
}
|
|
1511
|
-
},
|
|
1512
|
-
|
|
1513
|
-
/**
|
|
1514
|
-
* Set max height limit for container
|
|
1515
|
-
* using by old media items with defined height.
|
|
1516
|
-
* @private
|
|
1517
|
-
*/
|
|
1518
|
-
_setMaxHeight: function _setMaxHeight() {
|
|
1519
|
-
var $video = this.$container.find('video.video');
|
|
1520
|
-
var controlsHeight = parseInt(window.getComputedStyle(this.$controls[0]).height);
|
|
1521
|
-
var scale = $video.height() / this.config.height;
|
|
1522
|
-
var playerWidth = this.$container.find('.player').width();
|
|
1523
|
-
var videoWidth = $video.width() / scale;
|
|
1264
|
+
/**
|
|
1265
|
+
* Triggers a media ready event
|
|
1266
|
+
* @event mediaplayer#ready
|
|
1267
|
+
*/
|
|
1268
|
+
this.trigger('ready');
|
|
1524
1269
|
|
|
1525
|
-
|
|
1526
|
-
this.
|
|
1527
|
-
|
|
1528
|
-
this
|
|
1529
|
-
|
|
1270
|
+
// set the initial state
|
|
1271
|
+
this.setVolume(this.volume);
|
|
1272
|
+
this.mute(!!this.startMuted);
|
|
1273
|
+
if (this.autoStartAt) {
|
|
1274
|
+
this.seek(this.autoStartAt);
|
|
1275
|
+
} else if (this.autoStart) {
|
|
1276
|
+
this.play();
|
|
1277
|
+
}
|
|
1278
|
+
if (this.config.preview && this.$container && this.config.height && this.config.height !== 'auto') {
|
|
1279
|
+
this._setMaxHeight();
|
|
1280
|
+
}
|
|
1281
|
+
},
|
|
1282
|
+
/**
|
|
1283
|
+
* Set max height limit for container
|
|
1284
|
+
* using by old media items with defined height.
|
|
1285
|
+
* @private
|
|
1286
|
+
*/
|
|
1287
|
+
_setMaxHeight() {
|
|
1288
|
+
const $video = this.$container.find('video.video');
|
|
1289
|
+
const controlsHeight = parseInt(window.getComputedStyle(this.$controls[0]).height);
|
|
1290
|
+
const scale = $video.height() / this.config.height;
|
|
1291
|
+
const playerWidth = this.$container.find('.player').width();
|
|
1292
|
+
const videoWidth = $video.width() / scale;
|
|
1293
|
+
if (videoWidth > playerWidth) {
|
|
1294
|
+
this.execute('setSize', '100%', 'auto');
|
|
1295
|
+
} else {
|
|
1296
|
+
this.$component.css({
|
|
1297
|
+
maxHeight: `${this.config.height + controlsHeight}px`
|
|
1298
|
+
});
|
|
1299
|
+
this.execute('setSize', Math.floor(videoWidth), 'auto');
|
|
1300
|
+
}
|
|
1301
|
+
},
|
|
1302
|
+
/**
|
|
1303
|
+
* Update volume in DBIndex store
|
|
1304
|
+
* @param {Number} volume
|
|
1305
|
+
* @returns {Promise}
|
|
1306
|
+
* @private
|
|
1307
|
+
*/
|
|
1308
|
+
_storeVolume(volume) {
|
|
1309
|
+
return store('mediaVolume').then(volumeStore => volumeStore.setItem('volume', volume));
|
|
1310
|
+
},
|
|
1311
|
+
/**
|
|
1312
|
+
* Get volume from DBIndex store
|
|
1313
|
+
* @returns {Promise}
|
|
1314
|
+
* @private
|
|
1315
|
+
*/
|
|
1316
|
+
_updateVolumeFromStore() {
|
|
1317
|
+
return store('mediaVolume').then(volumeStore => volumeStore.getItem('volume')).then(volume => {
|
|
1318
|
+
if (_.isNumber(volume)) {
|
|
1319
|
+
this.volume = Math.max(volumeMin, Math.min(volumeMax, parseFloat(volume)));
|
|
1320
|
+
this.setVolume(this.volume);
|
|
1321
|
+
}
|
|
1530
1322
|
});
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1323
|
+
},
|
|
1324
|
+
/**
|
|
1325
|
+
* Event called when the media throws unrecoverable error
|
|
1326
|
+
* @private
|
|
1327
|
+
*/
|
|
1328
|
+
_onError() {
|
|
1329
|
+
this._setState('error', true);
|
|
1330
|
+
this._setState('loading', false);
|
|
1534
1331
|
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1332
|
+
/**
|
|
1333
|
+
* Triggers an unrecoverable media error event
|
|
1334
|
+
* @event mediaplayer#error
|
|
1335
|
+
*/
|
|
1336
|
+
this.trigger('error');
|
|
1337
|
+
},
|
|
1338
|
+
/**
|
|
1339
|
+
* Event called when the media is played
|
|
1340
|
+
* @private
|
|
1341
|
+
*/
|
|
1342
|
+
_onPlay() {
|
|
1343
|
+
this._playingState(true);
|
|
1344
|
+
this._setState('preview', true);
|
|
1546
1345
|
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1346
|
+
/**
|
|
1347
|
+
* Triggers a media playback event
|
|
1348
|
+
* @event mediaplayer#play
|
|
1349
|
+
*/
|
|
1350
|
+
this.trigger('play', this.player && this.player.getMedia());
|
|
1351
|
+
},
|
|
1352
|
+
/**
|
|
1353
|
+
* Event called when the media is paused
|
|
1354
|
+
* @private
|
|
1355
|
+
*/
|
|
1356
|
+
_onPause() {
|
|
1357
|
+
this._playingState(false);
|
|
1554
1358
|
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1359
|
+
/**
|
|
1360
|
+
* Triggers a media paused event
|
|
1361
|
+
* @event mediaplayer#pause
|
|
1362
|
+
*/
|
|
1363
|
+
this.trigger('pause');
|
|
1364
|
+
},
|
|
1365
|
+
/**
|
|
1366
|
+
* Event called when the media is ended
|
|
1367
|
+
* @private
|
|
1368
|
+
*/
|
|
1369
|
+
_onEnd() {
|
|
1370
|
+
this.timesPlayed++;
|
|
1371
|
+
this._playingState(false, true);
|
|
1372
|
+
this._updatePosition(0);
|
|
1560
1373
|
|
|
1561
|
-
|
|
1374
|
+
// disable when the play limit is reached
|
|
1375
|
+
if (this._playLimitReached()) {
|
|
1376
|
+
if (!this.is('disabled')) {
|
|
1377
|
+
this.disable();
|
|
1378
|
+
}
|
|
1379
|
+
/**
|
|
1380
|
+
* Triggers a play limit reached event
|
|
1381
|
+
* @event mediaplayer#limitreached
|
|
1382
|
+
*/
|
|
1383
|
+
this.trigger('limitreached');
|
|
1384
|
+
} else if (this.loop) {
|
|
1385
|
+
this.restart();
|
|
1386
|
+
} else if (parseInt(this.config.replayTimeout, 10) > 0) {
|
|
1387
|
+
this.replayTimeoutStartMs = new window.Date().getTime();
|
|
1388
|
+
this._replayTimeout();
|
|
1562
1389
|
}
|
|
1563
|
-
});
|
|
1564
|
-
},
|
|
1565
|
-
|
|
1566
|
-
/**
|
|
1567
|
-
* Event called when the media throws unrecoverable error
|
|
1568
|
-
* @private
|
|
1569
|
-
*/
|
|
1570
|
-
_onError: function _onError() {
|
|
1571
|
-
this._setState('error', true);
|
|
1572
1390
|
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1391
|
+
/**
|
|
1392
|
+
* Triggers a media ended event
|
|
1393
|
+
* @event mediaplayer#ended
|
|
1394
|
+
*/
|
|
1395
|
+
this.trigger('ended');
|
|
1396
|
+
},
|
|
1397
|
+
/**
|
|
1398
|
+
* Event called when the playback is playing
|
|
1399
|
+
* @private
|
|
1577
1400
|
*/
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
*/
|
|
1587
|
-
_onPlay: function _onPlay() {
|
|
1588
|
-
this._playingState(true);
|
|
1589
|
-
|
|
1590
|
-
this._setState('preview', true);
|
|
1591
|
-
/**
|
|
1592
|
-
* Triggers a media playback event
|
|
1593
|
-
* @event mediaplayer#play
|
|
1401
|
+
_onPlaying() {
|
|
1402
|
+
this._setState('preview', true);
|
|
1403
|
+
this._setState('stalled', false);
|
|
1404
|
+
this._setState('ready', true);
|
|
1405
|
+
},
|
|
1406
|
+
/**
|
|
1407
|
+
* Event called when the playback is stalled
|
|
1408
|
+
* @private
|
|
1594
1409
|
*/
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
* @private
|
|
1603
|
-
*/
|
|
1604
|
-
_onPause: function _onPause() {
|
|
1605
|
-
this._playingState(false);
|
|
1606
|
-
/**
|
|
1607
|
-
* Triggers a media paused event
|
|
1608
|
-
* @event mediaplayer#pause
|
|
1410
|
+
_onStalled() {
|
|
1411
|
+
this._setState('stalled', true);
|
|
1412
|
+
this._setState('ready', false);
|
|
1413
|
+
},
|
|
1414
|
+
/**
|
|
1415
|
+
* Event called when the time position has changed
|
|
1416
|
+
* @private
|
|
1609
1417
|
*/
|
|
1418
|
+
_onTimeUpdate() {
|
|
1419
|
+
this._updatePosition(this.player.getPosition());
|
|
1610
1420
|
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
if (this._playLimitReached()) {
|
|
1628
|
-
if (!this.is('disabled')) {
|
|
1421
|
+
/**
|
|
1422
|
+
* Triggers a media time update event
|
|
1423
|
+
* @event mediaplayer#update
|
|
1424
|
+
*/
|
|
1425
|
+
this.trigger('update');
|
|
1426
|
+
},
|
|
1427
|
+
/**
|
|
1428
|
+
* Run a timer to disable the possibility of replaying a media
|
|
1429
|
+
* @private
|
|
1430
|
+
*/
|
|
1431
|
+
_replayTimeout() {
|
|
1432
|
+
const nowMs = new window.Date().getTime(),
|
|
1433
|
+
elapsedSeconds = Math.floor((nowMs - this.replayTimeoutStartMs) / 1000);
|
|
1434
|
+
this.timerId = requestAnimationFrame(this._replayTimeout.bind(this));
|
|
1435
|
+
if (elapsedSeconds >= parseInt(this.config.replayTimeout, 10)) {
|
|
1629
1436
|
this.disable();
|
|
1437
|
+
cancelAnimationFrame(this.timerId);
|
|
1630
1438
|
}
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
this.trigger('limitreached');
|
|
1638
|
-
} else if (this.loop) {
|
|
1639
|
-
this.restart();
|
|
1640
|
-
} else if (parseInt(this.config.replayTimeout, 10) > 0) {
|
|
1641
|
-
this.replayTimeoutStartMs = new window.Date().getTime();
|
|
1642
|
-
|
|
1643
|
-
this._replayTimeout();
|
|
1644
|
-
}
|
|
1645
|
-
/**
|
|
1646
|
-
* Triggers a media ended event
|
|
1647
|
-
* @event mediaplayer#ended
|
|
1439
|
+
},
|
|
1440
|
+
/**
|
|
1441
|
+
* Checks if the play limit has been reached
|
|
1442
|
+
* @returns {Boolean}
|
|
1443
|
+
* @private
|
|
1648
1444
|
*/
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
* @private
|
|
1657
|
-
*/
|
|
1658
|
-
_onPlaying: function _onPlaying() {
|
|
1659
|
-
this._setState('preview', true);
|
|
1660
|
-
|
|
1661
|
-
this._setState('stalled', false);
|
|
1662
|
-
|
|
1663
|
-
this._setState('ready', true);
|
|
1664
|
-
},
|
|
1665
|
-
|
|
1666
|
-
/**
|
|
1667
|
-
* Event called when the playback is stalled
|
|
1668
|
-
* @private
|
|
1669
|
-
*/
|
|
1670
|
-
_onStalled: function _onStalled() {
|
|
1671
|
-
this._setState('stalled', true);
|
|
1672
|
-
|
|
1673
|
-
this._setState('ready', false);
|
|
1674
|
-
},
|
|
1675
|
-
|
|
1676
|
-
/**
|
|
1677
|
-
* Event called when the time position has changed
|
|
1678
|
-
* @private
|
|
1679
|
-
*/
|
|
1680
|
-
_onTimeUpdate: function _onTimeUpdate() {
|
|
1681
|
-
this._updatePosition(this.player.getPosition());
|
|
1682
|
-
/**
|
|
1683
|
-
* Triggers a media time update event
|
|
1684
|
-
* @event mediaplayer#update
|
|
1445
|
+
_playLimitReached() {
|
|
1446
|
+
return this.config.maxPlays && this.timesPlayed >= this.config.maxPlays;
|
|
1447
|
+
},
|
|
1448
|
+
/**
|
|
1449
|
+
* Checks if the media can be played
|
|
1450
|
+
* @returns {Boolean}
|
|
1451
|
+
* @private
|
|
1685
1452
|
*/
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
this._setState(stateName, false);
|
|
1776
|
-
|
|
1777
|
-
this.resume();
|
|
1778
|
-
return this;
|
|
1779
|
-
},
|
|
1780
|
-
|
|
1781
|
-
/**
|
|
1782
|
-
* Sets the media player to a particular state and pauses the playback
|
|
1783
|
-
* @param {String} stateName
|
|
1784
|
-
* @returns {mediaplayer}
|
|
1785
|
-
* @private
|
|
1786
|
-
*/
|
|
1787
|
-
_toState: function _toState(stateName) {
|
|
1788
|
-
this.pause();
|
|
1789
|
-
|
|
1790
|
-
this._setState(stateName, true);
|
|
1791
|
-
|
|
1792
|
-
return this;
|
|
1793
|
-
},
|
|
1794
|
-
|
|
1795
|
-
/**
|
|
1796
|
-
* Sets the playing state
|
|
1797
|
-
* @param {Boolean} state
|
|
1798
|
-
* @param {Boolean} [ended]
|
|
1799
|
-
* @returns {mediaplayer}
|
|
1800
|
-
* @private
|
|
1801
|
-
*/
|
|
1802
|
-
_playingState: function _playingState(state, ended) {
|
|
1803
|
-
this._setState('playing', !!state);
|
|
1804
|
-
|
|
1805
|
-
this._setState('paused', !state);
|
|
1806
|
-
|
|
1807
|
-
this._setState('ended', !!ended);
|
|
1808
|
-
|
|
1809
|
-
return this;
|
|
1810
|
-
},
|
|
1811
|
-
|
|
1812
|
-
/**
|
|
1813
|
-
* Executes a command onto the media
|
|
1814
|
-
* @param {String} command - The name of the command to execute
|
|
1815
|
-
* @param {*} args - additional arguments
|
|
1816
|
-
* @returns {*}
|
|
1817
|
-
* @private
|
|
1818
|
-
*/
|
|
1819
|
-
execute: function execute(command) {
|
|
1820
|
-
if (this.player && 'function' === typeof this.player[command]) {
|
|
1821
|
-
var _this$player;
|
|
1822
|
-
|
|
1823
|
-
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
1824
|
-
args[_key2 - 1] = arguments[_key2];
|
|
1453
|
+
_canPlay() {
|
|
1454
|
+
return (this.is('ready') || this.is('stalled')) && !this.is('disabled') && !this.is('hidden') && !this._playLimitReached();
|
|
1455
|
+
},
|
|
1456
|
+
/**
|
|
1457
|
+
* Checks if the media can be paused
|
|
1458
|
+
* @returns {Boolean}
|
|
1459
|
+
* @private
|
|
1460
|
+
*/
|
|
1461
|
+
_canPause() {
|
|
1462
|
+
return !!this.config.canPause;
|
|
1463
|
+
},
|
|
1464
|
+
/**
|
|
1465
|
+
* Checks if the media can be sought
|
|
1466
|
+
* @returns {Boolean}
|
|
1467
|
+
* @private
|
|
1468
|
+
*/
|
|
1469
|
+
_canSeek() {
|
|
1470
|
+
return !!this.config.canSeek;
|
|
1471
|
+
},
|
|
1472
|
+
/**
|
|
1473
|
+
* Checks if the playback can be resumed
|
|
1474
|
+
* @returns {Boolean}
|
|
1475
|
+
* @private
|
|
1476
|
+
*/
|
|
1477
|
+
_canResume() {
|
|
1478
|
+
return this.is('paused') && this._canPlay();
|
|
1479
|
+
},
|
|
1480
|
+
/**
|
|
1481
|
+
* Sets the media is in a particular state
|
|
1482
|
+
* @param {String} name
|
|
1483
|
+
* @param {Boolean} value
|
|
1484
|
+
* @returns {mediaplayer}
|
|
1485
|
+
*/
|
|
1486
|
+
_setState(name, value) {
|
|
1487
|
+
value = !!value;
|
|
1488
|
+
this.config.is[name] = value;
|
|
1489
|
+
if (this.$component) {
|
|
1490
|
+
this.$component.toggleClass(name, value);
|
|
1491
|
+
}
|
|
1492
|
+
return this;
|
|
1493
|
+
},
|
|
1494
|
+
/**
|
|
1495
|
+
* Restores the media player from a particular state and resumes the playback
|
|
1496
|
+
* @param {String} stateName
|
|
1497
|
+
* @returns {mediaplayer}
|
|
1498
|
+
* @private
|
|
1499
|
+
*/
|
|
1500
|
+
_fromState(stateName) {
|
|
1501
|
+
this._setState(stateName, false);
|
|
1502
|
+
this.resume();
|
|
1503
|
+
return this;
|
|
1504
|
+
},
|
|
1505
|
+
/**
|
|
1506
|
+
* Sets the media player to a particular state and pauses the playback
|
|
1507
|
+
* @param {String} stateName
|
|
1508
|
+
* @returns {mediaplayer}
|
|
1509
|
+
* @private
|
|
1510
|
+
*/
|
|
1511
|
+
_toState(stateName) {
|
|
1512
|
+
this.pause();
|
|
1513
|
+
this._setState(stateName, true);
|
|
1514
|
+
return this;
|
|
1515
|
+
},
|
|
1516
|
+
/**
|
|
1517
|
+
* Sets the playing state
|
|
1518
|
+
* @param {Boolean} state
|
|
1519
|
+
* @param {Boolean} [ended]
|
|
1520
|
+
* @returns {mediaplayer}
|
|
1521
|
+
* @private
|
|
1522
|
+
*/
|
|
1523
|
+
_playingState(state, ended) {
|
|
1524
|
+
this._setState('playing', !!state);
|
|
1525
|
+
this._setState('paused', !state);
|
|
1526
|
+
this._setState('ended', !!ended);
|
|
1527
|
+
return this;
|
|
1528
|
+
},
|
|
1529
|
+
/**
|
|
1530
|
+
* Executes a command onto the media
|
|
1531
|
+
* @param {String} command - The name of the command to execute
|
|
1532
|
+
* @param {*} args - additional arguments
|
|
1533
|
+
* @returns {*}
|
|
1534
|
+
* @private
|
|
1535
|
+
*/
|
|
1536
|
+
execute(command) {
|
|
1537
|
+
if (this.player && 'function' === typeof this.player[command]) {
|
|
1538
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
1539
|
+
args[_key2 - 1] = arguments[_key2];
|
|
1540
|
+
}
|
|
1541
|
+
return this.player[command](...args);
|
|
1825
1542
|
}
|
|
1826
|
-
|
|
1827
|
-
return (_this$player = this.player)[command].apply(_this$player, args);
|
|
1828
1543
|
}
|
|
1829
|
-
}
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
}
|
|
1833
|
-
/**
|
|
1834
|
-
* Tells if the browser can play audio and video
|
|
1835
|
-
* @param {String} [type] The type of media (audio or video)
|
|
1836
|
-
* @param {String} [mime] A media MIME type to check
|
|
1837
|
-
* @type {Boolean}
|
|
1838
|
-
*/
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
mediaplayerFactory.canPlay = function canPlay(type, mime) {
|
|
1842
|
-
return support.canPlay(type, mime);
|
|
1843
|
-
};
|
|
1844
|
-
/**
|
|
1845
|
-
* Tells if the browser can play audio
|
|
1846
|
-
* @param {String} [mime] A media MIME type to check
|
|
1847
|
-
* @type {Boolean}
|
|
1848
|
-
*/
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
mediaplayerFactory.canPlayAudio = function canPlayAudio(mime) {
|
|
1852
|
-
return support.canPlayAudio(mime);
|
|
1853
|
-
};
|
|
1854
|
-
/**
|
|
1855
|
-
* Tells if the browser can play video
|
|
1856
|
-
* @param {String} [mime] A media MIME type to check
|
|
1857
|
-
* @type {Boolean}
|
|
1858
|
-
*/
|
|
1544
|
+
};
|
|
1545
|
+
return mediaplayer.init(config);
|
|
1546
|
+
}
|
|
1859
1547
|
|
|
1548
|
+
/**
|
|
1549
|
+
* Tells if the browser can play audio and video
|
|
1550
|
+
* @param {String} [type] The type of media (audio or video)
|
|
1551
|
+
* @param {String} [mime] A media MIME type to check
|
|
1552
|
+
* @type {Boolean}
|
|
1553
|
+
*/
|
|
1554
|
+
mediaplayerFactory.canPlay = function canPlay(type, mime) {
|
|
1555
|
+
return support.canPlay(type, mime);
|
|
1556
|
+
};
|
|
1860
1557
|
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1558
|
+
/**
|
|
1559
|
+
* Tells if the browser can play audio
|
|
1560
|
+
* @param {String} [mime] A media MIME type to check
|
|
1561
|
+
* @type {Boolean}
|
|
1562
|
+
*/
|
|
1563
|
+
mediaplayerFactory.canPlayAudio = function canPlayAudio(mime) {
|
|
1564
|
+
return support.canPlayAudio(mime);
|
|
1565
|
+
};
|
|
1868
1566
|
|
|
1567
|
+
/**
|
|
1568
|
+
* Tells if the browser can play video
|
|
1569
|
+
* @param {String} [mime] A media MIME type to check
|
|
1570
|
+
* @type {Boolean}
|
|
1571
|
+
*/
|
|
1572
|
+
mediaplayerFactory.canPlayVideo = function canPlayVideo(mime) {
|
|
1573
|
+
return support.canPlayVideo(mime);
|
|
1574
|
+
};
|
|
1869
1575
|
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1576
|
+
/**
|
|
1577
|
+
* Checks if the browser allows to control the media playback
|
|
1578
|
+
* @returns {Boolean}
|
|
1579
|
+
*/
|
|
1580
|
+
mediaplayerFactory.canControl = function canControl() {
|
|
1581
|
+
return support.canControl();
|
|
1582
|
+
};
|
|
1873
1583
|
|
|
1874
|
-
|
|
1584
|
+
return mediaplayerFactory;
|
|
1875
1585
|
|
|
1876
1586
|
});
|