Skip to content

Commit

Permalink
-Added context menus for playing music files
Browse files Browse the repository at this point in the history
-Added donation page to options tabs
  • Loading branch information
khloke committed Jan 7, 2014
1 parent 2fc54cc commit b741005
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 52 deletions.
Binary file added images/address.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/bitcoin.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions js/background_scripts/background.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
chrome.extension.onMessage.addListener(
function (request, sender, sendResponse) {
switch (request.action) {
case 'isAvailable':
getXbmcJsonVersion(function (version) {
if (version == null) {
sendResponse({response: "NOT_DETECTED"});
} else {
sendResponse({response: "OK"});
}
});
break;

case 'playNow':
playCurrentUrl(function () {
sendResponse({response: "OK"});
Expand Down
51 changes: 35 additions & 16 deletions js/background_scripts/context-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,29 +81,48 @@ function removeContextMenus(tabId) {
// chrome.contextMenus onclick handlers:
var clickHandlers = {
'musicPlayNow': function(info, tab) {
doAction(actions.Stop, function () {
clearPlaylist(function () {
var url = info.linkUrl;
addItemsToPlaylist([{"contentType": 'audio', "pluginPath": url}], function(){});
})
getXbmcJsonVersion(function (version) {
if (version) {
doAction(actions.Stop, function () {
clearPlaylist(function () {
var url = info.linkUrl;
addItemsToPlaylist([
{"contentType": 'audio', "pluginPath": url}
], function () {
});
})
})
}
});
},
'musicQueue': function(info, tab) {
var url = info.linkUrl;
if (url.match(googleRedirectRegex)) {
url = parseGoogleRedirectUrl(url);
}
addItemsToPlaylist([{"contentType": 'audio', "pluginPath": url}], function(){});
},
'musicPlayNext': function(info, tab) {
getCurrentUrl(function (tabUrl) {
getPlaylistPosition(function (position) {
getXbmcJsonVersion(function (version) {
if (version) {
var url = info.linkUrl;
if (url.match(googleRedirectRegex)) {
url = parseGoogleRedirectUrl(url);
}
insertItemToPlaylist('audio', url, position+1, function() {});
});
addItemsToPlaylist([
{"contentType": 'audio', "pluginPath": url}
], function () {
});
}
});
},
'musicPlayNext': function(info, tab) {
getXbmcJsonVersion(function (version) {
if (version) {
getCurrentUrl(function (tabUrl) {
getPlaylistPosition(function (position) {
var url = info.linkUrl;
if (url.match(googleRedirectRegex)) {
url = parseGoogleRedirectUrl(url);
}
insertItemToPlaylist('audio', url, position + 1, function () {
});
});
});
}
});
}
};
Expand Down
45 changes: 29 additions & 16 deletions js/content_scripts/context-menu-content-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,32 @@ function concatMusicExtensions() {
return concatSelector;
}

addContextMenuTo(concatMusicExtensions(),
[{
title: "Play now",
contexts: ["link"],
onclick: 'musicPlayNow'
},{
title: "Queue",
contexts: ["link"],
onclick: 'musicPlayNow'
},{
title: "Play this Next",
contexts: ["link"],
onclick: 'musicPlayNow'
}]
);
//addContextM
//function checkConnectivity(callback) {
// chrome.extension.sendMessage({action: 'isAvailable'}, function (response) {
// if (response.response == 'OK') {
// callback(true);
// } else {
// callback(false);
// }
// });
//}
//
//checkConnectivity(function(isAvailable) {
// if (isAvailable) {
// addContextMenuTo(concatMusicExtensions(),
// [{
// title: "Play now",
// contexts: ["link"],
// onclick: 'musicPlayNow'
// },{
// title: "Queue",
// contexts: ["link"],
// onclick: 'musicPlayNow'
// },{
// title: "Play this Next",
// contexts: ["link"],
// onclick: 'musicPlayNow'
// }]
// );
// }
//});
20 changes: 0 additions & 20 deletions js/content_scripts/soundcloud-content-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,27 +53,7 @@ function getSoundcloudSetTrackIds(setId, callback) {

callback(trackIds);
}
// $.each(result.tracks, function (i, item) {
// trackIds.push(item.id);
// });
});

// jQuery.ajax({
// type: 'POST',
// url: apiUrl,
// success: function (result) {
// if (result && result.tracks) {
// var tracksJson = result.tracks;
// for (var i in tracksJson) {
// if (tracksJson.hasOwnProperty(i)) {
// trackIds.push(tracksJson[i].id);
// }
// }
//
// callback(trackIds);
// }
// }
// });
}

var trackIds = [];
16 changes: 16 additions & 0 deletions options.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<li class="active"><a href="#xbmcHost" data-toggle="tab">XBMC Host(s)</a></li>
<li><a href="#general" data-toggle="tab">Others</a></li>
<li><a href="#changelist" data-toggle="tab">Changelist</a></li>
<li><a href="#donate" data-toggle="tab">Donate</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="xbmcHost">
Expand Down Expand Up @@ -86,6 +87,15 @@
</div>
<div class="tab-pane" id="changelist">
<div style="margin: 0 25px">
<p>
<strong>Update 1.5.0.0:</strong>
<ul>
<li>Added context menus to show images on XBMC (Beta). This feature on XBMC is a little unstable and images like Gif is not supported.</li>
<li>Added context menus to play and queue direct links to music files. Supported extensions are: 'mp3', 'ogg', 'midi', 'wav', 'aiff', 'aac', 'flac', 'ape' and 'wma'.</li>
<li>Added support for MyCloudPlayers.com (Many thanks to cuckoo for the code work).</li>
<li>Added a donation page to the option tabs. If you like my work, consider buying me a coffee so I could spend more hours awake working on Play to XBMC.</li>
</ul>
</p>
<p>
<strong>Update 1.4.3.0:</strong>
<ul>
Expand Down Expand Up @@ -190,6 +200,12 @@
</p>
</div>
</div>
<div class="tab-pane" id="donate" style="text-align: center">
<div>If you like what I did and would like to buy me a coffee, <br/>you can send me some bitcoins to the address below!</div>
<div><img src="images/bitcoin.png"><img src="images/address.png"/></div>
<div>1GcpoegwrJv7VBw51JCbbmiY6oun7kcn9c</div>
<div>You can also donate to my PayPal account: khloke@gmail.com!</div>
</div>
</div>
</div>
<div class="control-group" style="border-top: #e5e5e5 solid 1px; ">
Expand Down

0 comments on commit b741005

Please sign in to comment.