-
Notifications
You must be signed in to change notification settings - Fork 7.5k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Fixed type support checking for an empty src string #1797
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -307,13 +307,13 @@ vjs.Html5.nativeSourceHandler = {}; | |
* @return {String} 'probably', 'maybe', or '' (empty string) | ||
*/ | ||
vjs.Html5.nativeSourceHandler.canHandleSource = function(source){ | ||
var ext; | ||
var match, ext; | ||
|
||
function canPlayType(type){ | ||
// IE9 on Windows 7 without MediaPlayer throws an error here | ||
// https://github.com/videojs/video.js/issues/519 | ||
try { | ||
return !!vjs.TEST_VID.canPlayType(type); | ||
return vjs.TEST_VID.canPlayType(type); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why'd we revert from the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When implementing the Flash source handler I decided to go with the maybe/probably/empty-string return values to be more similar to canPlayType. HTML5 needed to be updated to match that too. |
||
} catch(e) { | ||
return ''; | ||
} | ||
|
@@ -322,11 +322,15 @@ vjs.Html5.nativeSourceHandler.canHandleSource = function(source){ | |
// If a type was provided we should rely on that | ||
if (source.type) { | ||
return canPlayType(source.type); | ||
} else { | ||
} else if (source.src) { | ||
// If no type, fall back to checking 'video/[EXTENSION]' | ||
ext = source.src.match(/\.([^\/\?]+)(\?[^\/]+)?$/i)[1]; | ||
match = source.src.match(/\.([^\/\?]+)(\?[^\/]+)?$/i); | ||
ext = match && match[1]; | ||
|
||
return canPlayType('video/'+ext); | ||
} | ||
|
||
return ''; | ||
}; | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought the plan was to go with explicit var declarations moving forward, or are instances like this an exception (no actual values set, just defined)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Waiting for @gkatsev's input to change what I'm using in practice.