improve function name, fix autoplay
This commit is contained in:
parent
5fae9d2213
commit
71ef581b80
1 changed files with 17 additions and 17 deletions
|
@ -107,7 +107,7 @@ Ox.VideoElement = function(options, self) {
|
|||
|
||||
loadItems(function() {
|
||||
setCurrentItem(0);
|
||||
self.options.autoplay && play();
|
||||
self.options.autoplay && that.play();
|
||||
});
|
||||
|
||||
function getCurrentTime() {
|
||||
|
@ -160,6 +160,20 @@ Ox.VideoElement = function(options, self) {
|
|||
.appendTo(that);
|
||||
}
|
||||
|
||||
function isReady($video, callback) {
|
||||
if ($video[0].seeking) {
|
||||
$video.one('seeked', function(event) {
|
||||
callback($video[0]);
|
||||
});
|
||||
} else if ($video[0].readyState) {
|
||||
callback($video[0]);
|
||||
} else {
|
||||
$video.one('loadedmetadata', function(event) {
|
||||
callback($video[0]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function loadItems(callback) {
|
||||
var currentTime = 0,
|
||||
items = self.options.items.map(function(item) {
|
||||
|
@ -220,20 +234,6 @@ Ox.VideoElement = function(options, self) {
|
|||
nextVideo.src = next.src;
|
||||
}
|
||||
|
||||
function onLoadedMetadata($video, callback) {
|
||||
if ($video[0].seeking) {
|
||||
$video.one('seeked', function(event) {
|
||||
callback($video[0]);
|
||||
});
|
||||
} else if ($video[0].readyState) {
|
||||
callback($video[0]);
|
||||
} else {
|
||||
$video.one('loadedmetadata', function(event) {
|
||||
callback($video[0]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function setCurrentItem(item) {
|
||||
Ox.Log('Video', 'sCI', item, self.numberOfItems);
|
||||
var interval;
|
||||
|
@ -296,7 +296,7 @@ Ox.VideoElement = function(options, self) {
|
|||
self.$video.css(css);
|
||||
Ox.Log('Video', 'sCV', self.video.src, item['in'],
|
||||
self.video.currentTime, self.video.seeking);
|
||||
onLoadedMetadata(self.$video, function(video) {
|
||||
isReady(self.$video, function(video) {
|
||||
self.$video.one('seeked', function() {
|
||||
self.loading = false;
|
||||
!self.paused && self.video.play();
|
||||
|
@ -314,7 +314,7 @@ Ox.VideoElement = function(options, self) {
|
|||
function setCurrentItemTime(currentTime) {
|
||||
Ox.Log('Video', 'sCIT', currentTime, self.video.currentTime,
|
||||
'delta', currentTime - self.video.currentTime);
|
||||
onLoadedMetadata(self.$video, function(video) {
|
||||
isReady(self.$video, function(video) {
|
||||
if (self.video == video) {
|
||||
if(self.seeking) {
|
||||
self.$video.one('seeked', function() {
|
||||
|
|
Loading…
Reference in a new issue