?
Solved

Dynamically loading and playing external .mp3 files

Posted on 2003-11-13
3
Medium Priority
?
954 Views
Last Modified: 2011-04-14
Does anyone have suggestions for how to dynamically load and play external .mp3 files from a Flash movie.  I'm interested in making a movie that does nothing but read a parameter or variable containing the name of a file and then play it.  

I'm a .NET programmer working on an ASP questionnaire application where people see questions one at a time.  With each question they see, they get some question text, a series of controls to respond to the question, and they will have a sound file played which reads the question aloud.

So far I've gotten this to work:

mySound = new Sound();
mySound.attachSound("soundInMyLibrary");
mySound.start();

If I manually load files into the library there's no problem, but it is not ideal because it will be odious to load hundreds of sounds this way.  So my question is really:

Is there a good way to dynamically create the "soundInMyLibrary" which I can use to attach to a sound object?

Also, any ideas about how to change the "soundInMyLibrary" based on a variable that gets passed to the Flash movie?  I think this can by loading some server variables that you pass in a form, but I wonder if people have comments on any other good ways to pass data to a movie (ie, can you get something to it with a parameter specified in the object tag?)

Any comments would be appreciated :)

Thanks
0
Comment
Question by:thinkscript
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 27

Accepted Solution

by:
negatyve earned 1000 total points
ID: 9743435
>ie, can you get something to it with a parameter specified in the object tag?)

surely you can:

<object
      classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
      codebase="[...]"
      width="400" height="300">
      <param name=movie value="movie.swf">
      <param name=quality value=high>
      <param name=FlashVars value="soundToPlay=mysong.mp3">
      <param name=bgcolor value=#CCCCCC>
      <embed
            src="movie.swf"
            quality="high"
            bgcolor="#CCCCCC"
            width="400"
            height="300"
            FlashVars="soundToPlay=mysong.mp3"
            type="application/x-shockwave-flash"
            pluginspage="[...]">
      </embed>
</object>

and inside flash:

// ===============================
// if you want the external mp3 to stream
mySound = new Sound();
mySound.loadSound(_root.soundToPlay, true);
// ===============================


or

// ===============================
// if you want the external mp3 to play only
// when fully loaded
mySound = new Sound();
mySound.onLoad = function(success)
{
            if(success)this.start(0,999);
};
mySound.loadSound(_root.soundToPlay, false);
// ===============================


works with flash player 6 +
0
 

Author Comment

by:thinkscript
ID: 9743458
That looks great!!  I can't wait to try it when I get home tonight.  If it works I'll close out the question right away, thanks!
0
 

Author Comment

by:thinkscript
ID: 9744824
Works like a charm!  thanks alot for your help :)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.
Suggested Courses
Course of the Month15 days, 15 hours left to enroll

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question