0

Please open this url in browser it worked (http://yp.shoutcast.com//sbin/tunein-station.m3u?id=914897) . but it's not working when I'm going to play it in html5 audio tag. please give me suggestion how can i stream from this url using jquery, javascript. because I want to stream it in on Android and IOS devices using Sencha touch. My code is

  • m3u is a playlist for me on Xubuntu It's open in audo player not in the browser. – jcubic Mar 27 '15 at 13:57
  • Thanks for you comment. Well what should i do in this case. – Atif Gulzar Mar 27 '15 at 14:43
  • You need to load the file and then use urls in the file in audio tag. You can use `ended` event to load next file. – jcubic Mar 27 '15 at 16:33
  • @jcubic can you please guide me how can I read/parse that file using Javascript. I got failure when i try to make ajax on this [URL](http://yp.shoutcast.com/sbin/tunein-station.pls?id=175821) – Atif Gulzar Dec 31 '15 at 04:26
  • If it's not on your server and it don't enabled CORS then you will need to create server side proxy to read the file. – jcubic Dec 31 '15 at 08:41

1 Answers1

0

That URL is for an M3U which is a playlist file, not an audio file. You need to load the playlist and then playback one of its entries:

http://69.46.88.21:80
Brad
  • 159,648
  • 54
  • 349
  • 530
  • you are right Can you please guide me how can I read that file using Javascript [URL](http://yp.shoutcast.com/sbin/tunein-station.pls?id=175821) is this that i need to parse – Atif Gulzar Dec 31 '15 at 04:21
  • @AtifGulzar Assuming you can load the file (due to cross-origin issues and what not), just read it line-by-line and pick which URLs you want. The file isn't complicated. Open it with your text editor to see what I mean. – Brad Dec 31 '15 at 04:22
  • I'm developing an APP so when user come to app for streaming, I won't manually read that file for them. so I need to parse that file using javascript in my code and grab that url for streaming. But the main thing I won't know how can i parse it using javascript, I got failure when i try to make ajax request on that [URL](http://yp.shoutcast.com/sbin/tunein-station.pls?id=175821) – Atif Gulzar Dec 31 '15 at 04:38
  • Please have look on this guy [Answer](http://stackoverflow.com/questions/18652583/play-from-shoutcast-url-in-android) – Atif Gulzar Dec 31 '15 at 04:41
  • @AtifGulzar I can't help you if you can't elaborate on what the failure is. It's probably a cross-origin issue, like I said. The only way you're getting around that is via a server-side proxy. – Brad Dec 31 '15 at 04:44
  • Let me explain you with screenshots what I'm doing image [1](http://postimg.org/image/tz1tsdxf3/) is about my ajax request (Ext.JS) image [2](http://postimg.org/image/4obdzmx5j/) is about how server treat my request which seems accepted ( no cross domain issue ) image [3](http://postimg.org/image/8bxkoz0sr/) is the error i got on console image [4](http://postimg.org/image/bqmp18x41/) is when i click on error link on console, this image shows that the issue is on formatting the response of the server not with my coding – Atif Gulzar Dec 31 '15 at 05:01
  • @AtifGulzar You're trying to load an M3U via JSON-P, which isn't possible without a server that will cooperate with you (and SHOUTcast's YP won't). By doing this, you're effectively adding a ` – Brad Dec 31 '15 at 05:05
  • Ah Man, my bad, I got it, you mean i need to do these steps on my server side parse that file there and then retrieve the correct url into mobile app from my server side? – Atif Gulzar Dec 31 '15 at 05:09
  • @AtifGulzar No, you can parse the format in JavaScript if you want. You just need to get that data to your JavaScript somehow, and that's not going to work because of cross-origin restrictions. To get around that, a simple proxy on your origin will work. – Brad Dec 31 '15 at 05:10
  • Sorry to say you Actually I'm new in programing Could you please give me the code explain that how can i parse that using javascript. Thanks in Advance – Atif Gulzar Dec 31 '15 at 05:26
  • @AtifGulzar I don't know what languages and stack you're using server-side, so there's no code to give. Search StackOverflow for CORS or cross-origin proxy to start with, then search for how to split text on lines. I've told you step by step what you need to do. I can't write all of the code for you or you wouldn't learn much from it. – Brad Dec 31 '15 at 05:28
  • :) No problem I can write it by my self. Thanks for your time Buddy – Atif Gulzar Dec 31 '15 at 05:38