A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: sound name from soundChannel

  1. #1
    Junior Member
    Join Date
    Dec 2008
    Posts
    11

    sound name from soundChannel

    Hi,
    I wondered if there is a way to find out from the soundChannel the url of the sound it is currently playing.

    Once I found out its url, i can than use its name to call something else.

    Or anyway to find out the sound that is playing on a soundChannel.

    I will know which channel to look into, but different sound will be loaded into this soundChannel....

    If this is not possible, i thinking along the line of overloading SoundChannel play method so that is fires an event when the sondchannel plays and also find out the name of the sound file it is currently playing...

    thanks!

  2. #2
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    The soundChannel is seperated from the Sound object that creates it so you'd need to manage the connection yourself. Personally, I'd set it up as a Dictionary lookup:

    PHP Code:
    var s:Sound = new Sound( new URLRequest('a.mp3') );
    var 
    t:Sound = new Sound( new URLRequest('b.mp3') );
    var 
    SOUND_BY_CHANNEL:Dictionary = new Dictionary();

    //  ...

    var chan:SoundChannel s.play();
    SOUND_BY_CHANNEL[chan] = s;

    //  ...

    traceSOUND_BY_CHANNEL[chan] );  //  s 

  3. #3
    Junior Member
    Join Date
    Dec 2008
    Posts
    11
    Thanks neznein9.

    I see where you getting at. However it seems the same effort to your method equals the current solution I have.

    What is happening in my case is that I've been passed an .fla file that has many audios that plays via one sound channel. I'm supposed to close caption these audios. I load the captions from an xml file externally and things work just great. I had to go in and identify where a the audio (loaded externally) is about to play and I paste the code to start a piece of caption. (I wrote a function that will listen to the channel for the channels position not equal zero, than fires a sequence of events that fires the close captions. Works beautifully.) But I'm trying to save me going all over the place looking for where the sound starts to then paste a call to my function. All sounds are already loaded in the first frame and they all have their own variables. They then get loaded one by one when needed into the soundChannel. So what I'm attempting to do is to just listen to this particular sound channel (if I can), and detect which sound it is about to play, or is loading...then I can fire off its appropriate caption.

    I'm not certain if a dictionary would work like neznein9 has pointed out.

    Any other thoughts or suggestions?

    Thanks!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center