javascript - Audio from Icecast server not playing in Chrome -


i'm having trouble getting static content (mp3 files) served icecast server play in google chrome browser html5. reason we're serving mp3s via icecast policy: cpb requires "streamed" , not "downloaded" since we're public radio. our live audio streams play fine in chrome.

if put url mp3 served icecast 2.4.3 server straight url bar in google chrome, not play. same thing in firefox, ie, safari, etc.. plays! try it:

https://streaming.kansaspublicradio.org:8001/mp3/first_0713886.mp3

(the temporary solution i'm using flash latest update chrome (v60.0) makes flash blocked default, "always allow website" option not seem working, , little icon showing flash blocked more discrete. try here: http://kansaspublicradio.org/kpr-news/midwest-farmers-hope-boost-online-grocery-shopping )

my best guess why happening has this: https://developers.google.com/web/updates/2016/03/play-returns-promise?hl=en

so tried reproduce code example, in monkey html5 media capture audio play without user interaction. this url audio, fails play , throws error: uncaught (in promise) domexception: element has no supported sources. try it: https://jsfiddle.net/wo94xohr/2/ fails in chrome , not firefox or others.

i tried again without html5 media capture stuff. still no dice. try it: https://jsfiddle.net/yrhets74/

also, if @ response headers, see "content-range:bytes 0-0/0"... mean something?


update: i'm testing see if cors (cross origin resource sharing) issue. i've updated the jsfiddle to:

var audioelement = document.queryselector('#music'); audioelement.crossorigin = "anonymous"; // cors access restriction. worth shot no dice audioelement.type = "audio/mpeg"; // in case? idk audioelement.src = "https://streaming.kansaspublicradio.org:8001/mp3/first_0713886.mp3";  function startplayback() {   // .play() promise   return audioelement.play().then(function(x){console.log('yay!')}, function(reason){       console.log('error: ' + reason);   }); } var playbutton = document.queryselector('#play'); playbutton.addeventlistener('click', startplayback); 

it hasn't changed end result on chrome, on firefox doesn't play , gives warning: cross-origin request blocked: same origin policy disallows reading remote resource @ https://streaming.kansaspublicradio.org:8001/mp3/first_0713886.mp3. (reason: cors header ‘access-control-allow-origin’ missing).

do think icecast server needs 'access-control-allow-origin' header set 'allow' or something?

here's full response icecast server:

request url:https://streaming.kansaspublicradio.org:8001/mp3/first_0713886.mp3 request method:get status code:206 partial content remote address:129.237.213.244:8001 referrer policy:no-referrer-when-downgrade  response headers view source accept-ranges:bytes cache-control:no-cache content-length:526408 content-range:bytes 0-0/0 content-type:audio/mpeg date:tue, 15 aug 2017 19:34:23 gmt expires:mon, 26 jul 1997 05:00:00 gmt pragma:no-cache server:icecast 2.4.3  request headers view source accept:*/* accept-encoding:identity;q=1, *;q=0 accept-language:en-us,en;q=0.8,ms;q=0.6 cache-control:no-cache connection:keep-alive dnt:1 host:streaming.kansaspublicradio.org:8001 origin:https://fiddle.jshell.net pragma:no-cache range:bytes=0- referer:https://fiddle.jshell.net/_display/ user-agent:mozilla/5.0 (windows nt 6.1; win64; x64) applewebkit/537.36 (khtml, gecko) chrome/60.0.3112.90 safari/537.36 

update 2: we've added cors header access-control-allow-origin:* icecast server's response headers , jsfiddle works in firefox - no cors header ‘access-control-allow-origin’ missing warning. still not play in chrome though :(

i tested wav files , m3u files , neither play in chrome. firefox play wav file (with jsfiddle code) no m3u file

i think issue stream. here modified example streaming url:

audioelement.src = "http://novazz.ice.infomaniak.ch/novazz-128.mp3"; 

https://jsfiddle.net/yrhets74/5/

this works on machine firefox 55 , chrome 60.

vlc tells me codec used mpeg audio 1/2 (mpga).

regarding cors policy, may interested in question: domexception: failed load because no supported source found


Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -