在Chrome扩展运行的Shoutcast的电台 [英] running a shoutcast radio in a chrome extension
问题描述
我要创建我的互联网Shoutcast的网络电台一个Chrome扩展。
i want to create a chrome extension for my internet shoutcast internet radio station.
我设法让所有的工作,但每当我从弹出,关闭点击即可,并且流与它停止。
i managed to make it all work, except that whenever i click away from the popup, it closes, and the stream stops with it.
读一点我看到了,我需要创建一个背景页后,即会在后台将玩家运行。
after reading a little i saw that i need to create a background page, that will make the player run in the background.
多数民众赞成在我迷路和困惑。
thats where i got lost and confused.
如何让我流保持均匀的工作,如果我没有弹出打开?
how do i make the stream keep working even if i dont have the popup open?
再 - 继承人如何去:
当你点击扩展它打开,我的播放器显示出来(在iframe Flash播放器)。我点击播放,它完美的作品。当我想继续浏览网页,我点击页面中的IM和它关闭的延伸和停止音乐。
again - heres how it goes: when you click on the extension it opens, and my player shows up (a flash player in an iframe). i click Play and it works perfectly. when i wanna keep surfing the web, i click on the page im in and it closes the extension and stops the music.
这里有我的文件
manifest.json的:
here are my files manifest.json:
{
"name": "JointRadio",
"version": "1.0",
"manifest_version": 2,
"description": "Online Radio Station",
"background_page": "background.js",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"permissions": ["tabs"],
}
popup.html:
popup.html:
<!doctype html>
<html>
<head>
<title>Getting Started Extension's Popup</title>
<style>
body {
min-width:357px;
overflow-x:hidden;
}
img {
margin:5px;
border:2px solid black;
vertical-align:middle;
width:75px;
height:75px;
}
#mainplayer {
}
</style>
<!-- JavaScript and HTML must be in separate files for security. -->
<script src="popup.js">
</head>
<body>
<iframe width="460" border=0 height="130" src="http://jointil.com/broadcast/flexAmp.swf" frameborder=0 marginheight=0 marginwidth=0 id="mainplayer"></iframe>
</body>
</html>
在此先感谢! :)
亚当
Thanks in advance!! :) adam
推荐答案
我发现了一个方法,使即使弹出关闭流打法,但问题是,玩家不会在弹出显示...
我在background.js
I found a way to make the stream play even if the popup is closed, but the problem is that the player doesn't display in the popup... I added this code in "background.js"
var audioElement = document.createElement('audio');
audioElement.setAttribute('src', 'http://85.25.118.16:7502/;');
audioElement.setAttribute('controls', true);
audioElement.setAttribute('hidden', false);
audioElement.play();
2 - manifest.json的:
2 - manifest.json:
{
"name": "Kombat Syndicate Radio Extension",
"version": "1.0",
"manifest_version": 2,
"description": "Kombat Syndicate Radio",
"background": {
"persistent": true,
"scripts": ["background.js"]
},
"browser_action": {
"default_icon": "icon.png",
"19": "icons/icon.png",
"128": "icons/icon_128.png",
"default_popup": "ksradio.html"
},
"permissions": ["tabs", "http://*/*", "background"]
}
如果我找出如何显示在弹出我会告诉你的球员。而如果你发现如何在我面前显示出来,那么请告诉我:P
If I find out how to display the player in the popup I'll tell you.. And if you find how to display it before me, then please tell me :P
我注意到,在你的popup.html中的&LT;脚本SRC =popup.js&GT;
是不正确的,添加&LT; / SCRIPT&GT;
后,&LT; SCRIPT SRC =popup.js&GT;
所以你必须&LT;脚本SRC =popup.js&GT;&LT; / SCRIPT&GT;
I noticed that in your "popup.html" the "<script src="popup.js">
" isn't correct, add "</script>
" after "<script src="popup.js">
" so you'll have "<script src="popup.js"></script>
"
这篇关于在Chrome扩展运行的Shoutcast的电台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!