angularjs - SHOUTcast metadata in javascript -
i'm working on front end internet radio station , they're broadcasting shoutcast stream. have audio, need simple , reliable way display metadata on page. i'm using mean stack run whole thing if has answer fits framework preferable.
here's little whipped up. uses json-p results shoutcast, can done client side without cors issues etc
function dosomething(obj) { document.getelementbyid('shout').textcontent = obj.songtitle; } var getshout = (function() { var script; return function shout(fn, sc, sid) { if (script) { document.body.removechild(script); } script = document.createelement('script'); script.src = sc + 'stats?json=1&callback=' + fn + '&sid=' + sid + '&rand=' + math.random(); document.body.appendchild(script); }; }()); document.getelementbyid('eatme').addeventlistener('click', function() { getshout('dosomething', 'http://s2.radioboss.fm:8024/', 1) });
<input id="eatme" type="button" value="press me" /> <div id="shout"></div>
Comments
Post a Comment