ovenplayer 0.10.49 → 0.10.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/ovenplayer.js +1 -1
  2. package/dist/ovenplayer.js.map +1 -1
  3. package/package.json +49 -49
  4. package/src/js/api/Configurator.js +1 -1
  5. package/src/js/api/ads/vast/Ad.js +237 -237
  6. package/src/js/api/caption/Loader.js +1 -1
  7. package/src/js/api/caption/Manager.js +1 -1
  8. package/src/js/api/caption/parser/VttParser.js +1541 -1542
  9. package/src/js/api/playlist/Manager.js +229 -229
  10. package/src/js/api/provider/html5/providers/Dash.js +286 -286
  11. package/src/js/api/provider/html5/providers/Hls.js +110 -2
  12. package/src/js/api/provider/html5/providers/WebRTC.js +2 -1
  13. package/src/js/api/provider/html5/providers/WebRTCLoader.js +35 -2
  14. package/src/js/api/provider/utils.js +69 -69
  15. package/src/js/ovenplayer.sdk.js +143 -143
  16. package/src/js/utils/likeA$.js +241 -242
  17. package/src/js/utils/resize-sensor.js +145 -168
  18. package/src/js/utils/strings.js +104 -104
  19. package/src/js/view/components/controls/settingPanel/audioTrackPanel.js +57 -57
  20. package/src/js/view/components/controls/settingPanel/main.js +1 -1
  21. package/src/js/view/components/controls/settingPanel/mainTemplate.js +29 -29
  22. package/src/js/view/components/controls/settingPanel/qualityPanel.js +68 -68
  23. package/src/js/view/components/controls/settingPanel/subtitleTrackPanel.js +56 -56
  24. package/src/js/view/components/helpers/captionViewer.js +97 -15
  25. package/src/js/view/components/helpers/captionViewerTemplate.js +1 -2
  26. package/src/js/view/components/helpers/waterMark.js +69 -69
  27. package/src/js/view/engine/OvenTemplate.js +158 -158
  28. package/src/js/view/global/PanelManager.js +47 -47
  29. package/src/stylesheet/ovenplayer.less +52 -21
  30. package/src/js/utils/adapter.js +0 -4944
  31. package/src/js/utils/captions/vttCue.js +0 -308
  32. package/src/js/utils/captions/vttRegion.js +0 -136
  33. package/src/js/utils/polyfills/dom.js +0 -634
  34. package/src/js/utils/underscore.js +0 -6
@@ -1,229 +1,229 @@
1
- import _ from "utils/underscore";
2
- import {isRtmp, isWebRTC, isDash, isHls } from "utils/validator";
3
- import {extractExtension ,trim} from "../../utils/strings";
4
- import SupportChecker from "../SupportChecker";
5
- import {PLAYLIST_CHANGED} from "api/constants";
6
-
7
- /**
8
- * @brief This manages Playlist or Sources.
9
- * @param
10
- *
11
- * */
12
- const Manager = function(provider){
13
- const that = {};
14
- let currentPlaylistItem = [];
15
- let spec = {
16
- playlist : [],
17
- currentIndex : 0
18
- };
19
- let supportChecker = SupportChecker();
20
-
21
- OvenPlayerConsole.log("PlaylistManager loaded.");
22
-
23
- const makePrettySource = function(source_){
24
- if (!source_ || !source_.file && !(source_.host || source_.application || source_.stream)) {
25
- return;
26
- }
27
-
28
- let source = Object.assign({}, { 'default': false }, source_);
29
- source.file = trim('' + source.file);
30
-
31
- if(source.host && source.application && source.stream){
32
- source.file = source.host + "/" + source.application + "/stream/" + source.stream;
33
- delete source.host;
34
- delete source.application;
35
- delete source.stream;
36
- }
37
-
38
- const mimetypeRegEx = /^[^/]+\/(?:x-)?([^/]+)$/;
39
-
40
- if (mimetypeRegEx.test(source.type)) {
41
- // if type is given as a mimetype
42
- source.mimeType = source.type;
43
- source.type = source.type.replace(mimetypeRegEx, '$1');
44
- }
45
-
46
- if(isRtmp(source.file)){
47
- source.type = 'rtmp';
48
- }else if(isWebRTC(source.file)){
49
- source.type = 'webrtc';
50
- }else if(isHls(source.file, source.type)){
51
- source.type = 'hls';
52
- }else if(isDash(source.file, source.type)){
53
- source.type = 'dash';
54
- }else if (!source.type) {
55
- source.type = extractExtension(source.file);
56
- }
57
-
58
- if (source.lowLatency) {
59
- source.lowLatency = source.lowLatency;
60
- }
61
-
62
- if (!source.type) {
63
- return;
64
- }
65
-
66
- // normalize types
67
- switch (source.type) {
68
- case 'm3u8':
69
- case 'vnd.apple.mpegurl':
70
- source.type = 'hls';
71
- break;
72
- case 'm4a':
73
- source.type = 'aac';
74
- break;
75
- case 'smil':
76
- source.type = 'rtmp';
77
- break;
78
- default:
79
- break;
80
- }
81
-
82
- Object.keys(source).forEach(function(key) {
83
- if (source[key] === '') {
84
- delete source[key];
85
- }
86
- });
87
-
88
- return source;
89
-
90
- }
91
-
92
- that.initPlaylist =(playlist, playerConfig) =>{
93
-
94
- OvenPlayerConsole.log("PlaylistManager setPlaylist() ", playlist);
95
- const prettiedPlaylist = (_.isArray(playlist) ? playlist : [playlist]).map(function(item){
96
- if(!_.isArray(item.tracks)) {
97
- delete item.tracks;
98
- }
99
- let playlistItem = Object.assign({},{
100
- sources: [],
101
- tracks: [],
102
- title : ""
103
- }, item );
104
-
105
- if((playlistItem.sources === Object(playlistItem.sources)) && !_.isArray(playlistItem.sources)) {
106
- playlistItem.sources = [makePrettySource(playlistItem.sources)];
107
- }
108
-
109
- if (!_.isArray(playlistItem.sources) || playlistItem.sources.length === 0) {
110
- playlistItem.sources = [makePrettySource(playlistItem)];
111
- }
112
-
113
- if(!_.isArray(playlistItem.sources) || playlistItem.sources.length === 0) {
114
- if (item.levels) {
115
- playlistItem.sources = item.levels;
116
- } else {
117
- playlistItem.sources = [makePrettySource(item)];
118
- }
119
- }
120
-
121
-
122
- for(let i = 0; i < playlistItem.sources.length; i++) {
123
- let source = playlistItem.sources[i];
124
- let prettySource = "";
125
- if (!source) {
126
- continue;
127
- }
128
-
129
- let defaultSource = source.default;
130
- if (defaultSource) {
131
- source.default = (defaultSource.toString() === 'true');
132
- } else {
133
- source.default = false;
134
- }
135
-
136
- // If the source doesn't have a label, number it
137
- if (!playlistItem.sources[i].label) {
138
- playlistItem.sources[i].label = playlistItem.sources[i].type+"-"+i.toString();
139
- }
140
-
141
- prettySource = makePrettySource(playlistItem.sources[i]);
142
- if(supportChecker.findProviderNameBySource(prettySource)){
143
- playlistItem.sources[i] = prettySource;
144
- }else{
145
- playlistItem.sources[i] = null;
146
- }
147
- }
148
-
149
- playlistItem.sources = playlistItem.sources.filter(source => !!source);
150
-
151
- if(!playlistItem.title && playlistItem.sources[0] && playlistItem.sources[0].label){
152
- playlistItem.title = playlistItem.sources[0].label;
153
- }
154
-
155
- function extractOnlyOneProtocol(sources){
156
- if(!!sources){
157
- let highPriorityType = playlistItem.sources[0].type;
158
-
159
- return _.filter(sources, {type : highPriorityType});
160
- }
161
- }
162
-
163
- if(playerConfig.isCurrentProtocolOnly()){
164
- playlistItem.sources = extractOnlyOneProtocol(playlistItem.sources);
165
- }
166
-
167
- if(!_.isArray(playlistItem.tracks)){
168
- playlistItem.tracks = [];
169
- }
170
- if(_.isArray(playlistItem.captions)){
171
- playlistItem.tracks = playlistItem.tracks.concat(playlistItem.captions);
172
- delete playlistItem.captions;
173
- }
174
-
175
- playlistItem.tracks = playlistItem.tracks.map(function(track){
176
- if(!track || !track.file){
177
- return false;
178
- }
179
- return Object.assign({}, {
180
- 'kind': 'captions',
181
- 'default': false
182
- }, track);
183
- }).filter(track => !!track);
184
- return playlistItem;
185
- }).filter(function(item){return item.sources && item.sources.length > 0;})||[];
186
- spec.playlist = prettiedPlaylist;
187
- return prettiedPlaylist;
188
- };
189
- that.getPlaylist = () => {
190
- OvenPlayerConsole.log("PlaylistManager getPlaylist() ", spec.playlist);
191
- return spec.playlist;
192
- };
193
- that.getCurrentPlayList = () => {
194
- if(spec.playlist[spec.currentIndex]){
195
- return spec.playlist[spec.currentIndex];
196
- }else{
197
- return [];
198
- }
199
- };
200
- that.getCurrentPlaylistIndex = () => {
201
- return spec.currentIndex;
202
- };
203
- that.setCurrentPlaylist = (index) => {
204
- if(spec.playlist[index]){
205
- spec.currentIndex = index;
206
- provider.trigger(PLAYLIST_CHANGED, spec.currentIndex);
207
- }
208
- return spec.currentIndex;
209
- };
210
- that.getCurrentSources = () => {
211
- if(spec.playlist[spec.currentIndex]){
212
- OvenPlayerConsole.log("PlaylistManager getCurrentSources() ", spec.playlist[spec.currentIndex].sources);
213
- return spec.playlist[spec.currentIndex].sources;
214
- }else{
215
- return null;
216
- }
217
-
218
- };
219
- that.getCurrentAdTag = () => {
220
- if(spec.playlist[spec.currentIndex]){
221
- return spec.playlist[spec.currentIndex].adTagUrl || "";
222
- }
223
- };
224
-
225
- return that;
226
- };
227
-
228
-
229
- export default Manager;
1
+ import _ from "underscore";
2
+ import {isRtmp, isWebRTC, isDash, isHls } from "utils/validator";
3
+ import {extractExtension ,trim} from "../../utils/strings";
4
+ import SupportChecker from "../SupportChecker";
5
+ import {PLAYLIST_CHANGED} from "api/constants";
6
+
7
+ /**
8
+ * @brief This manages Playlist or Sources.
9
+ * @param
10
+ *
11
+ * */
12
+ const Manager = function(provider){
13
+ const that = {};
14
+ let currentPlaylistItem = [];
15
+ let spec = {
16
+ playlist : [],
17
+ currentIndex : 0
18
+ };
19
+ let supportChecker = SupportChecker();
20
+
21
+ OvenPlayerConsole.log("PlaylistManager loaded.");
22
+
23
+ const makePrettySource = function(source_){
24
+ if (!source_ || !source_.file && !(source_.host || source_.application || source_.stream)) {
25
+ return;
26
+ }
27
+
28
+ let source = Object.assign({}, { 'default': false }, source_);
29
+ source.file = trim('' + source.file);
30
+
31
+ if(source.host && source.application && source.stream){
32
+ source.file = source.host + "/" + source.application + "/stream/" + source.stream;
33
+ delete source.host;
34
+ delete source.application;
35
+ delete source.stream;
36
+ }
37
+
38
+ const mimetypeRegEx = /^[^/]+\/(?:x-)?([^/]+)$/;
39
+
40
+ if (mimetypeRegEx.test(source.type)) {
41
+ // if type is given as a mimetype
42
+ source.mimeType = source.type;
43
+ source.type = source.type.replace(mimetypeRegEx, '$1');
44
+ }
45
+
46
+ if(isRtmp(source.file)){
47
+ source.type = 'rtmp';
48
+ }else if(isWebRTC(source.file)){
49
+ source.type = 'webrtc';
50
+ }else if(isHls(source.file, source.type)){
51
+ source.type = 'hls';
52
+ }else if(isDash(source.file, source.type)){
53
+ source.type = 'dash';
54
+ }else if (!source.type) {
55
+ source.type = extractExtension(source.file);
56
+ }
57
+
58
+ if (source.lowLatency) {
59
+ source.lowLatency = source.lowLatency;
60
+ }
61
+
62
+ if (!source.type) {
63
+ return;
64
+ }
65
+
66
+ // normalize types
67
+ switch (source.type) {
68
+ case 'm3u8':
69
+ case 'vnd.apple.mpegurl':
70
+ source.type = 'hls';
71
+ break;
72
+ case 'm4a':
73
+ source.type = 'aac';
74
+ break;
75
+ case 'smil':
76
+ source.type = 'rtmp';
77
+ break;
78
+ default:
79
+ break;
80
+ }
81
+
82
+ Object.keys(source).forEach(function(key) {
83
+ if (source[key] === '') {
84
+ delete source[key];
85
+ }
86
+ });
87
+
88
+ return source;
89
+
90
+ }
91
+
92
+ that.initPlaylist =(playlist, playerConfig) =>{
93
+
94
+ OvenPlayerConsole.log("PlaylistManager setPlaylist() ", playlist);
95
+ const prettiedPlaylist = (_.isArray(playlist) ? playlist : [playlist]).map(function(item){
96
+ if(!_.isArray(item.tracks)) {
97
+ delete item.tracks;
98
+ }
99
+ let playlistItem = Object.assign({},{
100
+ sources: [],
101
+ tracks: [],
102
+ title : ""
103
+ }, item );
104
+
105
+ if((playlistItem.sources === Object(playlistItem.sources)) && !_.isArray(playlistItem.sources)) {
106
+ playlistItem.sources = [makePrettySource(playlistItem.sources)];
107
+ }
108
+
109
+ if (!_.isArray(playlistItem.sources) || playlistItem.sources.length === 0) {
110
+ playlistItem.sources = [makePrettySource(playlistItem)];
111
+ }
112
+
113
+ if(!_.isArray(playlistItem.sources) || playlistItem.sources.length === 0) {
114
+ if (item.levels) {
115
+ playlistItem.sources = item.levels;
116
+ } else {
117
+ playlistItem.sources = [makePrettySource(item)];
118
+ }
119
+ }
120
+
121
+
122
+ for(let i = 0; i < playlistItem.sources.length; i++) {
123
+ let source = playlistItem.sources[i];
124
+ let prettySource = "";
125
+ if (!source) {
126
+ continue;
127
+ }
128
+
129
+ let defaultSource = source.default;
130
+ if (defaultSource) {
131
+ source.default = (defaultSource.toString() === 'true');
132
+ } else {
133
+ source.default = false;
134
+ }
135
+
136
+ // If the source doesn't have a label, number it
137
+ if (!playlistItem.sources[i].label) {
138
+ playlistItem.sources[i].label = playlistItem.sources[i].type+"-"+i.toString();
139
+ }
140
+
141
+ prettySource = makePrettySource(playlistItem.sources[i]);
142
+ if(supportChecker.findProviderNameBySource(prettySource)){
143
+ playlistItem.sources[i] = prettySource;
144
+ }else{
145
+ playlistItem.sources[i] = null;
146
+ }
147
+ }
148
+
149
+ playlistItem.sources = playlistItem.sources.filter(source => !!source);
150
+
151
+ if(!playlistItem.title && playlistItem.sources[0] && playlistItem.sources[0].label){
152
+ playlistItem.title = playlistItem.sources[0].label;
153
+ }
154
+
155
+ function extractOnlyOneProtocol(sources){
156
+ if(!!sources){
157
+ let highPriorityType = playlistItem.sources[0].type;
158
+
159
+ return _.filter(sources, {type : highPriorityType});
160
+ }
161
+ }
162
+
163
+ if(playerConfig.isCurrentProtocolOnly()){
164
+ playlistItem.sources = extractOnlyOneProtocol(playlistItem.sources);
165
+ }
166
+
167
+ if(!_.isArray(playlistItem.tracks)){
168
+ playlistItem.tracks = [];
169
+ }
170
+ if(_.isArray(playlistItem.captions)){
171
+ playlistItem.tracks = playlistItem.tracks.concat(playlistItem.captions);
172
+ delete playlistItem.captions;
173
+ }
174
+
175
+ playlistItem.tracks = playlistItem.tracks.map(function(track){
176
+ if(!track || !track.file){
177
+ return false;
178
+ }
179
+ return Object.assign({}, {
180
+ 'kind': 'captions',
181
+ 'default': false
182
+ }, track);
183
+ }).filter(track => !!track);
184
+ return playlistItem;
185
+ }).filter(function(item){return item.sources && item.sources.length > 0;})||[];
186
+ spec.playlist = prettiedPlaylist;
187
+ return prettiedPlaylist;
188
+ };
189
+ that.getPlaylist = () => {
190
+ OvenPlayerConsole.log("PlaylistManager getPlaylist() ", spec.playlist);
191
+ return spec.playlist;
192
+ };
193
+ that.getCurrentPlayList = () => {
194
+ if(spec.playlist[spec.currentIndex]){
195
+ return spec.playlist[spec.currentIndex];
196
+ }else{
197
+ return [];
198
+ }
199
+ };
200
+ that.getCurrentPlaylistIndex = () => {
201
+ return spec.currentIndex;
202
+ };
203
+ that.setCurrentPlaylist = (index) => {
204
+ if(spec.playlist[index]){
205
+ spec.currentIndex = index;
206
+ provider.trigger(PLAYLIST_CHANGED, spec.currentIndex);
207
+ }
208
+ return spec.currentIndex;
209
+ };
210
+ that.getCurrentSources = () => {
211
+ if(spec.playlist[spec.currentIndex]){
212
+ OvenPlayerConsole.log("PlaylistManager getCurrentSources() ", spec.playlist[spec.currentIndex].sources);
213
+ return spec.playlist[spec.currentIndex].sources;
214
+ }else{
215
+ return null;
216
+ }
217
+
218
+ };
219
+ that.getCurrentAdTag = () => {
220
+ if(spec.playlist[spec.currentIndex]){
221
+ return spec.playlist[spec.currentIndex].adTagUrl || "";
222
+ }
223
+ };
224
+
225
+ return that;
226
+ };
227
+
228
+
229
+ export default Manager;