Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The play/pause and source text has been replaced by icons (thanks to P.J. Onori and BrandSpankingNew for those). Now the track and last position is saved so one can resume the audio at a later date. Also made the interface a little more robust and cleaner.
- Loading branch information
Dan Brook
committed
Jun 6, 2010
1 parent
23c4ef0
commit e51ca2d
Showing
12 changed files
with
126 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,10 @@ | ||
<html> | ||
<body> | ||
<!-- Empty element so popup.html has something to hang off of even -- | ||
-- when an audio source hasn't been selected. --> | ||
<audio src="" id="bgm"></audio> | ||
|
||
<script src="jquery.min.js"></script> | ||
<script> | ||
chrome.extension.onRequest.addListener(function(request, sender, sendResponse) { | ||
var snd = request.audioSrc, | ||
bgm = $('#bgm').remove(); | ||
|
||
// Recreate the audio element so we can switch tracks. | ||
bgm = $('<audio src="" id="bgm"></audio>').get(0); | ||
bgm.src = snd; | ||
bgm.play(); | ||
|
||
document.body.appendChild(bgm); | ||
|
||
localStorage.setItem('origUrl', sender.tab.url); | ||
|
||
var notification = webkitNotifications.createNotification( | ||
'icon_128.png', 'Queued to play:', | ||
(snd.match(/\/([^/]+)$/))[1] | ||
); | ||
notification.show(); | ||
}); | ||
</script> | ||
<script src="background.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
chrome.extension.onRequest.addListener(function(request, sender, sendResponse) { | ||
var snd = request.audioSrc, | ||
bgm = $('#bgm').remove(); | ||
|
||
// Recreate the audio element so we can switch tracks. | ||
bgm = $('<audio src="" id="bgm"></audio>').get(0); | ||
bgm.src = snd; | ||
bgm.play(); | ||
|
||
document.body.appendChild(bgm); | ||
|
||
localStorage.setItem('origUrl', sender.tab.url); | ||
localStorage.setItem('origSrc', snd); | ||
|
||
var notification = webkitNotifications.createNotification( | ||
'icons/icon_128.png', 'About to play', | ||
(snd.match(/\/([^/]+)$/))[1] | ||
); | ||
notification.show(); | ||
}); | ||
|
||
$(function() { | ||
// Load up the last piece of audio if available. | ||
var snd = localStorage.getItem('origSrc'); | ||
if(!snd) | ||
return; | ||
|
||
var bgm = $('#bgm').get(0); | ||
bgm.src = snd; | ||
bgm.load(); | ||
|
||
var pos = localStorage.getItem('origPos'); | ||
if(pos) | ||
// Only set the track position when it's valid to. | ||
$(bgm).bind('loadedmetadata', function() { this.currentTime = pos }); | ||
}); |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters