← Back to team overview

olrait team mailing list archive

Patch per play all

 

Ho realizzato una patch che implementa la funzionalità di "Play all", che riproduce in sequenza tutti i clip dopo aver scelto il bitrate da usare, che trovate allegata. (nella patch troverete anche alcuni messaggi di diagnostica che ho aggiunto/modificato).
Spero che qualcuno possa trovarla utile.
Ogni commento/suggerimento in proposito è ben accetto.
Ciao
Davide

diff -Naur raismth@mitm.rc_orig/chrome/content/raismth/engine.js raismth@xxxxxxx/chrome/content/raismth/engine.js
--- raismth@mitm.rc_orig/chrome/content/raismth/engine.js	2012-09-10 22:59:08.000000000 +0200
+++ raismth@xxxxxxx/chrome/content/raismth/engine.js	2012-09-29 16:38:42.461375900 +0200
@@ -116,9 +116,12 @@
                                 v_payload = ret[2];
                         } 
 			raismth.chunks[indice]++;
-			if(raismth.chunks[indice] > 5 && raismth.chunks[indice] % 10 == 0) stDump('[RAISMTH] Chunk [' + raismth.chunks[indice] + ']\n', indice);
+			// stampa lunghezza del clip
+			let clip_length = raismth.video_chunks[indice][clip].length;
+			if(raismth.chunks[indice] > 5 && raismth.chunks[indice] % 10 == 0)
+				stDump('[RAISMTH] Chunk [' + raismth.chunks[indice] + '/' + clip_length + ']\n', indice);
 
-	                if(args[2] == raismth.video_chunks[indice][clip][raismth.video_chunks[indice][clip].length-1]) {
+			if(args[2] == raismth.video_chunks[indice][clip][clip_length-1]) {
 				if(raismth.stream_url[indice][clip].indexOf('live') == -1) stop = true;
 			}
 
@@ -138,7 +141,8 @@
 				raismth.chunks[indice] = 0;
 				raismth.sem = false;
 				raismth.smthsem[indice] = false;
-				myDump('[RAISMTH] End Of Stream [' + indice + ']\n');				
+				// stampa messaggio di fine clip
+				stDump('[RAISMTH] End Of Stream [' + indice + ']\n');				
 			}
 		
 			raismth.engine.log(indice, v_url, a_url, v_next, a_next, v_payload, a_payload);
diff -Naur raismth@mitm.rc_orig/chrome/content/raismth/globals.js raismth@xxxxxxx/chrome/content/raismth/globals.js
--- raismth@mitm.rc_orig/chrome/content/raismth/globals.js	2012-06-22 23:30:12.000000000 +0200
+++ raismth@xxxxxxx/chrome/content/raismth/globals.js	2012-09-29 16:39:33.961376455 +0200
@@ -63,5 +63,7 @@
 theApp.stream_url = new Array();
 theApp.stream_index = new Array();
 theApp.grabber_start_time = new Array();
+theApp.playQueue = new Array(); 
+theApp.playQueueIdx = new Array(); 
 
 }});
diff -Naur raismth@mitm.rc_orig/chrome/content/raismth/main.js raismth@xxxxxxx/chrome/content/raismth/main.js
--- raismth@mitm.rc_orig/chrome/content/raismth/main.js	2012-06-22 23:41:52.000000000 +0200
+++ raismth@xxxxxxx/chrome/content/raismth/main.js	2012-09-29 16:37:58.989375433 +0200
@@ -33,6 +33,29 @@
 myDump("[RAISMTH] main module initialization\n");
 
 theApp.main = {
+		// funzione per riprodurre il prossimo clip nella coda
+		playNextQueued : function(indice)
+		{
+			if (raismth.playQueueIdx[indice] == -1 || raismth.playQueue[indice].length == 0 || raismth.playQueueIdx[indice] >= raismth.playQueue[indice].length)
+			{
+				raismth.playQueueIdx[indice] = -1;
+				return;
+			}
+			
+			let i = raismth.playQueueIdx[indice];
+			raismth.playQueueIdx[indice]++;
+			
+			let clip = raismth.playQueue[indice][i].clip;
+			let ql = raismth.playQueue[indice][i].ql;
+			
+			let video_chunk = raismth.video_chunks[indice][clip][0];
+			let audio_chunk = raismth.audio_chunks[indice][clip][0];
+			let url = raismth.stream_url[indice][clip];
+			let windowid = raismth.rai_windows_ts[indice];
+			let doc = raismth.rai_windows[indice];
+			raismth.main.main_loop(url, [video_chunk, audio_chunk, indice, clip, ql], 6, windowid);
+		},
+		
         main_loop : function(url,ttauth,action,id,vc1) {
 		let indice = raismth.utils.arrayIndexOf(raismth.rai_windows_ts, parseInt(id));
 		myDump('[RAISMTH] main loop entry indice:' + indice + ' action:' + action + ' ts:' + id + '\n');
diff -Naur raismth@mitm.rc_orig/chrome/content/raismth/player.js raismth@xxxxxxx/chrome/content/raismth/player.js
--- raismth@mitm.rc_orig/chrome/content/raismth/player.js	2012-09-10 23:00:06.000000000 +0200
+++ raismth@xxxxxxx/chrome/content/raismth/player.js	2012-09-29 16:38:14.721375602 +0200
@@ -148,7 +148,9 @@
 			if(raismth.player_istances[c] && !raismth.player_istances[c].isRunning && raismth.player_istances_pid[c] != null) {
 				pid = raismth.player_istances_pid[c];
 				let chan_index = c;
-				stDump('[RAISMTH] Player Stop/EOF pid:' + pid + ' c:' + c + '\n', c);
+				// valuta la condizione di fine clip (vedi engine.js grabber)
+				let clipFinished = (raismth.chunks[chan_index] == 0 && !raismth.smthsem[chan_index]);
+				stDump('[RAISMTH] Player Stop/EOF pid:' + pid + ' c:' + c + ', ' + (clipFinished ? 'END OF CLIP' : 'ERROR') + '\n', c);
 				raismth.rai_active_channels[chan_index] = null;
 				raismth.chunks[chan_index] = null;
 				raismth.player_istances[chan_index] = null;
@@ -157,6 +159,13 @@
 				raismth.grabber_start_time[chan_index] = null;
 
 				raismth.utils.clean_temp_files(pid);
+				
+				// se è attiva la coda di riproduzione di 'play all', lancia il prossimo filmato tra 2s
+				if (theApp.playQueueIdx[chan_index] != -1)
+				{
+					let t = Components.classes["@mozilla.org/timer;1"].createInstance(Components.interfaces.nsITimer);
+					t.initWithCallback(function() { raismth.main.playNextQueued(chan_index); }, 2000, Components.interfaces.nsITimer.TYPE_ONE_SHOT);
+				}
 				break;
 			}
 		}
diff -Naur raismth@mitm.rc_orig/chrome/content/raismth/rai.js raismth@xxxxxxx/chrome/content/raismth/rai.js
--- raismth@mitm.rc_orig/chrome/content/raismth/rai.js	2012-07-30 22:28:30.000000000 +0200
+++ raismth@xxxxxxx/chrome/content/raismth/rai.js	2012-09-29 16:39:14.589376245 +0200
@@ -31,6 +31,29 @@
 		div.appendChild(testo);
 		ancora.appendChild(div);
 
+		// creazione bottone di play all e combo con i bitrate
+		let btnPlayAll = doc.createElement("button");
+		btnPlayAll.setAttribute('style', 'font-size:12px');
+		btnPlayAll.appendChild(doc.createTextNode("Play all"));
+		ancora.appendChild(btnPlayAll);
+		btnPlayAll.addEventListener("click", function (event) {
+				// recupera il valore di bitrate scelto dalla select e lo mette su tutti i clip della coda
+				let ql = parseInt(window.content.document.getElementById('playAll_ql').value);
+				for (let i = 0; i < raismth.playQueue[indice].length; i++)
+					raismth.playQueue[indice][i].ql = ql;
+					
+				raismth.playQueueIdx[indice] = 0;
+				raismth.main.playNextQueued(indice);
+			}, false);
+		
+		let selBitrate = doc.createElement("select");
+		selBitrate.setAttribute("id", "playAll_ql");
+		selBitrate.setAttribute('style', 'font-size:12px');
+		ancora.appendChild(selBitrate);
+
+		raismth.playQueue[indice] = []
+		raismth.playQueueIdx[indice] = -1;
+		
 		div = doc.createElement("div");
 		div.setAttribute('align', 'left');
 		div.setAttribute('style', 'font-weight:bold;font-size:12px;color:white');
@@ -61,7 +84,18 @@
 				let v = 2 * d;
 				let a = v + 1;
 				for(let k = 0; k < raismth.stream_index[indice][v].length; k++) {
-					text = ' | ' + raismth.utils.pad(parseInt(raismth.stream_index[indice][v][k][1])/1000, 0) + 'k';
+					let bitrate = parseInt(raismth.stream_index[indice][v][k][1])/1000;
+					
+					// sul primo clip aggiunge le voci alla select del playall
+					if (e == 1)
+					{
+						let opt = doc.createElement("option");
+						opt.value = k
+						opt.appendChild(doc.createTextNode(bitrate + "k"));
+						selBitrate.appendChild(opt);
+					}
+					
+					text = ' | ' + raismth.utils.pad(bitrate, 0) + 'k';
 					testo = doc.createTextNode(text);
 					div.appendChild(testo);
 					radio = doc.createElement("input");
@@ -89,6 +123,9 @@
 							}, false);
 
 				}
+				// aggiunge in coda l'indice del clip, la qualità sarà valorizzata dopo
+				raismth.playQueue[indice].push( {clip: d, ql: -1} );
+				
 				ancora.appendChild(div);
 	                        div = doc.createElement("div");
 				div.setAttribute('align', 'left');