--- a/web/static/res/js/incplayer.js Wed Dec 12 04:01:13 2012 +0100
+++ b/web/static/res/js/incplayer.js Wed Dec 12 15:54:57 2012 +0100
@@ -96,31 +96,51 @@
{
this.sequences = [];
var videos = this.allSequencesData.videos;
- this.sequences.push(this.getRandomVideos(words[0]));
- this.sequences.push(this.getRandomVideos(words[1]));
- this.sequences.push(this.getRandomVideos(words[2]));
+
+ // Choose first video
+ var v1 = this.getRandomVideos(words[0]);
+ this.sequences.push(v1);
+
+ var v2, v3;
+
+ // Choose second video
+ do {
+ v2 = this.getRandomVideos(words[1]) ;
+ } while (v2.src == v1.src);
+ this.sequences.push(v2);
+
+ // Choose third video
+ do {
+ v3 = this.getRandomVideos(words[2]) ;
+ } while (v3.src == v1.src || v3.src == v2.src);
+ this.sequences.push(v3);
// Set the video file name
var i;
for (i = 0; i < this.sequences.length; ++i) {
- var file = this.sequences[i];
+ var v = this.sequences[i];
// HD
if(this.hd) {
- file += "hd";
+ v.src += "hd";
}
// Extention
- file += "." + /*this.videoExt*/ "mp4"; // todo
+ v.src += "." + /*this.videoExt*/ "mp4"; // todo
// Set the final file
- this.sequences[i] = file;
+ this.sequences[i] = v;
}
for (i = 0; i < this.sequences.length; ++i) {
- this.sequences[i] = { src: this.sequences[i], in: 0, out: -1 };
+ var seq = this.sequences[i];
+
+ var integer = Math.floor(seq.duration);
+ var decimal = Math.floor((seq.duration - integer) * 100);
+ var duration = integer * 60 + decimal;
+
+ this.sequences[i] = { src: seq.src, in: 0, out: duration };
}
-
this.logi("choosed sequences:");
for (i = 0; i < this.sequences.length; ++i) {
@@ -139,7 +159,7 @@
// We push has many time the url that the score for the word
for (var j = 0; j < video.scoreWord[index]; ++j) {
- videos.push(video.src);
+ videos.push(video);
}
}
@@ -184,7 +204,16 @@
self.listenEvent(pop, "timeupdate", false, function() {
// Update the current time position
- $(self.progressCurrent).html(self.secondsToTime(self.popSeq.currentTime()));
+ var currentTime = self.popSeq.currentTime();
+ $(self.progressCurrent).html(self.secondsToTime(currentTime));
+
+ // Detect vsquence end
+ if (self.popSeq.active == 2 && currentTime >= self.popSeq.duration()) {
+ setTimeout(function() {
+ location.href = "transition.html";
+ }, 2000);
+
+ }
});
self.listenEvent(pop, "canplaythrough", true, function() {
@@ -197,7 +226,7 @@
// todo
// Set total duration
- //$(self.progressDuration).html(self.secondsToTime(self.popSeq.duration()));
+ $(self.progressDuration).html(self.secondsToTime(self.popSeq.duration()));
if (!self.iOS) {
// Automatic play
@@ -213,8 +242,6 @@
});
self.popSeq.on("ended", function() {
- // todo
- location.href = "transition.html";
});
};