Skip to content

Commit

Permalink
Fully working support for queue
Browse files Browse the repository at this point in the history
  • Loading branch information
vincelwt committed Dec 16, 2015
1 parent 00be999 commit 4374dec
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 22 deletions.
18 changes: 10 additions & 8 deletions ChromeExtension/js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ function stopNote() {
chrome.notifications.clear('notif', function(id) { console.log("Last error:", chrome.runtime.lastError); });
}

function notif(msg) {
function notif(title, msg) {
var opt = {
type: "basic",
title: "Raspberry Pi",
title: title,
message: msg,
iconUrl: "48.png"
};
Expand All @@ -20,19 +20,21 @@ function mkrequest(url, response) {
try {
var newURL = "http://"+localStorage.getItem('raspip')+":2020"+url;
if (response == 1) {
notif("Trying to get video stream URL. Please wait ~ 10 seconds.");
notif("RaspberryCast", "Processing video. Please wait ~ 10 seconds.");
}
var req = new XMLHttpRequest();
req.open('GET', newURL, true);
req.onreadystatechange = function (aEvt) {
if (req.readyState == 4) {
if (req.status == 200) {
if (req.responseText == "1") {
if (response == 1) {
notif("Success ! Video should now be playing.");
if (response == 1) {
if (req.responseText == "1") {
notif("RaspberryCast", "Video should now start playing.");
} else if (req.responseText == "2") {
notif("RaspberryCast", "Video has been added to queue.");
} else {
notif("Error", "Please make sure the link is compatible");
}
} else {
notif("An error occured during the treatment of the link. Please make sure the link is compatible");
}
} else {
chrome.notifications.clear('notif', function(id) { console.log("Last error:", chrome.runtime.lastError); });
Expand Down
7 changes: 4 additions & 3 deletions ChromeExtension/js/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ function handlers() {
var url_encoded = encodeURIComponent(tabs[0].url);
chrome.extension.getBackgroundPage().mkrequest("/stream?url=" + url_encoded + "&slow="+localStorage.modeslow, 1);
});
window.close();
});

$( "#addqueue" ).click(function() {
chrome.tabs.query({currentWindow: true, active: true}, function(tabs){
var url_encoded = encodeURIComponent(tabs[0].url);
chrome.extension.getBackgroundPage().mkrequest("/queue?url="+url_encoded + "&slow="+localStorage.modeslow, 0);
chrome.extension.getBackgroundPage().mkrequest("/queue?url="+url_encoded + "&slow="+localStorage.modeslow, 1);
});

window.close();
});

$( "#pause" ).click(function() {
Expand All @@ -22,6 +22,7 @@ function handlers() {

$( "#stop" ).click(function() {
chrome.extension.getBackgroundPage().mkrequest("/video?control=stop", 0);
window.close();
});

$( "#backward" ).click(function() {
Expand Down
2 changes: 1 addition & 1 deletion ChromeExtension/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
"manifest_version": 2,
"name": "RaspberryCast",
"permissions": [ "contextMenus", "tabs", "notifications" ],
"version": "1.2.2"
"version": "1.3.0"
}
18 changes: 9 additions & 9 deletions FirefoxExtension/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,21 +89,21 @@ cm.Item({
});

function mkrequest(url) {
if (url.indexOf("/stream") > -1) {
notifications.notify({ title: "Processing media", text: "Please wait ~10 seconds." });
if (url.indexOf("/stream") > -1 || url.indexOf("/queue") > -1) {
notifications.notify({ title: "RaspberryCast", text: "Processing video. Please wait ~10 seconds." });
}

Request({
url: "http://"+prefs.raspIp+":2020" + url,
onComplete: function (response) {
if (response.text == "1") {
if (url.indexOf("/stream") > -1) {
notifications.notify({ title: "Success !", text: "Video should start playing." });
} else if (url.indexOf("/queue") > -1) {
notifications.notify({ title: "Success !", text: "Video has been added to queue." });
if (url.indexOf("/stream") > -1 || url.indexOf("/queue") > -1) {
if (response.text == "1") {
notifications.notify({ title: "RaspberryCast", text: "Video should start playing." });
} else if (response.text == "2") {
notifications.notify({ title: "RaspberryCast", text: "Video has been added to queue." });
} else {
notifications.notify({ title: "RaspberryCast", text: "An error occured during the request." });
}
} else {
notifications.notify({ title: "RaspberryCast", text: "An error occured during the request." });
}
}
}).get();
Expand Down
2 changes: 1 addition & 1 deletion FirefoxExtension/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"title": "RaspberryCast",
"name": "raspberrycast",
"version": "1.0.2",
"version": "1.2.0",
"description": "Firefox add-on for RaspberryCast",
"main": "index.js",
"author": "VinceLwt",
Expand Down

0 comments on commit 4374dec

Please sign in to comment.