views:

61

answers:

3

My flex 3.5 application has an audio player whose content is accessed by calling an AMF service to get the mp3 data. As far as I can tell, flash.media.Sound is initialized with a URLRequest, so it's not clear to me how I can provide it with data using my RemoteObject.

I want to do one of the following things:

  1. Provide data to the Sound object's load method from a RemoteObject service call.
  2. Create a URLRequest object that will perform the requisite AMF wrapping so that my service implementation will look exactly like any other service call if at all possible.
  3. Any alternative that allows me to invoke a PHP4 AMF service and play the audio it returns in a Flash audio player.
A: 

Why not use the Sound object with a URL parameter?

No need to write code to manually retrieve your URL. If you prefer to do some back end processing before returning the file, you can just set the return mimetype and 'dump' the data bytes of the mp3 file into the output stream.

With ColdFusion, this is easy using the cfcontent tag. I assume PHP offers some parallel, however I don't know what it is.

www.Flextras.com
Right. That's exactly the approach I describe as not being quite what I want. For the sake of argument, let's just say that I require -- if not an actual AMF call -- a substantial amount of other POST data to get this.
Chris R
Nowhere in your original post did I get the impression that that this approach would be "not quite right". Perhaps I'm misunderstanding. If you need to a post, one solution would be to do the psot using HTTPService and return the mp3 URL. An alternate solution may be to turn the "post" values into URL Variables and use the Sound object as is.
www.Flextras.com
+1  A: 

If you absolutely have to use AMF to serve the sound, you have 2 options. The first is to wrap the MP3 in a swf, send it back as a ByteArray and use the loadBytes method on Loader to load it back in. The second option is to convert it to a wav, send it as a ByteArray, and then parse the audio file and feed the data to a sound using the sampleData event (Flash Player 10 only). I would probably recommend the first option, as it's a lot easier and faster than the second, but both aren't particularly easy.

If I had to authenticate through AMF to load sound, I would return a session cookie of some type and set up a simple PHP service that would serve MP3s with the proper session cookie.

warhammerkid
+1  A: 

You need to load the Sound from a ByteArray which is done here:

http://www.flexiblefactory.co.uk/flexible/?p=46

Matt