Changeset 1288
- Timestamp:
- 09/19/10 19:05:39 (3 years ago)
- Location:
- trunk/html5
- Files:
-
- 3 edited
-
bin-debug/jwplayer.html5.js (modified) (28 diffs)
-
src/html5/jwplayer.html5.display.js (modified) (4 diffs)
-
src/html5/jwplayer.html5.mediavideo.js (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/html5/bin-debug/jwplayer.html5.js
r1285 r1288 265 265 if (_model.plugins.object[pluginName].getDisplayElement !== undefined) { 266 266 if (_hasPosition(_model.plugins.config[pluginName].position)) { 267 if (_model.plugins.object[pluginName].getDisplayElement().parent Element=== null) {267 if (_model.plugins.object[pluginName].getDisplayElement().parentNode === null) { 268 268 _wrapper.appendChild(_model.plugins.object[pluginName].getDisplayElement()); 269 269 } … … 277 277 278 278 function _overlayComponentResizer(pluginName, zIndex) { 279 if (_model.plugins.object[pluginName].getDisplayElement().parent Element=== null) {279 if (_model.plugins.object[pluginName].getDisplayElement().parentNode === null) { 280 280 _box.appendChild(_model.plugins.object[pluginName].getDisplayElement()); 281 281 } … … 537 537 var _elements = {}; 538 538 var _ready = false; 539 var _fadeOutTimeout;540 539 541 540 … … 595 594 596 595 function _fadeOut() { 597 _wrapper.style.opacity = 1; 598 if (_fadeOutTimeout !== undefined) { 599 clearTimeout(_fadeOutTimeout); 600 } 601 _fadeOutTimeout = setTimeout(function() { 602 jwplayer.html5.utils.fadeTo(_wrapper, 0, 0.1, 1); 603 _fadeOutTimeout = undefined; 604 }, 2000); 596 jwplayer.html5.utils.cancelAnimation(_wrapper); 597 jwplayer.html5.utils.fadeTo(_wrapper, 0, 0.1, 1, 2); 605 598 } 606 599 … … 1366 1359 * @version 1.0 1367 1360 */ 1368 (function(jwplayer) { 1361 (function(jwplayer) { 1369 1362 _css = jwplayer.html5.utils.css; 1370 1363 … … 1391 1384 var _bufferInterval = _api.skin.getComponentSettings("display").bufferinterval === undefined ? 100 : parseInt(_api.skin.getComponentSettings("display").bufferinterval, 10); 1392 1385 var _elements = { 1393 display: { 1394 style: { 1395 cursor: "pointer" 1396 }, 1397 click: _displayClickHandler 1386 display: { 1387 style: { 1388 cursor: "pointer" 1398 1389 }, 1399 display_icon: { 1400 style: { 1401 cursor: "pointer", 1402 position: "absolute", 1403 top: ((_api.skin.getSkinElement("display", "background").height - _api.skin.getSkinElement("display", "playIcon").height) / 2), 1404 left: ((_api.skin.getSkinElement("display", "background").width - _api.skin.getSkinElement("display", "playIcon").width) / 2), 1405 border: 0, 1406 margin: 0, 1407 padding: 0 1408 } 1409 }, 1410 display_iconBackground: { 1411 style: { 1412 cursor: "pointer", 1413 position: "absolute", 1414 top: ((_height - _api.skin.getSkinElement("display", "background").height) / 2), 1415 left: ((_width - _api.skin.getSkinElement("display", "background").width) / 2), 1416 border: 0, 1417 backgroundImage: (["url(", _api.skin.getSkinElement("display", "background").src, ")"]).join(""), 1418 width: _api.skin.getSkinElement("display", "background").width, 1419 height: _api.skin.getSkinElement("display", "background").height, 1420 margin: 0, 1421 padding: 0 1422 } 1423 }, 1424 display_image: { 1425 style: { 1426 display: "block", 1427 width: _width, 1428 height: _height, 1429 position: "absolute", 1430 cursor: "pointer", 1431 left: 0, 1432 top: 0, 1433 margin: 0, 1434 padding: 0, 1435 textDecoration: "none" 1436 } 1437 } 1438 }; 1390 click: _displayClickHandler 1391 }, 1392 display_icon: { 1393 style: { 1394 cursor: "pointer", 1395 position: "absolute", 1396 top: ((_api.skin.getSkinElement("display", "background").height - _api.skin.getSkinElement("display", "playIcon").height) / 2), 1397 left: ((_api.skin.getSkinElement("display", "background").width - _api.skin.getSkinElement("display", "playIcon").width) / 2), 1398 border: 0, 1399 margin: 0, 1400 padding: 0 1401 } 1402 }, 1403 display_iconBackground: { 1404 style: { 1405 cursor: "pointer", 1406 position: "absolute", 1407 top: ((_height - _api.skin.getSkinElement("display", "background").height) / 2), 1408 left: ((_width - _api.skin.getSkinElement("display", "background").width) / 2), 1409 border: 0, 1410 backgroundImage: (["url(", _api.skin.getSkinElement("display", "background").src, ")"]).join(""), 1411 width: _api.skin.getSkinElement("display", "background").width, 1412 height: _api.skin.getSkinElement("display", "background").height, 1413 margin: 0, 1414 padding: 0 1415 } 1416 }, 1417 display_image: { 1418 style: { 1419 display: "block", 1420 width: _width, 1421 height: _height, 1422 position: "absolute", 1423 cursor: "pointer", 1424 left: 0, 1425 top: 0, 1426 margin: 0, 1427 padding: 0, 1428 textDecoration: "none" 1429 } 1430 }, 1431 display_text: { 1432 style: { 1433 position: "relative", 1434 top: "50%", 1435 opacity: 0.8, 1436 backgroundColor: "black", 1437 color: "white", 1438 display: "none", 1439 textAlign: "center", 1440 fontFamily: "Arial,sans-serif", 1441 padding: "0 5px", 1442 fontSize: 14 1443 } 1444 } 1445 }; 1439 1446 _api.jwAddEventListener(jwplayer.api.events.JWPLAYER_PLAYER_STATE, _stateHandler); 1440 1447 _api.jwAddEventListener(jwplayer.api.events.JWPLAYER_MEDIA_MUTE, _stateHandler); 1441 1448 _api.jwAddEventListener(jwplayer.api.events.JWPLAYER_PLAYLIST_ITEM, _stateHandler); 1442 _api.jwAddEventListener(jwplayer.api.events.JWPLAYER_MEDIA_ERROR, function(obj) { 1443 }); 1449 _api.jwAddEventListener(jwplayer.api.events.JWPLAYER_ERROR, _errorHandler); 1444 1450 _setupDisplay(); 1445 1446 1451 1447 1452 function _setupDisplay() { 1448 1453 _display.display = createElement("div", "display"); 1454 _display.display_text = createElement("div", "display_text"); 1455 _display.display.appendChild(_display.display_text); 1449 1456 _display.display_image = createElement("div", "display_image"); 1450 1457 _display.display_icon = createElement("div", "display_icon"); … … 1484 1491 _css(_element, _elements[element].style); 1485 1492 return _element; 1486 }1487 1488 function _getStyle(element) {1489 var result = '';1490 for (var style in _elements[element].style) {1491 result += style + ":" + _elements[element].style[style] + ";";1492 }1493 if (result === '') {1494 return ' ';1495 }1496 return ' style="' + result + '" ';1497 1493 } 1498 1494 … … 1551 1547 } 1552 1548 1553 function _stateHandler(obj) { 1549 function _errorHandler(evt){ 1550 _hideDisplayIcon(); 1551 _display.display_text.innerHTML = "<p>"+evt.error+"</p>"; 1552 _show(_display.display_text); 1553 _display.display_text.style.top = ((_height - _display.display_text.getBoundingClientRect().height) / 2) + "px"; 1554 } 1555 1556 function _stateHandler(evt) { 1557 _hide(_display.display_text); 1554 1558 if (_rotationInterval !== undefined) { 1555 1559 clearInterval(_rotationInterval); … … 1796 1800 var _api = api; 1797 1801 var _settings = jwplayer.utils.extend({}, _defaults, config); 1798 var _interval;1799 1802 1800 1803 var _logo = document.createElement("img"); 1801 1802 1804 _logo.id = _api.id + "_jwplayer_logo"; 1805 _css(_logo, _getStyle()); 1803 1806 1804 1807 _logo.onload = function(evt) { 1805 1808 _settings.width = _logo.width; 1806 1809 _settings.height = _logo.height; 1807 1808 _css(_logo, _getStyle()); 1809 1810 1810 1811 _api.jwAddEventListener(jwplayer.api.events.JWPLAYER_PLAYER_STATE, _stateHandler); 1811 1812 }; … … 1828 1829 height: _settings.height, 1829 1830 textDecoration: "none", 1830 position: "absolute" 1831 position: "absolute", 1832 display: "none" 1831 1833 }; 1832 1834 var positions = _settings.position.toLowerCase().split("-"); … … 1854 1856 case jwplayer.api.events.state.BUFFERING: 1855 1857 _logo.style.opacity = _settings.out; 1856 setTimeout(jwplayer.html5.utils.fadeTo(_logo, 0, 0.1, _logo.style.opacity), _settings.timeout * 1000);1858 jwplayer.html5.utils.fadeTo(_logo, 0, 0.1, parseFloat(_logo.style.opacity), _settings.timeout); 1857 1859 break; 1858 1860 case jwplayer.api.events.state.PAUSED: … … 1860 1862 case jwplayer.api.events.state.IDLE: 1861 1863 break; 1864 case jwplayer.api.events.state.PLAYING: 1865 break; 1862 1866 default: 1863 setTimeout(jwplayer.html5.utils.fadeTo(_logo, 0, 0.1, _logo.style.opacity), _settings.timeout * 1000);1867 jwplayer.html5.utils.fadeTo(_logo, 0, 0.1, parseFloat(_logo.style.opacity), _settings.timeout); 1864 1868 break; 1865 1869 } … … 1928 1932 var _start = false; 1929 1933 var hasChrome = false; 1934 var _currentItem; 1935 var _sourceError = 0; 1930 1936 1931 1937 function _getState() { … … 1953 1959 _model.state = newstate; 1954 1960 _state = newstate; 1961 var _sendComplete = false; 1955 1962 if (newstate == jwplayer.api.events.state.IDLE) { 1956 1963 _clearInterval(); 1957 _eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_COMPLETE); 1964 if (_model.position >= _model.duration && (_model.position || _model.duration)) { 1965 _sendComplete = true; 1966 } 1958 1967 1959 1968 if (_container.style.display != 'none') { … … 1966 1975 newstate: newstate 1967 1976 }); 1977 if (_sendComplete) { 1978 _eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_COMPLETE); 1979 } 1968 1980 } 1969 1981 _stopped = false; … … 1977 1989 duration: event.target.duration 1978 1990 }; 1979 if (_model.duration === 0 ) {1980 _model.duration = event.target.duration;1991 if (_model.duration === 0 || isNaN(_model.duration)) { 1992 _model.duration = Math.round(event.target.duration * 10) / 10; 1981 1993 } 1982 1994 _model.playlist[_model.item] = jwplayer.utils.extend(_model.playlist[_model.item], meta); … … 1993 2005 1994 2006 if (event !== undefined && event.target !== undefined) { 1995 if (_model.duration === 0) { 1996 _model.duration = event.target.duration; 1997 } 1998 2007 if (_model.duration === 0 || isNaN(_model.duration)) { 2008 _model.duration = Math.round(event.target.duration * 10) / 10 2009 } 2010 if (!_start && _container.readyState > 0) { 2011 _setState(jwplayer.api.events.state.PLAYING); 2012 } 1999 2013 if (_state == jwplayer.api.events.state.PLAYING) { 2000 2014 if (!_start && _container.readyState > 0) { … … 2028 2042 } 2029 2043 2030 if (_bufferFull === false ) {2044 if (_bufferFull === false && _state == jwplayer.api.events.state.BUFFERING) { 2031 2045 _bufferFull = true; 2032 2046 _eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_BUFFER_FULL); … … 2063 2077 2064 2078 function _errorHandler(event) { 2065 _eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_ERROR, event.target); 2079 _stop(); 2080 var message = "There was an error: "; 2081 if (event.target.error || event.target.parentNode.error) { 2082 var element = event.target.error === undefined ? event.target.parentNode.error : event.target.error; 2083 switch (element.code) { 2084 case element.MEDIA_ERR_ABORTED: 2085 message = "You aborted the video playback: "; 2086 break; 2087 case element.MEDIA_ERR_NETWORK: 2088 message = "A network error caused the video download to fail part-way: "; 2089 break; 2090 case element.MEDIA_ERR_DECODE: 2091 message = "The video playback was aborted due to a corruption problem or because the video used features your browser did not support: "; 2092 break; 2093 case element.MEDIA_ERR_SRC_NOT_SUPPORTED: 2094 message = "The video could not be loaded, either because the server or network failed or because the format is not supported: "; 2095 break; 2096 default: 2097 message = "An unknown error occurred: "; 2098 break; 2099 } 2100 } else if (event.target.tagName.toLowerCase() == "source") { 2101 _sourceError++; 2102 if (_sourceError != _currentItem.levels.length) { 2103 return; 2104 } 2105 message = "The video could not be loaded, either because the server or network failed or because the format is not supported: "; 2106 } 2107 2108 message += joinFiles(); 2109 _eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_ERROR, { 2110 error: message 2111 }); 2112 return; 2113 } 2114 2115 function joinFiles() { 2116 var result = ""; 2117 for (var sourceIndex in _currentItem.levels) { 2118 var sourceModel = _currentItem.levels[sourceIndex]; 2119 var source = _container.ownerDocument.createElement("source"); 2120 result += jwplayer.html5.utils.getAbsolutePath(sourceModel.file); 2121 if (sourceIndex < (_currentItem.levels.length - 1)) { 2122 result += ", "; 2123 } 2124 } 2125 return result; 2066 2126 } 2067 2127 … … 2076 2136 } 2077 2137 _container.play(); 2078 _setState(jwplayer.api.events.state.PLAYING);2079 2138 _startInterval(); 2080 2139 } … … 2097 2156 2098 2157 /** Stop playback and loading of the video. **/ 2099 this.stop = function() {2158 function _stop() { 2100 2159 _stopped = true; 2101 2160 _container.pause(); … … 2103 2162 _model.position = 0; 2104 2163 _setState(jwplayer.api.events.state.IDLE); 2105 }; 2106 2164 } 2165 2166 this.stop = _stop; 2107 2167 2108 2168 /** Change the video's volume level. **/ … … 2155 2215 this.load = function(playlistItem) { 2156 2216 _embed(playlistItem); 2157 2217 _eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_LOADED); 2158 2218 _bufferFull = false; 2159 2219 _bufferingComplete = false; 2160 2220 _start = false; 2221 _setState(jwplayer.api.events.state.BUFFERING); 2222 2161 2223 setTimeout(function() { 2162 _eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_LOADED);2163 _setState(jwplayer.api.events.state.BUFFERING);2164 2224 _positionHandler(); 2165 2225 }, 25); … … 2167 2227 2168 2228 _embed = function(playlistItem) { 2229 _currentItem = playlistItem; 2169 2230 var vid = document.createElement("video"); 2170 2231 vid.preload = "none"; 2171 2232 vid.loop = _model.config.repeat; 2233 _sourceError = 0; 2172 2234 for (var sourceIndex in playlistItem.levels) { 2173 2235 var sourceModel = playlistItem.levels[sourceIndex]; … … 2681 2743 }; 2682 2744 2683 jwplayer.html5.utils.fadeTo = function(domelement, endAlpha, time, startAlpha, startTime) { 2745 jwplayer.html5.utils.cancelAnimation = function(domelement) { 2746 delete _animations[domelement]; 2747 }; 2748 2749 jwplayer.html5.utils.fadeTo = function(domelement, endAlpha, time, startAlpha, delay, startTime) { 2684 2750 // Interrupting 2685 2751 if (_animations[domelement] != startTime && startTime !== undefined) { … … 2687 2753 } 2688 2754 var currentTime = new Date().getTime(); 2755 if (startTime > currentTime) { 2756 setTimeout(function() { 2757 jwplayer.html5.utils.fadeTo(domelement, endAlpha, time, startAlpha, 0, startTime); 2758 }, startTime - currentTime); 2759 } 2760 domelement.style.display = "block"; 2689 2761 if (startAlpha === undefined) { 2690 2762 startAlpha = domelement.style.opacity === "" ? 1 : domelement.style.opacity; 2691 2763 } 2692 if (typeof startAlpha == "string") {2693 startAlpha = parseInt(startAlpha, 10);2694 }2695 2764 if (domelement.style.opacity == endAlpha && domelement.style.opacity !== "" && startTime !== undefined) { 2765 if (endAlpha === 0) { 2766 domelement.style.display = "none"; 2767 } 2696 2768 return; 2697 2769 } … … 2699 2771 startTime = currentTime; 2700 2772 _animations[domelement] = startTime; 2773 } 2774 if (delay === undefined) { 2775 delay = 0; 2701 2776 } 2702 2777 var percentTime = (currentTime - startTime) / (time * 1000); … … 2710 2785 } 2711 2786 domelement.style.opacity = alpha; 2787 if (delay > 0) { 2788 _animations[domelement] = startTime + delay * 1000; 2789 jwplayer.html5.utils.fadeTo(domelement, endAlpha, time, startAlpha, 0, _animations[domelement]); 2790 return; 2791 } 2712 2792 setTimeout(function() { 2713 jwplayer.html5.utils.fadeTo(domelement, endAlpha, time, startAlpha, startTime);2793 jwplayer.html5.utils.fadeTo(domelement, endAlpha, time, startAlpha, 0, startTime); 2714 2794 }, 10); 2715 }; 2716 2795 }; 2717 2796 })(jwplayer); 2718 2797 /** -
trunk/html5/src/html5/jwplayer.html5.display.js
r1278 r1288 5 5 * @version 1.0 6 6 */ 7 (function(jwplayer) { 7 (function(jwplayer) { 8 8 _css = jwplayer.html5.utils.css; 9 9 … … 30 30 var _bufferInterval = _api.skin.getComponentSettings("display").bufferinterval === undefined ? 100 : parseInt(_api.skin.getComponentSettings("display").bufferinterval, 10); 31 31 var _elements = { 32 display: { 33 style: { 34 cursor: "pointer" 35 }, 36 click: _displayClickHandler 32 display: { 33 style: { 34 cursor: "pointer" 37 35 }, 38 display_icon: { 39 style: { 40 cursor: "pointer", 41 position: "absolute", 42 top: ((_api.skin.getSkinElement("display", "background").height - _api.skin.getSkinElement("display", "playIcon").height) / 2), 43 left: ((_api.skin.getSkinElement("display", "background").width - _api.skin.getSkinElement("display", "playIcon").width) / 2), 44 border: 0, 45 margin: 0, 46 padding: 0 47 } 48 }, 49 display_iconBackground: { 50 style: { 51 cursor: "pointer", 52 position: "absolute", 53 top: ((_height - _api.skin.getSkinElement("display", "background").height) / 2), 54 left: ((_width - _api.skin.getSkinElement("display", "background").width) / 2), 55 border: 0, 56 backgroundImage: (["url(", _api.skin.getSkinElement("display", "background").src, ")"]).join(""), 57 width: _api.skin.getSkinElement("display", "background").width, 58 height: _api.skin.getSkinElement("display", "background").height, 59 margin: 0, 60 padding: 0 61 } 62 }, 63 display_image: { 64 style: { 65 display: "block", 66 width: _width, 67 height: _height, 68 position: "absolute", 69 cursor: "pointer", 70 left: 0, 71 top: 0, 72 margin: 0, 73 padding: 0, 74 textDecoration: "none" 75 } 76 } 77 }; 36 click: _displayClickHandler 37 }, 38 display_icon: { 39 style: { 40 cursor: "pointer", 41 position: "absolute", 42 top: ((_api.skin.getSkinElement("display", "background").height - _api.skin.getSkinElement("display", "playIcon").height) / 2), 43 left: ((_api.skin.getSkinElement("display", "background").width - _api.skin.getSkinElement("display", "playIcon").width) / 2), 44 border: 0, 45 margin: 0, 46 padding: 0 47 } 48 }, 49 display_iconBackground: { 50 style: { 51 cursor: "pointer", 52 position: "absolute", 53 top: ((_height - _api.skin.getSkinElement("display", "background").height) / 2), 54 left: ((_width - _api.skin.getSkinElement("display", "background").width) / 2), 55 border: 0, 56 backgroundImage: (["url(", _api.skin.getSkinElement("display", "background").src, ")"]).join(""), 57 width: _api.skin.getSkinElement("display", "background").width, 58 height: _api.skin.getSkinElement("display", "background").height, 59 margin: 0, 60 padding: 0 61 } 62 }, 63 display_image: { 64 style: { 65 display: "block", 66 width: _width, 67 height: _height, 68 position: "absolute", 69 cursor: "pointer", 70 left: 0, 71 top: 0, 72 margin: 0, 73 padding: 0, 74 textDecoration: "none" 75 } 76 }, 77 display_text: { 78 style: { 79 position: "relative", 80 top: "50%", 81 opacity: 0.8, 82 backgroundColor: "black", 83 color: "white", 84 display: "none", 85 textAlign: "center", 86 fontFamily: "Arial,sans-serif", 87 padding: "0 5px", 88 fontSize: 14 89 } 90 } 91 }; 78 92 _api.jwAddEventListener(jwplayer.api.events.JWPLAYER_PLAYER_STATE, _stateHandler); 79 93 _api.jwAddEventListener(jwplayer.api.events.JWPLAYER_MEDIA_MUTE, _stateHandler); 80 94 _api.jwAddEventListener(jwplayer.api.events.JWPLAYER_PLAYLIST_ITEM, _stateHandler); 81 _api.jwAddEventListener(jwplayer.api.events.JWPLAYER_MEDIA_ERROR, function(obj) { 82 }); 95 _api.jwAddEventListener(jwplayer.api.events.JWPLAYER_ERROR, _errorHandler); 83 96 _setupDisplay(); 84 85 97 86 98 function _setupDisplay() { 87 99 _display.display = createElement("div", "display"); 100 _display.display_text = createElement("div", "display_text"); 101 _display.display.appendChild(_display.display_text); 88 102 _display.display_image = createElement("div", "display_image"); 89 103 _display.display_icon = createElement("div", "display_icon"); … … 123 137 _css(_element, _elements[element].style); 124 138 return _element; 125 }126 127 function _getStyle(element) {128 var result = '';129 for (var style in _elements[element].style) {130 result += style + ":" + _elements[element].style[style] + ";";131 }132 if (result === '') {133 return ' ';134 }135 return ' style="' + result + '" ';136 139 } 137 140 … … 190 193 } 191 194 192 function _stateHandler(obj) { 195 function _errorHandler(evt){ 196 _hideDisplayIcon(); 197 _display.display_text.innerHTML = "<p>"+evt.error+"</p>"; 198 _show(_display.display_text); 199 _display.display_text.style.top = ((_height - _display.display_text.getBoundingClientRect().height) / 2) + "px"; 200 } 201 202 function _stateHandler(evt) { 203 _hide(_display.display_text); 193 204 if (_rotationInterval !== undefined) { 194 205 clearInterval(_rotationInterval); -
trunk/html5/src/html5/jwplayer.html5.mediavideo.js
r1287 r1288 58 58 var _start = false; 59 59 var hasChrome = false; 60 var _currentItem; 61 var _sourceError = 0; 60 62 61 63 function _getState() { … … 83 85 _model.state = newstate; 84 86 _state = newstate; 87 var _sendComplete = false; 85 88 if (newstate == jwplayer.api.events.state.IDLE) { 86 89 _clearInterval(); 87 _eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_COMPLETE); 90 if (_model.position >= _model.duration && (_model.position || _model.duration)) { 91 _sendComplete = true; 92 } 88 93 89 94 if (_container.style.display != 'none') { … … 96 101 newstate: newstate 97 102 }); 103 if (_sendComplete) { 104 _eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_COMPLETE); 105 } 98 106 } 99 107 _stopped = false; … … 107 115 duration: event.target.duration 108 116 }; 109 if (_model.duration === 0 ) {110 _model.duration = event.target.duration;117 if (_model.duration === 0 || isNaN(_model.duration)) { 118 _model.duration = Math.round(event.target.duration * 10) / 10; 111 119 } 112 120 _model.playlist[_model.item] = jwplayer.utils.extend(_model.playlist[_model.item], meta); … … 123 131 124 132 if (event !== undefined && event.target !== undefined) { 125 if (_model.duration === 0 ) {126 _model.duration = event.target.duration;133 if (_model.duration === 0 || isNaN(_model.duration)) { 134 _model.duration = Math.round(event.target.duration * 10) / 10 127 135 } 128 136 if (!_start && _container.readyState > 0) { … … 160 168 } 161 169 162 if (_bufferFull === false ) {170 if (_bufferFull === false && _state == jwplayer.api.events.state.BUFFERING) { 163 171 _bufferFull = true; 164 172 _eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_BUFFER_FULL); … … 195 203 196 204 function _errorHandler(event) { 197 _eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_ERROR, event.target); 205 _stop(); 206 var message = "There was an error: "; 207 if (event.target.error || event.target.parentNode.error) { 208 var element = event.target.error === undefined ? event.target.parentNode.error : event.target.error; 209 switch (element.code) { 210 case element.MEDIA_ERR_ABORTED: 211 message = "You aborted the video playback: "; 212 break; 213 case element.MEDIA_ERR_NETWORK: 214 message = "A network error caused the video download to fail part-way: "; 215 break; 216 case element.MEDIA_ERR_DECODE: 217 message = "The video playback was aborted due to a corruption problem or because the video used features your browser did not support: "; 218 break; 219 case element.MEDIA_ERR_SRC_NOT_SUPPORTED: 220 message = "The video could not be loaded, either because the server or network failed or because the format is not supported: "; 221 break; 222 default: 223 message = "An unknown error occurred: "; 224 break; 225 } 226 } else if (event.target.tagName.toLowerCase() == "source") { 227 _sourceError++; 228 if (_sourceError != _currentItem.levels.length) { 229 return; 230 } 231 message = "The video could not be loaded, either because the server or network failed or because the format is not supported: "; 232 } 233 234 message += joinFiles(); 235 _eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_ERROR, { 236 error: message 237 }); 238 return; 239 } 240 241 function joinFiles() { 242 var result = ""; 243 for (var sourceIndex in _currentItem.levels) { 244 var sourceModel = _currentItem.levels[sourceIndex]; 245 var source = _container.ownerDocument.createElement("source"); 246 result += jwplayer.html5.utils.getAbsolutePath(sourceModel.file); 247 if (sourceIndex < (_currentItem.levels.length - 1)) { 248 result += ", "; 249 } 250 } 251 return result; 198 252 } 199 253 … … 228 282 229 283 /** Stop playback and loading of the video. **/ 230 this.stop = function() {284 function _stop() { 231 285 _stopped = true; 232 286 _container.pause(); … … 234 288 _model.position = 0; 235 289 _setState(jwplayer.api.events.state.IDLE); 236 }; 237 290 } 291 292 this.stop = _stop; 238 293 239 294 /** Change the video's volume level. **/ … … 286 341 this.load = function(playlistItem) { 287 342 _embed(playlistItem); 288 343 _eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_LOADED); 289 344 _bufferFull = false; 290 345 _bufferingComplete = false; 291 346 _start = false; 347 _setState(jwplayer.api.events.state.BUFFERING); 348 292 349 setTimeout(function() { 293 _eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_LOADED);294 _setState(jwplayer.api.events.state.BUFFERING);295 350 _positionHandler(); 296 351 }, 25); … … 298 353 299 354 _embed = function(playlistItem) { 355 _currentItem = playlistItem; 300 356 var vid = document.createElement("video"); 301 357 vid.preload = "none"; 302 358 vid.loop = _model.config.repeat; 359 _sourceError = 0; 303 360 for (var sourceIndex in playlistItem.levels) { 304 361 var sourceModel = playlistItem.levels[sourceIndex];
Note: See TracChangeset
for help on using the changeset viewer.
