Skip to main content
March 23, 2010
Answered

I need to play an mp3 file using netStream.play

  • March 23, 2010
  • 2 replies
  • 690 views

I have a "movie player" that plays flv files using the code below (videoToPlay is the name of the file to play and is just a string).  I want to use the same setup to play an mp3 file also.  I tried using mySound = new Sound(); and then mySound.attachNetStream(ns);, but it gives me this error: 1061: Call to a possibly undefined method attachNetStream through a reference with static type flash.media:Sound.

This topic has been closed for replies.
Correct answer Andrei1-bKoviI

I believe you cannot play MP3 with NetStream unless you use FMS.

If by time stamp you mean playhead position you should use SoundChannel position property and read it periodically (timer or ENTER_FRAME event):

http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/media/SoundChannel.html

2 replies

March 23, 2010

this thing cut off half my message too:

Does anyone know how to accomplish this?  Currently I use AIR to allow the user to select the file they want to play, and with the flv files it works fine, but it will not let me play mp3 files. If I use mySound.load(new URLRequest(videoToPlay)); and mySound.play(); then the mp3 file will play, but I need to be able to capture a timestamp, when a button is clicked , of the miliseconds the file is at when the button is clicked.  Using the netStream lets me do this easily for the flv files, but by playing the mp3 file without using the netStream, it does not let me capture the timestamp.  So if anyone can tell me how to play the mp3 using netStream, OR how to capture the time stamp from the mp3 file using the .load and .play methods, I would greatly appreciate it.  Thanks.

Andrei1-bKoviICorrect answer
Inspiring
March 23, 2010

I believe you cannot play MP3 with NetStream unless you use FMS.

If by time stamp you mean playhead position you should use SoundChannel position property and read it periodically (timer or ENTER_FRAME event):

http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/media/SoundChannel.html

March 23, 2010

Thanks for the response.  I was able to use the soundChannel.position to get my "timestamp".

March 23, 2010

for some reason it did not put the code in there:

myVideo = new Video();

//creating and instantiating a netConnection and netStream to attach a video to

nc = new NetConnection();

nc.connect(null);

ns = new NetStream(nc);

ns.client = this;

ns.soundTransform = videoVolume;

ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);

ns.addEventListener(NetStatusEvent.NET_STATUS, videoComplete);

              

myVideo.attachNetStream(ns);

ns.play(videoToPlay);