--- a/web/static/res/js/incplayer.js Tue Dec 11 21:13:42 2012 +0100
+++ b/web/static/res/js/incplayer.js Wed Dec 12 03:10:24 2012 +0100
@@ -59,9 +59,6 @@
// Load all sequences data
this.allSequencesData = this.loadJson(jsonFile);
- this.logi("sequences in part1: " + (this.allSequencesData.part1 !== undefined ? this.allSequencesData.part1.length : 0));
- this.logi("sequences in part2: " + (this.allSequencesData.part2 !== undefined ? this.allSequencesData.part2.length : 0));
- this.logi("sequences in part3: " + (this.allSequencesData.part3 !== undefined ? this.allSequencesData.part3.length : 0));
this.initDone = true;
return true;
@@ -78,7 +75,7 @@
}
};
- this.createPopSequence = function()
+ this.createPopSequence = function(words)
{
if (!this.initDone) {
this.loge("incplayer not initialized");
@@ -89,29 +86,24 @@
this.destroySequence();
// Choose the 3 video
- this.choosePopSequence();
+ this.choosePopSequence(words);
// And cerate the popcorn sequence
this.initPopSequence();
};
- this.choosePopSequence = function()
+ this.choosePopSequence = function(words)
{
this.sequences = [];
- if (this.allSequencesData.part1 !== undefined && this.allSequencesData.part1.length) {
- this.sequences.push(this.allSequencesData.part1[this.random(0, this.allSequencesData.part1.length)]);
- }
- if (this.allSequencesData.part2 !== undefined && this.allSequencesData.part2.length) {
- this.sequences.push(this.allSequencesData.part2[this.random(0, this.allSequencesData.part2.length)]);
- }
- if (this.allSequencesData.part3 !== undefined && this.allSequencesData.part3.length) {
- this.sequences.push(this.allSequencesData.part3[this.random(0, this.allSequencesData.part3.length)]);
- }
+ 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]));
// Set the video file name
var i;
for (i = 0; i < this.sequences.length; ++i) {
- var file = this.sequences[i].src;
+ var file = this.sequences[i];
// HD
if(this.hd) {
@@ -119,11 +111,16 @@
}
// Extention
- file += "." + this.videoExt;
+ file += "." + /*this.videoExt*/ "mp4"; // todo
// Set the final file
- this.sequences[i].src = file;
+ this.sequences[i] = file;
}
+
+ for (i = 0; i < this.sequences.length; ++i) {
+ this.sequences[i] = { src: this.sequences[i], in: 0, out: -1 };
+ }
+
this.logi("choosed sequences:");
for (i = 0; i < this.sequences.length; ++i) {
@@ -131,6 +128,36 @@
}
};
+ this.getRandomVideos = function(word)
+ {
+ var index = this.getWordIndex(word);
+ var videos = [];
+
+ // Get all video affected by this word
+ for (var i = 0; i < this.allSequencesData.videos.length; ++i) {
+ var video = this.allSequencesData.videos[i];
+
+ // 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);
+ }
+ }
+
+ return videos[this.random(0, videos.length)];
+ }
+
+ this.getWordIndex = function(word)
+ {
+ var words = this.allSequencesData.mots;
+ for (var i = 0; i < words.length; ++i) {
+ if (words[i] == word) {
+ return i;
+ }
+ }
+ console.log("getWordIndex erreur");
+ return -1;
+ };
+
this.initPopSequence = function()
{
var self = this;
@@ -145,9 +172,6 @@
// Hide controls
pop.controls(false);
- // Mute (debug)
- pop.mute();
-
self.listenEvent(pop, "playing", false, function() {
self.displayPlayButton(false);
self.logi("play sequence: " + self.sequenceToString(self.popSeq.active));
@@ -171,32 +195,21 @@
self.playerIsReady = true;
+ // 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
self.ctrlPlay();
-
- if (self.seekTime !== 0.0) {
- self.popSeq.jumpTo(self.seekTime);
- self.seekTime = 0.0;
- }
}
// Unlisten event
self.popSeq.off("loadedmetadata");
-
- // Call the resize object
- if (incResize !== undefined) {
- incResize.resizeElements();
- }
-
self.logi("the player is ready");
});
self.popSeq.on("cycle", function() {
- self.logi("CYCLE !");
});
};