Search code examples
rtmpamazon-cloudfrontsoundmanager2

Amazon Cloudfront RTMP Strings with SoundManager2


I'm working on a web application that is using SoundManager2. After beating my head against a wall and not getting my music to stream, I finally switched some of my URL's when creating a new SoundManager sound.

This is what I was using before and although it would connect, the stream would never play.

soundManager.createSound({
    id: 'songId_1',
    serverURL: 'rtmp://s3s5uvbmfjq6k1.cloudfront.net:1935/cfx/st', 
    url: 'hihi.m4a',
    onconnect: function(connected){
        alert(connected);
    }
});

Once I changed it to this however, it all of a sudden was able to stream.

soundManager.createSound({
     id:'test3',
     serverURL:'rtmp://s3s5uvbmfjq6k1.cloudfront.net:1935/cfx/st',
     url:'mp4:hihi.m4a'
});

I don't understand why the first one does not work and the second one does. I don't have a problem with the serverURL being hardcoded but the url is dynamic and can be any number of audio formats, so having to convert that to a valid value that will stream doesn't make sense to me unless there is an API to do so (I didn't see one in Cloudfront). Is there a way to convert

song location/song name.ext

into it's correct url for streaming or do I need to use a different player?


Solution

  • We have this trouble a while ago, and ended up with hard-coded url for each of the format. We are using Flowplayer another flash player, and dealing both with CloudFront and EdgeCast two streaming providers, and you will find out that even there is a slight difference between the format they support for certain video types.

    You can refer to the question Why RTMP streaming protocal's url path different from each other? I asked before.

    I haven't found any tool to convert it since this is rather relying on the streaming providers and there is no standard at this stage.

    When we deal with mp4, flv, mp3, the constructed url are: (Be careful of both prefix and extension)

    mp4:test.mp4
    flv:test
    mp3:test