| author | ymh <ymh.work@gmail.com> |
| Tue, 12 Feb 2013 10:54:34 +0100 | |
| changeset 134 | 678b07d351ef |
| parent 124 | 8d2376eb825c |
| permissions | -rw-r--r-- |
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
1 |
function IncPlayer() |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
2 |
{ |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
3 |
// -------------------------------------------------------------------------------------------------------------------- |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
4 |
// Members |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
5 |
// -------------------------------------------------------------------------------------------------------------------- |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
6 |
|
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
7 |
// Global |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
8 |
this.initDone = false; |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
9 |
this.playerIsReady = false; |
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
10 |
this.playerWaitForBeingReady = false; // used on ipad |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
11 |
this.mobile; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
12 |
this.ipad; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
13 |
this.nextPage; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
14 |
this.reloadPage; |
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
15 |
|
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
16 |
// Sequences |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
17 |
this.allSequencesData = []; |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
18 |
this.sequences = []; |
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
19 |
this.singleVideo; |
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
20 |
|
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
21 |
// Popcorn objects |
| 36 | 22 |
this.videoDivId = ""; |
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
23 |
this.videoExt = ""; |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
24 |
this.popSeq = null; |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
25 |
|
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
26 |
// Controls |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
27 |
this.playButton = null; |
| 124 | 28 |
this.hdSdButton = null; |
| 36 | 29 |
this.progressCurrent = null; |
30 |
this.progressDuration = null; |
|
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
31 |
this.progressCursor = null; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
32 |
this.progressBar = null; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
33 |
this.progressCursorX = 0; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
34 |
this.progressCursorDrag; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
35 |
this.hd; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
36 |
this.seekTime = -1; |
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
37 |
|
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
38 |
// Tools |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
39 |
this.logiEnable = true; |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
40 |
this.jsonData = []; |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
41 |
|
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
42 |
// -------------------------------------------------------------------------------------------------------------------- |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
43 |
// Functions |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
44 |
// -------------------------------------------------------------------------------------------------------------------- |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
45 |
|
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
46 |
this.init = function(nextPage, videoDivId, playButtonId, hdSdButtonId, progressCurrentId, progressDurationId, progressCursorId, progressBarId, jsonFile) |
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
47 |
{ |
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
48 |
this.nextPage = nextPage; |
| 36 | 49 |
this.videoDivId = videoDivId; |
50 |
||
51 |
// Control |
|
52 |
this.playButton = $("#" + playButtonId).get(0); |
|
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
53 |
this.hdSdButton = $("#" + hdSdButtonId).get(0); |
| 36 | 54 |
this.progressCurrent = $("#" + progressCurrentId); |
55 |
this.progressDuration = $("#" + progressDurationId); |
|
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
56 |
this.progressCursor = $("#" + progressCursorId); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
57 |
this.progressBar = $("#" + progressBarId); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
58 |
this.ctrlSetCursorDragFunction(); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
59 |
this.setCursorPosition(0); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
60 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
61 |
// HD ? |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
62 |
this.hd = incChoice.getHD(); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
63 |
$(this.hdSdButton).css({"background-position" : this.hd ? '0 -12px' : '0 0'}); |
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
64 |
|
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
65 |
// Video extention |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
66 |
this.videoExt = this.getSupportedVideoExt(); |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
67 |
if (this.videoExt === "") { |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
68 |
this.loge("your browser don't support HTML5 videos"); |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
69 |
return false; |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
70 |
} |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
71 |
|
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
72 |
if (jsonFile !== null & jsonFile !== undefined) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
73 |
// Load all sequences data |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
74 |
this.allSequencesData = this.loadJson(jsonFile); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
75 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
76 |
// Add index to the videos |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
77 |
for (var i = 0; i < this.allSequencesData.videos.length; ++i) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
78 |
this.allSequencesData.videos[i].index = i; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
79 |
} |
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
80 |
} |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
81 |
|
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
82 |
this.initDone = true; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
83 |
this.mobile = IsSmartphone(); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
84 |
this.ipad = !this.mobile && IsIpad(); |
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
85 |
|
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
86 |
return true; |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
87 |
}; |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
88 |
|
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
89 |
this.destroySequence = function() |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
90 |
{ |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
91 |
if (this.popSeq !== null) { |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
92 |
for (var i = 0; i < this.sequences.length; ++i) { |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
93 |
this.popSeq.eq(i).destroy(); |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
94 |
} |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
95 |
this.sequences = []; |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
96 |
this.popSeq.remove(); |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
97 |
} |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
98 |
}; |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
99 |
|
|
93
7c37aaa2a8ae
netoyage update du rep static
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
88
diff
changeset
|
100 |
this.createPopSequence = function(words, videosIndex, paramIndex) |
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
101 |
{ |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
102 |
if (!this.initDone) { |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
103 |
this.loge("incplayer not initialized"); |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
104 |
return; |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
105 |
} |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
106 |
|
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
107 |
// Delete previous popcorn objects |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
108 |
this.destroySequence(); |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
109 |
|
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
110 |
// Choose the 3 videos |
|
93
7c37aaa2a8ae
netoyage update du rep static
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
88
diff
changeset
|
111 |
this.choosePopSequence(words, videosIndex, paramIndex); |
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
112 |
|
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
113 |
// And init the popcorn sequence |
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
114 |
this.initPopSequence(); |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
115 |
}; |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
116 |
|
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
117 |
this.playSingleVideo = function(videoUrl) |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
118 |
{ |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
119 |
this.sequences = []; |
|
93
7c37aaa2a8ae
netoyage update du rep static
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
88
diff
changeset
|
120 |
this.singleVideo = true; |
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
121 |
var video = { name : "xxx", src: videoUrl, in: 0, out: "1.44" }; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
122 |
this.sequences.push(video); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
123 |
this.formatPopSequence(); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
124 |
this.initPopSequence(); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
125 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
126 |
|
|
93
7c37aaa2a8ae
netoyage update du rep static
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
88
diff
changeset
|
127 |
this.choosePopSequence = function(wordsIndex, videosIndex, paramIndex) |
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
128 |
{ |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
129 |
this.sequences = []; |
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
130 |
|
|
93
7c37aaa2a8ae
netoyage update du rep static
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
88
diff
changeset
|
131 |
if (paramIndex.length == 3) { |
|
7c37aaa2a8ae
netoyage update du rep static
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
88
diff
changeset
|
132 |
// This is a shared link, we get the videos index from the url |
|
7c37aaa2a8ae
netoyage update du rep static
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
88
diff
changeset
|
133 |
for (var i = 0; i < paramIndex.length; ++i) { |
|
7c37aaa2a8ae
netoyage update du rep static
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
88
diff
changeset
|
134 |
this.sequences.push(this.allSequencesData.videos[paramIndex[i]]); |
|
7c37aaa2a8ae
netoyage update du rep static
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
88
diff
changeset
|
135 |
} |
|
7c37aaa2a8ae
netoyage update du rep static
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
88
diff
changeset
|
136 |
} else if (videosIndex.length == 3) { |
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
137 |
// The player got reloded, we use the previously choosen videos |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
138 |
for (var i = 0; i < videosIndex.length; ++i) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
139 |
this.sequences.push(this.allSequencesData.videos[videosIndex[i]]); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
140 |
} |
| 103 | 141 |
} else if (wordsIndex[0] == null) { |
142 |
// No reason to be here, redirection |
|
143 |
location.href = "index.html"; |
|
144 |
||
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
145 |
} else { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
146 |
// We choose new videos |
| 48 | 147 |
|
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
148 |
// Get previous used videos |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
149 |
var var32bits = incChoice.getChoosenVideosFlags(); |
| 48 | 150 |
|
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
151 |
// Choose videos according to the chosen words |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
152 |
for (var i = 0; i < wordsIndex.length; ++i) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
153 |
var v = this.getRandomVideos(wordsIndex[i], var32bits, this.sequences); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
154 |
if (v == null) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
155 |
// We didn't find free video |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
156 |
// So we mark some as unplayed, we must get flags again and retry |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
157 |
var32bits = incChoice.getChoosenVideosFlags(); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
158 |
v = this.getRandomVideos(wordsIndex[i], var32bits, this.sequences); |
| 48 | 159 |
|
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
160 |
if (v == null) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
161 |
this.loge("We didn't find a free video"); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
162 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
163 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
164 |
this.sequences.push(v); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
165 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
166 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
167 |
// Save played videos with cookies |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
168 |
this.savePlayedVideos(this.sequences, true); |
| 48 | 169 |
|
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
170 |
// Save chosen video with cookies |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
171 |
this.saveChosenVideos(this.sequences); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
172 |
} |
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
173 |
|
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
174 |
// Format pop sequence |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
175 |
this.formatPopSequence(); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
176 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
177 |
// Debug |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
178 |
this.logi("choosed sequences:"); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
179 |
for (i = 0; i < this.sequences.length; ++i) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
180 |
this.logi(this.sequenceToString(i)); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
181 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
182 |
}; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
183 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
184 |
this.formatPopSequence = function() |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
185 |
{ |
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
186 |
// Set the video file name |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
187 |
var i; |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
188 |
for (i = 0; i < this.sequences.length; ++i) { |
| 48 | 189 |
var v = this.sequences[i]; |
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
190 |
|
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
191 |
// HD |
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
192 |
if(!this.hd) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
193 |
v.src = v.src.replace("HD", "SD"); |
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
194 |
} |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
195 |
|
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
196 |
// Extention |
|
93
7c37aaa2a8ae
netoyage update du rep static
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
88
diff
changeset
|
197 |
v.src += "." + this.videoExt; |
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
198 |
|
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
199 |
// Set the final file |
| 48 | 200 |
this.sequences[i] = v; |
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
201 |
} |
| 46 | 202 |
|
203 |
for (i = 0; i < this.sequences.length; ++i) { |
|
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
204 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
205 |
// Get the sequence |
| 48 | 206 |
var seq = this.sequences[i]; |
207 |
||
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
208 |
// Compute time in seconds |
| 48 | 209 |
var integer = Math.floor(seq.duration); |
210 |
var decimal = Math.floor((seq.duration - integer) * 100); |
|
211 |
var duration = integer * 60 + decimal; |
|
212 |
||
213 |
this.sequences[i] = { src: seq.src, in: 0, out: duration }; |
|
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
214 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
215 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
216 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
217 |
this.getRandomVideos = function(wordIndex, var32bits, otherVideos) |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
218 |
{ |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
219 |
var i; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
220 |
var index = parseInt(wordIndex); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
221 |
var videos = []; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
222 |
var allVideosPlayed = true; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
223 |
var videosMatchWord = []; |
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
224 |
|
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
225 |
// Debug |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
226 |
var freeVideosCount = 0; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
227 |
var wordScoreAllVideos = 0; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
228 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
229 |
// Get all videos affected by this word |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
230 |
for (i = 0; i < this.allSequencesData.videos.length; ++i) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
231 |
var video = this.allSequencesData.videos[i]; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
232 |
var wordScore = video.scoreWord[index]; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
233 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
234 |
if (wordScore <= 0) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
235 |
// This video can't be choosen with this word |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
236 |
continue; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
237 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
238 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
239 |
videosMatchWord.push(video); // Debug |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
240 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
241 |
video.choosen = incChoice.IsThisVideoWasPlayed(var32bits, video.index); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
242 |
if (video.choosen) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
243 |
// This video was already played in an another session |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
244 |
continue; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
245 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
246 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
247 |
allVideosPlayed = false; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
248 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
249 |
// Compare categories |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
250 |
video.samecat = false; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
251 |
for (var j = 0; j < otherVideos.length; ++j) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
252 |
if (video.cat == otherVideos[j].cat) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
253 |
video.samecat = true; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
254 |
break; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
255 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
256 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
257 |
if (video.samecat == true) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
258 |
// This video have the same cat that an other selected video |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
259 |
continue; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
260 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
261 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
262 |
// We push has many time the video that the score for the word |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
263 |
for (var j = 0; j < wordScore; ++j) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
264 |
videos.push(video); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
265 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
266 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
267 |
// Debug |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
268 |
wordScoreAllVideos += wordScore; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
269 |
++freeVideosCount; |
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
270 |
} |
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
271 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
272 |
if (allVideosPlayed || !videos.length) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
273 |
// All the videos asociated with the word have been played |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
274 |
// or there is no videos to choose because we skipped the one with the same cat |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
275 |
// We must mark the videos asociated with the word as unplayed |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
276 |
this.savePlayedVideos(videosMatchWord, false); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
277 |
return null; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
278 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
279 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
280 |
// Choose random video |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
281 |
var v = videos[this.random(0, videos.length)]; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
282 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
283 |
// Debug |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
284 |
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
285 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
286 |
this.logi("---------------------------------------------------------------------"); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
287 |
this.logi("The word " + this.allSequencesData.mots[index] + "(" + index + ")" +" give us " + videosMatchWord.length + " videos, we can choose " + freeVideosCount); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
288 |
this.logi("---------------------------------------------------------------------"); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
289 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
290 |
for (i = 0; i < videosMatchWord.length; ++i) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
291 |
var video = videosMatchWord[i]; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
292 |
var message = this.resizeString(video.name, 15) + this.resizeString(" cat:" + video.cat, 15); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
293 |
if (video.choosen) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
294 |
message += this.resizeString("played", 15); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
295 |
} else if (video.samecat) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
296 |
message += this.resizeString("same cat", 15); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
297 |
} else { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
298 |
message += this.resizeString("OK", 15) + this.resizeString("proba:" + video.scoreWord[index] + "/" + wordScoreAllVideos, 15); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
299 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
300 |
this.logi(message); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
301 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
302 |
this.logi(""); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
303 |
this.logi("We choose " + v.name + "(" + v.index + ")" + " cat:" + v.cat + " proba: " + v.scoreWord[index] + "/" + wordScoreAllVideos + "\n\n"); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
304 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
305 |
return v; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
306 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
307 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
308 |
this.savePlayedVideos = function(videos, markPlayed) |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
309 |
{ |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
310 |
var indexs = []; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
311 |
for (var i = 0; i < videos.length; ++i) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
312 |
indexs.push(videos[i].index); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
313 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
314 |
incChoice.savePlayedVideos(indexs, markPlayed); |
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
315 |
}; |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
316 |
|
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
317 |
this.saveChosenVideos = function(videos) |
| 46 | 318 |
{ |
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
319 |
var indexs = []; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
320 |
for (var i = 0; i < videos.length; ++i) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
321 |
indexs.push(videos[i].index); |
| 46 | 322 |
} |
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
323 |
incChoice.saveChosenVideos(indexs); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
324 |
}; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
325 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
326 |
this.resizeString = function (str, size) |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
327 |
{ |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
328 |
while (str.length < size) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
329 |
str += " "; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
330 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
331 |
return str; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
332 |
}; |
| 46 | 333 |
|
334 |
this.getWordIndex = function(word) |
|
335 |
{ |
|
336 |
var words = this.allSequencesData.mots; |
|
337 |
for (var i = 0; i < words.length; ++i) { |
|
338 |
if (words[i] == word) { |
|
339 |
return i; |
|
340 |
} |
|
341 |
} |
|
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
342 |
this.loge("getWordIndex erreur"); |
| 46 | 343 |
return -1; |
344 |
}; |
|
345 |
||
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
346 |
this.debugDisplayWordsIndex = function() |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
347 |
{ |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
348 |
var words = this.allSequencesData.mots; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
349 |
for (var i = 0; i < words.length; ++i) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
350 |
this.logi(words[i] + " -> " + i); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
351 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
352 |
}; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
353 |
|
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
354 |
this.initPopSequence = function() |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
355 |
{ |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
356 |
var self = this; |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
357 |
|
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
358 |
// Create the popcorn sequencer |
| 36 | 359 |
self.popSeq = Popcorn.sequence(self.videoDivId, self.sequences); |
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
360 |
|
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
361 |
for (var i = 0; i < self.sequences.length; ++i) { |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
362 |
|
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
363 |
var pop = self.popSeq.eq(i); |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
364 |
|
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
365 |
// Hide controls |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
366 |
pop.controls(false); |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
367 |
|
|
93
7c37aaa2a8ae
netoyage update du rep static
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
88
diff
changeset
|
368 |
// Add poster on ipad |
|
7c37aaa2a8ae
netoyage update du rep static
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
88
diff
changeset
|
369 |
if (self.ipad && !this.singleVideo) { |
|
7c37aaa2a8ae
netoyage update du rep static
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
88
diff
changeset
|
370 |
$(pop.media).attr('poster', 'static/res/img/poster' + (i + 1) + '_video.png'); |
|
7c37aaa2a8ae
netoyage update du rep static
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
88
diff
changeset
|
371 |
} |
|
7c37aaa2a8ae
netoyage update du rep static
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
88
diff
changeset
|
372 |
|
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
373 |
// Play event |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
374 |
self.listenEvent(pop, "playing", false, i, function(index) { |
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
375 |
self.displayPlayButton(false); |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
376 |
self.logi("play sequence: " + self.sequenceToString(self.popSeq.active)); |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
377 |
}); |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
378 |
|
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
379 |
// Pause event |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
380 |
self.listenEvent(pop, "pause", false, i, function(index) { |
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
381 |
self.displayPlayButton(true); |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
382 |
self.logi("pause sequence: " + self.sequenceToString(self.popSeq.active)); |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
383 |
}); |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
384 |
|
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
385 |
// Ended event |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
386 |
self.listenEvent(pop, "ended", false, i, function(index) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
387 |
self.logi("ended sequence: " + self.sequenceToString(self.popSeq.active)); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
388 |
}); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
389 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
390 |
// Timeupdate event |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
391 |
self.listenEvent(pop, "timeupdate", false, i, function(index) { |
| 48 | 392 |
|
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
393 |
var currentTime = self.popSeq.currentTime(); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
394 |
if (!self.progressCursorDrag) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
395 |
// Move timeline and display the time |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
396 |
self.progressCursorX = self.setCursorPosition(currentTime); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
397 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
398 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
399 |
// Detect the sequence end |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
400 |
if (self.popSeq.active == self.sequences.length-1 && currentTime >= self.popSeq.duration() - 1) { |
| 48 | 401 |
setTimeout(function() { |
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
402 |
location.href = self.nextPage; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
403 |
}, 1500); |
| 48 | 404 |
} |
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
405 |
}); |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
406 |
|
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
407 |
/* |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
408 |
// Canplaythrough event |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
409 |
self.listenEvent(pop, "canplaythrough", true, i, function(index) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
410 |
}); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
411 |
*/ |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
412 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
413 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
414 |
if (!this.ipad) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
415 |
self.popSeq.on("canplaythrough", function() { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
416 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
417 |
self.playerIsReady = true; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
418 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
419 |
// Recompute Duration |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
420 |
self.recomputeDuration(); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
421 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
422 |
// Automatic play |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
423 |
self.ctrlPlay(); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
424 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
425 |
// Unlisten event |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
426 |
self.popSeq.off("canplaythrough"); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
427 |
self.logi("the player is ready"); |
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
428 |
}); |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
429 |
} |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
430 |
|
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
431 |
self.popSeq.on("cycle", function() { |
| 47 | 432 |
}); |
433 |
||
434 |
self.popSeq.on("ended", function() { |
|
435 |
}); |
|
436 |
||
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
437 |
}; |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
438 |
|
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
439 |
this.listenEvent = function(pop, event, unlisten, index, func) |
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
440 |
{ |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
441 |
pop.on(event, function() { |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
442 |
// Execute the function |
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
443 |
func(index); |
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
444 |
|
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
445 |
if (unlisten) { |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
446 |
// Unlisten event |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
447 |
pop.off(event); |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
448 |
} |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
449 |
}); |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
450 |
}; |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
451 |
|
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
452 |
this.recomputeDuration = function() |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
453 |
{ |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
454 |
// Recompute duration |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
455 |
var totalDuration = 0; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
456 |
for (var j = 0; j < this.sequences.length; ++j) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
457 |
var duration = this.popSeq.eq(j).duration(); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
458 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
459 |
// ofVideos |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
460 |
this.popSeq.inOuts.ofVideos[j].out = duration; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
461 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
462 |
// ofClips |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
463 |
this.popSeq.inOuts.ofClips[j].in = totalDuration; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
464 |
totalDuration += duration; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
465 |
this.popSeq.inOuts.ofClips[j].out = totalDuration; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
466 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
467 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
468 |
// Set total duration |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
469 |
$(this.progressDuration).html(this.secondsToTime(this.popSeq.duration())); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
470 |
}; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
471 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
472 |
this.recomputeDurationNoAutoPlay = function() |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
473 |
{ |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
474 |
// Recompute duration |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
475 |
var totalDuration = 0; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
476 |
for (var j = 0; j <= this.popSeq.active; ++j) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
477 |
var duration = this.popSeq.eq(j).duration(); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
478 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
479 |
// ofVideos |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
480 |
this.popSeq.inOuts.ofVideos[j].out = duration; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
481 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
482 |
// ofClips |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
483 |
this.popSeq.inOuts.ofClips[j].in = totalDuration; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
484 |
totalDuration += duration; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
485 |
this.popSeq.inOuts.ofClips[j].out = totalDuration; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
486 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
487 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
488 |
// Set total duration |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
489 |
$(this.progressDuration).html(this.secondsToTime(this.popSeq.duration())); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
490 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
491 |
if (incHideBar !== undefined) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
492 |
incHideBar.showBarPointerOnAction(6000); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
493 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
494 |
}; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
495 |
|
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
496 |
this.getCurrentPop = function() |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
497 |
{ |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
498 |
var index = this.popSeq.active; |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
499 |
if (index >= this.sequences.length) { |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
500 |
index = this.sequences.length-1; |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
501 |
} |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
502 |
return this.popSeq.eq(index); |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
503 |
}; |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
504 |
|
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
505 |
this.setCursorPosition = function(time) |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
506 |
{ |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
507 |
// Display time |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
508 |
$(this.progressCurrent).html(this.secondsToTime(time)); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
509 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
510 |
// Move cursor timeline |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
511 |
var progressCursorX = time ? ((time / this.popSeq.duration()) * (240 - 16)) : 0; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
512 |
$(this.progressCursor).css({"left" : progressCursorX }); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
513 |
$("#progress").css({"width" : progressCursorX + 8}); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
514 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
515 |
return progressCursorX; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
516 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
517 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
518 |
this.forceCheckPlayerIsReady = function() |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
519 |
{ |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
520 |
this.playerIsReady = false; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
521 |
this.playerWaitForBeingReady = false; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
522 |
this.checkPlayerIsReady(); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
523 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
524 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
525 |
this.checkPlayerIsReady = function() |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
526 |
{ |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
527 |
if (this.playerIsReady) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
528 |
return true; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
529 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
530 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
531 |
if (this.ipad) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
532 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
533 |
// We "manualy" play the video (we are in a click event handler) |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
534 |
var media = this.popSeq.eq(this.popSeq.active).media; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
535 |
media.play(); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
536 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
537 |
if (media.readystate === 4) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
538 |
this.playerIsReady = true; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
539 |
this.recomputeDurationNoAutoPlay(); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
540 |
return false; // Ready but we don't want to do anything after |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
541 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
542 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
543 |
if (this.playerWaitForBeingReady) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
544 |
return false; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
545 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
546 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
547 |
this.playerWaitForBeingReady = true; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
548 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
549 |
var self = this; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
550 |
var mediaCanPlay = function () { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
551 |
// Remove event |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
552 |
media.removeEventListener('canplaythrough', mediaCanPlay, false); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
553 |
media.removeEventListener('load', mediaCanPlay, false); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
554 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
555 |
// The video is ready, play |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
556 |
media.play(); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
557 |
self.playerIsReady = true; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
558 |
self.recomputeDurationNoAutoPlay(); |
| 124 | 559 |
self.logi("ipad play event"); |
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
560 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
561 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
562 |
media.addEventListener('canplaythrough', mediaCanPlay, false); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
563 |
media.addEventListener('load', mediaCanPlay, false); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
564 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
565 |
setTimeout(function() { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
566 |
media.pause(); // Block play so it buffers before playing |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
567 |
}, 1); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
568 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
569 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
570 |
this.logi("can't play, the player is not ready"); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
571 |
return false; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
572 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
573 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
574 |
this.ctrlSetCursorDragFunction = function() |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
575 |
{ |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
576 |
var self = this; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
577 |
var origineX = null; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
578 |
var posX; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
579 |
var maxX = 240 - 16; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
580 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
581 |
var setCursorPositionX = function (x) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
582 |
if (x < 0) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
583 |
x = 0; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
584 |
} else if (x > maxX) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
585 |
x = maxX; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
586 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
587 |
var time = self.popSeq.duration() * x / maxX; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
588 |
self.setCursorPosition(time); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
589 |
return x; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
590 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
591 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
592 |
var setCursorPosition = function (x) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
593 |
self.progressCursorDrag = true; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
594 |
if (origineX == null) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
595 |
origineX = x; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
596 |
} else { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
597 |
posX = self.progressCursorX + x - origineX; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
598 |
posX = setCursorPositionX(posX); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
599 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
600 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
601 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
602 |
this.progressCursor.on({ |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
603 |
mousedown: function() { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
604 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
605 |
if (!self.checkPlayerIsReady()) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
606 |
return; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
607 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
608 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
609 |
$(document).on( |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
610 |
self.ipad ? { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
611 |
touchmove: function (e) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
612 |
e.preventDefault(); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
613 |
var touches = ( typeof( event.touches ) != "undefined" ) ? event.touches : event.changedTouches; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
614 |
setCursorPosition(touches[0].pageX); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
615 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
616 |
} : { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
617 |
mousemove: function (e) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
618 |
self.progressCursorDrag = true; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
619 |
setCursorPosition(e.pageX); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
620 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
621 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
622 |
); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
623 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
624 |
}); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
625 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
626 |
var progressBarX = $(self.progressBar).position().left; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
627 |
if (self.ipad) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
628 |
this.progressBar.on({ |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
629 |
touchdown: function(e) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
630 |
if (!self.checkPlayerIsReady()) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
631 |
return; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
632 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
633 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
634 |
e.preventDefault(); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
635 |
var touches = ( typeof( event.touches ) != "undefined" ) ? event.touches : event.changedTouches; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
636 |
PosX = touches[0].pageX - progressBarX - 8; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
637 |
PosX = setCursorPositionX(PosX); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
638 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
639 |
// Seek time |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
640 |
var jumpTime = self.popSeq.duration() * PosX / maxX; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
641 |
self.popSeq.jumpTo(jumpTime); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
642 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
643 |
}); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
644 |
} else { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
645 |
this.progressBar.on({ |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
646 |
mousedown: function(e) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
647 |
if (!self.checkPlayerIsReady()) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
648 |
return; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
649 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
650 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
651 |
PosX = e.pageX - progressBarX - 8; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
652 |
PosX = setCursorPositionX(PosX); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
653 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
654 |
// Seek time |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
655 |
var jumpTime = self.popSeq.duration() * PosX / maxX; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
656 |
self.popSeq.jumpTo(jumpTime); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
657 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
658 |
}); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
659 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
660 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
661 |
$(document).mouseup(function(){ |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
662 |
if (self.progressCursorDrag) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
663 |
self.progressCursorDrag = false; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
664 |
origineX = null; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
665 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
666 |
// Remove event |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
667 |
$(document).off(self.ipad ? "touchmove" : "mousemove"); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
668 |
|
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
669 |
// Seek time |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
670 |
var jumpTime = self.popSeq.duration() * posX / maxX; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
671 |
self.popSeq.jumpTo(jumpTime); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
672 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
673 |
}); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
674 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
675 |
|
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
676 |
this.ctrlPlay = function() |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
677 |
{ |
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
678 |
if (!this.checkPlayerIsReady()) { |
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
679 |
return; |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
680 |
} |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
681 |
|
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
682 |
if (this.getCurrentPop().paused()) { |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
683 |
// Play |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
684 |
this.popSeq.play(); |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
685 |
} else { |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
686 |
// Pause |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
687 |
this.popSeq.pause(); |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
688 |
} |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
689 |
}; |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
690 |
|
| 36 | 691 |
this.ctrlNext = function() |
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
692 |
{ |
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
693 |
if (!this.checkPlayerIsReady()) { |
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
694 |
return; |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
695 |
} |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
696 |
|
| 36 | 697 |
if (this.popSeq.active == this.sequences.length - 1) { |
698 |
// We are at the last video |
|
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
699 |
location.href = this.nextPage; |
| 36 | 700 |
return; |
701 |
} |
|
702 |
||
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
703 |
if (this.ipad) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
704 |
this.playerIsReady = false; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
705 |
this.playerWaitForBeingReady = false; |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
706 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
707 |
|
| 36 | 708 |
// Go to the next video |
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
709 |
var jumpTime = this.popSeq.durationSeqs(this.popSeq.active + 1) + 0.001; |
| 36 | 710 |
this.popSeq.jumpTo(jumpTime); |
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
711 |
}; |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
712 |
|
| 36 | 713 |
this.ctrlPrev = function() |
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
714 |
{ |
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
715 |
if (!this.checkPlayerIsReady()) { |
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
716 |
return; |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
717 |
} |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
718 |
|
| 36 | 719 |
var videoIndex = this.popSeq.active; |
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
720 |
if (videoIndex === 0) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
721 |
// We jump to the start |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
722 |
this.popSeq.jumpTo(0); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
723 |
} else { |
| 36 | 724 |
|
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
725 |
// If we are a less than 1 sec from the sequence start, we jump to the prev sequence |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
726 |
// else we jump to the start of the current sequence |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
727 |
var jumpTime = this.popSeq.durationSeqs(videoIndex); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
728 |
if (this.popSeq.currentTime() - jumpTime < 1) { |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
729 |
jumpTime = this.popSeq.durationSeqs(videoIndex-1); |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
730 |
} |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
731 |
this.popSeq.jumpTo(jumpTime + 0.001); |
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
732 |
} |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
733 |
}; |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
734 |
|
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
735 |
this.ctrlHdSd = function() |
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
736 |
{ |
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
737 |
// We swape between hd/sd |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
738 |
incChoice.setHD(this.hd ? 0 : 1); |
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
739 |
|
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
740 |
// We record the current time |
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
741 |
|
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
742 |
// Reload |
|
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
743 |
location.href = document.URL; |
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
744 |
}; |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
745 |
|
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
746 |
this.displayPlayButton = function(playIcon) |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
747 |
{ |
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
748 |
$(this.playButton).css({"background-position" : playIcon ? '-77px 0' : '-77px -17px'}); |
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
749 |
}; |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
750 |
|
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
751 |
// -------------------------------------------------------------------------------------------------------------------- |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
752 |
// Tools Functions |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
753 |
// -------------------------------------------------------------------------------------------------------------------- |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
754 |
|
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
755 |
this.logi = function(txt) |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
756 |
{ |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
757 |
if (this.logiEnable) { |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
758 |
console.log("info: " + txt); |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
759 |
} |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
760 |
}; |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
761 |
|
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
762 |
this.loge = function(txt) |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
763 |
{ |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
764 |
console.log("error: " + txt); |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
765 |
}; |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
766 |
|
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
767 |
this.loadJson = function(jsonFile) |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
768 |
{ |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
769 |
var txt = this.loadTxtFile(jsonFile); |
| 103 | 770 |
var obj = null; |
771 |
||
772 |
$.ajax({ |
|
773 |
url: jsonFile, |
|
774 |
async: false, |
|
775 |
success: function (data){ |
|
776 |
obj = data; |
|
777 |
} |
|
778 |
}); |
|
779 |
||
780 |
return obj; |
|
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
781 |
}; |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
782 |
|
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
783 |
this.loadTxtFile = function(jsonFile) |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
784 |
{ |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
785 |
var xhr = new XMLHttpRequest(); |
| 103 | 786 |
xhr.open("GET", jsonFile, false); |
787 |
if (xhr.overrideMimeType) { |
|
788 |
xhr.overrideMimeType('text/plain; charset=x-user-defined'); |
|
789 |
} |
|
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
790 |
|
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
791 |
try { |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
792 |
xhr.send(null); |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
793 |
} catch(e) { |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
794 |
return ""; |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
795 |
} |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
796 |
|
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
797 |
if (xhr.status == 404) { |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
798 |
return ""; |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
799 |
} |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
800 |
|
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
801 |
var buffer; |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
802 |
if (xhr.responseType == "arraybuffer") { |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
803 |
buffer = xhr.response; |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
804 |
} else if (xhr.mozResponseArrayBuffer === null) { |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
805 |
buffer = xhr.mozResponseArrayBuffer; |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
806 |
} else { |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
807 |
buffer = xhr.response; |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
808 |
} |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
809 |
return buffer; |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
810 |
}; |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
811 |
|
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
812 |
this.random = function(min, max) |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
813 |
{ |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
814 |
return Math.floor((Math.random()*(max-min))+min); |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
815 |
}; |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
816 |
|
| 36 | 817 |
this.secondsToTime = function(sec) |
818 |
{ |
|
819 |
var minutes = Math.floor(sec / 60); |
|
820 |
var seconds = Math.floor(sec - minutes * 60); |
|
821 |
if (seconds < 10) { |
|
822 |
seconds = "0" + seconds; |
|
823 |
} |
|
824 |
return "" + minutes + "'" + seconds + "''"; |
|
825 |
}; |
|
826 |
||
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
827 |
this.sequenceToString = function(index) |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
828 |
{ |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
829 |
return JSON.stringify(this.sequences[index]); |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
830 |
}; |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
831 |
|
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
832 |
this.getSupportedVideoExt = function() |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
833 |
{ |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
834 |
var v = document.createElement("video"); |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
835 |
|
|
78
8c3f0b94d056
big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
49
diff
changeset
|
836 |
if (v.canPlayType) { |
|
18
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
837 |
// Check for Webm support |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
838 |
if (v.canPlayType('video/webm; codecs="vp8, vorbis"') !== "") { |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
839 |
return "webm"; |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
840 |
} |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
841 |
// Check for MPEG-4 support |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
842 |
if (v.canPlayType('video/mp4; codecs="mp4v.20.8"' ) !== "") { |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
843 |
return "mp4"; |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
844 |
} |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
845 |
// Check for h264 support |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
846 |
if ((v.canPlayType('video/mp4; codecs="avc1.42E01E"' ) !== "" || v.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"'))) { |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
847 |
return "mp4"; |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
848 |
} |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
849 |
} |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
850 |
return ""; |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
851 |
}; |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
852 |
} |
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
853 |
|
|
f6232b308fbd
base du player niveau 1
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
854 |
var incPlayer = new IncPlayer(); |