|
73 | 73 | var getInputValue = function(el) { |
74 | 74 | if (el.type === 'url' || el.type === 'text' || el.nodeName.toLowerCase() === 'textarea') { |
75 | 75 | return encodeURIComponent(el.value); |
| 76 | + } else if (el.type === 'select-one') { |
| 77 | + return el.options[el.selectedIndex].value; |
76 | 78 | } else if (el.type === 'checkbox') { |
77 | 79 | return el.checked; |
78 | 80 | } |
|
84 | 86 | var setInputValue = function(el, value) { |
85 | 87 | if (el.type === 'url' || el.type === 'text' || el.nodeName.toLowerCase() === 'textarea') { |
86 | 88 | el.value = decodeURIComponent(value); |
| 89 | + } else if (el.type === 'select-one') { |
| 90 | + for (let i = 0; i < el.options.length; i++) { |
| 91 | + if (el.options[i].value === value) { |
| 92 | + el.options[i].selected = true; |
| 93 | + } |
| 94 | + } |
87 | 95 | } else { |
88 | 96 | // get the `value` into a Boolean. |
89 | 97 | el.checked = JSON.parse(value); |
|
217 | 225 | representationsEl.selectedIndex = selectedIndex; |
218 | 226 | }; |
219 | 227 |
|
220 | | - ['debug', 'autoplay', 'muted', 'minified', 'sync-workers', 'liveui', 'partial', 'url', 'type', 'keysystems', 'buffer-water', 'override-native'].forEach(function(name) { |
| 228 | + ['debug', 'autoplay', 'muted', 'minified', 'sync-workers', 'liveui', 'partial', 'url', 'type', 'keysystems', 'buffer-water', 'override-native', 'preload'].forEach(function(name) { |
221 | 229 | stateEls[name] = document.getElementById(name); |
222 | 230 | }); |
223 | 231 |
|
|
251 | 259 | stateEls.minified.dispatchEvent(newEvent('change')); |
252 | 260 | }); |
253 | 261 |
|
| 262 | + stateEls.preload.addEventListener('change', function(event) { |
| 263 | + saveState(); |
| 264 | + // reload the player and scripts |
| 265 | + stateEls.minified.dispatchEvent(newEvent('change')); |
| 266 | + }); |
| 267 | + |
254 | 268 | stateEls.debug.addEventListener('change', function(event) { |
255 | 269 | saveState(); |
256 | 270 | window.videojs.log.level(event.target.checked ? 'debug' : 'info'); |
|
315 | 329 | var videoEl = document.createElement('video-js'); |
316 | 330 |
|
317 | 331 | videoEl.setAttribute('controls', ''); |
| 332 | + videoEl.setAttribute('preload', stateEls.preload.options[stateEls.preload.selectedIndex].value || 'auto'); |
318 | 333 | videoEl.className = 'vjs-default-skin'; |
319 | 334 | fixture.appendChild(videoEl); |
320 | 335 |
|
|
0 commit comments