Changeset 926
- Timestamp:
- 04/09/10 13:38:07 (3 years ago)
- Location:
- trunk/html5/src
- Files:
-
- 4 deleted
- 3 edited
- 1 moved
-
jquery.jwplayerCore.js (modified) (3 diffs)
-
jquery.jwplayerParse.js (moved) (moved from trunk/html5/src/jquery.jwplayerUtilsParsers.js) (1 diff)
-
jquery.jwplayerUtils.js (modified) (6 diffs)
-
jquery.jwplayerUtilsParsersDOMElementParser.js (deleted)
-
jquery.jwplayerUtilsParsersDOMMediaElementParser.js (deleted)
-
jquery.jwplayerUtilsParsersDOMSourceElementParser.js (deleted)
-
jquery.jwplayerUtilsParsersDOMVideoElementParser.js (deleted)
-
jquery.jwplayerView.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/html5/src/jquery.jwplayerCore.js
r925 r926 14 14 return this.each(function() { 15 15 $(this).css("display","none"); 16 var domConfig = $.fn.jwplayerUtilsParsersDOMElementParser.parse(this); 17 var model = $.extend(true, {}, $.fn.jwplayer.defaults, options, domConfig); 18 $(this).data("model", model); 16 $(this).jwplayerParse(options); 19 17 $(this).wrap("<div />"); 20 $(this).before("<img src='" + model.image + "' style='width:" + model.width + "px,height:" + model.height + "px' />");18 $(this).before("<img src='" + $(this).data("model").image + "' style='width:" + $(this).data("model").width + "px,height:" + $(this).data("model").height + "px' />"); 21 19 $(this).prev("img").click($.fn.jwplayer.play); 22 20 // loadSkin(options); 23 21 }); 24 } 22 }; 23 25 24 26 25 $.fn.jwplayer.play = function(event) { … … 30 29 var source = model.sources[sourceIndex]; 31 30 if (source.type == undefined) { 32 source.type = 'video/' + source.file.substr(source.file.lastIndexOf('.')+1, source.file.length) + ';';31 source.type = 'video/' + $.fn.jwplayerUtils.extension(source.file) + ';'; 33 32 } 34 33 if ($.fn.jwplayerUtils.supportsType(source.type)){ 35 $(event.target).remove(); 36 video.css("display","block"); 34 model.item = sourceIndex; 35 $(event.target).css("display","none"); 36 video.css("display","inherit"); 37 37 video[0].play(); 38 38 model.state = 'playing'; 39 break; 40 } 41 } 42 if ($.fn.jwplayerUtils.supportsFlash && model.state != 'playing'){ 43 if (event != undefined) { 44 $.fn.jwplayerView.embedFlash(video, model); 45 $(event.target).remove(); 39 return true; 46 40 } 47 41 } 48 } 42 if ($.fn.jwplayerUtils.supportsFlash && model.state != 'playing'){ 43 for (var sourceIndex in model.sources) { 44 var source = model.sources[sourceIndex]; 45 $.fn.log($.fn.jwplayerUtils.flashCanPlay(source.file)); 46 if ($.fn.jwplayerUtils.flashCanPlay(source.file)){ 47 model.item = sourceIndex; 48 $.fn.jwplayerView.embedFlash(video, model); 49 $(event.target).css("display","none"); 50 return true; 51 } 52 } 53 } 54 alert("No file to play!"); 55 return false; 56 }; 57 49 58 50 59 /** Map with all players on the page. **/ … … 66 75 top:0, 67 76 volume:100, 68 width:400 77 width:400, 78 item:0 69 79 }; 70 80 -
trunk/html5/src/jquery.jwplayerParse.js
r920 r926 8 8 (function($){ 9 9 10 $.fn.jwplayerUtilsParsers = function(){ 10 var elementAttributes = { 11 'element':{ 12 'width':'width', 13 'height': 'height', 14 'id': 'id', 15 'class': 'className', 16 'name': 'name' 17 }, 18 'media': { 19 'src': 'file', 20 'preload': 'preload', 21 'autoplay': 'autostart', 22 'loop': 'repeat', 23 'controls': 'controls' 24 }, 25 'source':{ 26 'src': 'file', 27 'type': 'type', 28 'media': 'media' 29 }, 30 'video': { 31 'poster': 'image' 32 } 11 33 }; 12 34 35 var parsers = { 36 } 37 38 $.fn.jwplayerParse = function(options){ 39 return this.each(function() { 40 $(this).data("model", $.extend(true, {}, $.fn.jwplayer.defaults, options, parseElement(this))); 41 }); 42 }; 43 44 function getAttributeList(attributes, elementType) { 45 if (attributes == undefined) { 46 attributes = elementAttributes[elementType]; 47 } else { 48 $.extend(attributes, elementAttributes[elementType]); 49 } 50 return attributes; 51 } 52 53 function parseElement(domElement, attributes) { 54 if (parsers[domElement.tagName.toLowerCase()] && (attributes == null)) { 55 return parsers[domElement.tagName.toLowerCase()](domElement); 56 } else { 57 attributes = getAttributeList(attributes, 'element'); 58 var configuration = {}; 59 for (var attribute in attributes) { 60 if (attribute != "length") { 61 var value = $(domElement).attr(attribute); 62 if (!(value == "" || value == undefined)) { 63 configuration[attributes[attribute]] = $(domElement).attr(attribute); 64 } 65 } 66 } 67 return configuration; 68 } 69 }; 70 71 function parseMediaElement(domElement, attributes) { 72 attributes = getAttributeList(attributes, 'media'); 73 var sources = []; 74 $("source",domElement).each(function() { 75 sources[sources.length] = parseSourceElement(this); 76 }); 77 var configuration = parseElement(domElement, attributes); 78 if (configuration['file'] != undefined) { 79 sources[0] = {'file':configuration['file']}; 80 } 81 configuration['sources'] = sources; 82 return configuration; 83 }; 84 85 function parseSourceElement(domElement, attributes) { 86 attributes = getAttributeList(attributes, 'source'); 87 return parseElement(domElement, attributes); 88 }; 89 90 function parseVideoElement(domElement, attributes) { 91 attributes = getAttributeList(attributes, 'video'); 92 return parseMediaElement(domElement, attributes); 93 } 94 95 parsers['media'] = parseMediaElement; 96 parsers['audio'] = parseMediaElement; 97 parsers['source'] = parseSourceElement; 98 parsers['video'] = parseVideoElement; 99 100 13 101 })(jQuery); -
trunk/html5/src/jquery.jwplayerUtils.js
r924 r926 9 9 (function($){ 10 10 11 /** Constructor **/ 11 12 $.fn.jwplayerUtils = function(){ 12 13 return this.each(function() { 13 14 }); 14 } 15 }; 15 16 16 17 /** Check if this client supports Flash player 9.0.115+ (FLV/H264). **/ … … 41 42 }; 42 43 43 /** check if this client supports playback for the specified type. **/ 44 /** Filetypes supported by Flash **/ 45 var flashFileTypes = { 46 '3g2':true, 47 '3gp':true, 48 'aac':true, 49 'f4b':true, 50 'f4p':true, 51 'f4v':true, 52 'flv':true, 53 'gif':true, 54 'jpg':true, 55 'jpeg':true, 56 'm4a':true, 57 'm4v':true, 58 'mov':true, 59 'mp3':true, 60 'mp4':true, 61 'png':true, 62 'rbs':true, 63 'sdp':true, 64 'swf':true, 65 'vp6':true 66 }; 67 68 69 /** Check if this client supports Flash player 9.0.115+ (FLV/H264). **/ 70 $.fn.jwplayerUtils.flashCanPlay = function(fileName) { 71 if (flashFileTypes[$.fn.jwplayerUtils.extension(fileName)]){ 72 return true; 73 } 74 return false; 75 }; 76 77 /** Check if this client supports playback for the specified type. **/ 44 78 $.fn.jwplayerUtils.supportsType = function(type) { 45 79 try { … … 50 84 }; 51 85 52 /** check if this client supports HTML5 H.264 playback. **/86 /** Check if this client supports HTML5 H.264 playback. **/ 53 87 $.fn.jwplayerUtils.supportsH264 = function() { 54 88 return $.fn.jwplayerUtils.supportsType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"'); … … 56 90 57 91 58 /** check if this client supports HTML5 OGG playback. **/92 /** Check if this client supports HTML5 OGG playback. **/ 59 93 $.fn.jwplayerUtils.supportsOgg = function() { 60 94 return $.fn.jwplayerUtils.supportsType('video/ogg; codecs="theora, vorbis"'); 61 95 }; 62 96 97 /** Returns the extension of a file name **/ 98 $.fn.jwplayerUtils.extension = function(path) { 99 return path.substr(path.lastIndexOf('.')+1, path.length); 100 }; 101 102 /** Dumps the content of an object to a string **/ 63 103 $.fn.jwplayerUtils.dump = function(object, depth) { 64 104 if (object == null) { … … 92 132 return result; 93 133 }; 94 134 135 /** Returns the true type of an object **/ 95 136 $.fn.jwplayerUtils.typeOf = function(value) { 96 137 var s = typeof value; … … 108 149 109 150 151 /** Logger **/ 110 152 $.fn.log = function (msg, obj) { 111 153 try { 112 console.log("%s: %o", msg, obj); 154 if (obj) { 155 console.log("%s: %o", msg, obj); 156 } else { 157 console.log($.fn.jwplayerUtils.dump(msg)); 158 } 113 159 } catch (err) { 114 160 } -
trunk/html5/src/jquery.jwplayerView.js
r923 r926 23 23 "allowfullscreen='true' " + 24 24 "allowscriptaccess='always' " + 25 "flashvars='file=" + model.sources[ 0].file + "&image=" + model.image + "' " +25 "flashvars='file=" + model.sources[model.item].file + "&image=" + model.image + "' " + 26 26 "/>" 27 27 ); … … 32 32 "<param name='allowscriptaccess' value='always'>" + 33 33 "<param name='wmode' value='transparent'>" + 34 "<param name='flashvars' value='file=" + model.sources[ 0].file + "&image=" + model.image + "'>" +34 "<param name='flashvars' value='file=" + model.sources[model.item].file + "&image=" + model.image + "'>" + 35 35 "</object>" 36 36 );
Note: See TracChangeset
for help on using the changeset viewer.
