mirror of
https://github.com/videojs/video.js.git
synced 2025-09-16 09:26:56 +02:00
@heff fixed setting the source to an empty string. closes #1905
This commit is contained in:
@@ -2,7 +2,7 @@ CHANGELOG
|
||||
=========
|
||||
|
||||
## HEAD (Unreleased)
|
||||
_(none)_
|
||||
* @heff fixed setting the source to an empty string ([view](https://github.com/videojs/video.js/pull/1905))
|
||||
|
||||
--------------------
|
||||
|
||||
|
@@ -496,6 +496,16 @@ vjs.MediaTechController.withSourceHandlers = function(Tech){
|
||||
Tech.prototype.setSource = function(source){
|
||||
var sh = Tech.selectSourceHandler(source);
|
||||
|
||||
if (!sh) {
|
||||
// Fall back to a native source hander when unsupported sources are
|
||||
// deliberately set
|
||||
if (Tech.nativeSourceHandler) {
|
||||
sh = Tech.nativeSourceHandler;
|
||||
} else {
|
||||
vjs.log.error('No source hander found for the current source.');
|
||||
}
|
||||
}
|
||||
|
||||
// Dispose any existing source handler
|
||||
this.disposeSourceHandler();
|
||||
this.off('dispose', this.disposeSourceHandler);
|
||||
|
@@ -229,3 +229,25 @@ test('should add the source hanlder interface to a tech', function(){
|
||||
tech.dispose();
|
||||
ok(disposeCalled, 'the handler dispose method was called when the tech was disposed');
|
||||
});
|
||||
|
||||
test('should handle unsupported sources with the source hanlder API', function(){
|
||||
var mockPlayer = {
|
||||
off: this.noop,
|
||||
trigger: this.noop
|
||||
};
|
||||
|
||||
// Define a new tech class
|
||||
var Tech = videojs.MediaTechController.extend();
|
||||
// Extend Tech with source handlers
|
||||
vjs.MediaTechController.withSourceHandlers(Tech);
|
||||
// Create an instance of Tech
|
||||
var tech = new Tech(mockPlayer);
|
||||
|
||||
var usedNative;
|
||||
Tech.nativeSourceHandler = {
|
||||
handleSource: function(){ usedNative = true; }
|
||||
};
|
||||
|
||||
tech.setSource('');
|
||||
ok(usedNative, 'native source handler was used when an unsupported source was set');
|
||||
});
|
Reference in New Issue
Block a user