Search code examples
javascriptjwplayerm3u

jwplayer streaming m3u from another domain


Looking to stream a radio station on my website, we also host the streaming but from a different domain. Just getting this error:

Task Queue failed at step 5: Playlist could not be loaded due to crossdomain policy restrictions

Code on domain A:

    <div id="mediaplayer">Loading...</div>
<script type="text/javascript" src="/jwplayer/jwplayer.js"></script>
<script type="text/javascript">
    jwplayer("mediaplayer").setup({
        flashplayer: "/jwplayer/player.swf",
        playlistfile: "http://domainB/stream.m3u",
        image: "/images/listening.jpg",
        type: "sound",
        allowscriptaccess:"always",
        width:300,
        height:300
    });
</script>

Just having no luck, tried a variety of options... Am I wasting my time with out crossdomain.xml on domain B ? (of which I have no access to at the moment, but maybe able to get access to soon)

The stream works fine from itunes, winamp etc..


Solution

  • Okay, the problem was: The url for the m3u file isn't the actual url for the stream. I needed to open the m3u file in a text editor, and use that url, which included port etc.

    <script type='text/javascript' src='/jwplayer/jwplayer.js'></script>
    <div id='media'></div>
    <script type='text/javascript'>
      jwplayer('media').setup({
        'flashplayer': '/jwplayer/player.swf',
        'file': 'http://xx.xxxxxx.xxx:80/xxxxfm',
        'provider': 'sound',
        'controlbar': 'bottom',
        'image': "/images/listening.jpg",
        'width': '300',
        'height': '300'
      });
    </script>
    

    this code seems to work, no crossdomain.xml needed, it was requesting one only because the url was incorrect.