mirror of
https://github.com/videojs/video.js.git
synced 2025-03-17 21:18:27 +02:00
adding a currentType method to get current source type if known
This commit is contained in:
parent
8a05aa11a1
commit
9e8a31065e
@ -70,6 +70,7 @@ goog.exportProperty(vjs.Component.prototype, 'buildCSSClass', vjs.Component.prot
|
||||
|
||||
// Need to export ended to ensure it's not removed by CC, since it's not used internally
|
||||
goog.exportProperty(vjs.Player.prototype, 'ended', vjs.Player.prototype.ended);
|
||||
goog.exportProperty(vjs.Player.prototype, 'currentType', vjs.Player.prototype.currentType);
|
||||
|
||||
goog.exportSymbol('videojs.MediaLoader', vjs.MediaLoader);
|
||||
goog.exportSymbol('videojs.TextTrackDisplay', vjs.TextTrackDisplay);
|
||||
|
@ -275,6 +275,7 @@ vjs.Player.prototype.loadTech = function(techName, source){
|
||||
var techOptions = vjs.obj.merge({ 'source': source, 'parentEl': this.el_ }, this.options_[techName.toLowerCase()]);
|
||||
|
||||
if (source) {
|
||||
this.srcType_ = source.type;
|
||||
if (source.src == this.cache_.src && this.cache_.currentTime > 0) {
|
||||
techOptions['startTime'] = this.cache_.currentTime;
|
||||
}
|
||||
@ -1065,6 +1066,17 @@ vjs.Player.prototype.selectSource = function(sources){
|
||||
return false;
|
||||
};
|
||||
|
||||
vjs.Player.prototype.setSource = function(source, type) {
|
||||
this.srcType_ = type;
|
||||
this.techCall('src', source);
|
||||
if (this.options_['preload'] == 'auto') {
|
||||
this.load();
|
||||
}
|
||||
if (this.options_['autoplay']) {
|
||||
this.play();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The source function updates the video source
|
||||
*
|
||||
@ -1131,7 +1143,7 @@ vjs.Player.prototype.src = function(source){
|
||||
} else if (source instanceof Object) {
|
||||
|
||||
if (window['videojs'][this.techName]['canPlaySource'](source)) {
|
||||
this.src(source.src);
|
||||
this.setSource(source.src, source.type);
|
||||
} else {
|
||||
// Send through tech loop to check for a compatible technology.
|
||||
this.src([source]);
|
||||
@ -1144,16 +1156,10 @@ vjs.Player.prototype.src = function(source){
|
||||
|
||||
if (!this.isReady_) {
|
||||
this.ready(function(){
|
||||
this.src(source);
|
||||
this.setSource(source);
|
||||
});
|
||||
} else {
|
||||
this.techCall('src', source);
|
||||
if (this.options_['preload'] == 'auto') {
|
||||
this.load();
|
||||
}
|
||||
if (this.options_['autoplay']) {
|
||||
this.play();
|
||||
}
|
||||
this.setSource(source);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1172,6 +1178,10 @@ vjs.Player.prototype.currentSrc = function(){
|
||||
return this.techGet('currentSrc') || this.cache_.src || '';
|
||||
};
|
||||
|
||||
vjs.Player.prototype.currentType = function(){
|
||||
return this.srcType_ || '';
|
||||
};
|
||||
|
||||
// Attributes/Options
|
||||
vjs.Player.prototype.preload = function(value){
|
||||
if (value !== undefined) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user