Load and play different external MP3

I wanted to do something I thought was simple - I wanted to have a sound playing (loaded external mp3) and then have various buttons on the screen that load an alternate song in its place.  Could someone please help me?
This is what I'm trying to do:
var myMusic:Sound = new Sound();
var reqMyMusic:URLRequest = new URLRequest("mySong.mp3");
myMusic.load(reqMyMusic);
myMusic.play();
music1_btn.addEventListener(MouseEvent.CLICK, music1);
music2_btn.addEventListener(MouseEvent.CLICK, music2);
function music1(event:Event)
    // LOAD AND PLAY A DIFFERENT MP3 (in place of mySong.mp3)
function  music2(event:Event)
    // LOAD AND PLAY A DIFFERENT MP3 (in place of mySong.mp3)

use:
var myMusic:Sound = new Sound();
var reqMyMusic:URLRequest = new URLRequest("mySong.mp3");
myMusic.load(reqMyMusic);
var sc:SoundChannel = myMusic.play();
music1_btn.addEventListener(MouseEvent.CLICK, music1);
music2_btn.addEventListener(MouseEvent.CLICK, music2);
function music1(event:Event)
sc.stop();
myMusic = null;
myMusic=newSound();
myMusic.load(new URLRequest("whatever"));
sc=myMusic.play();
function  music2(event:Event)
sc.stop();
myMusic = null;
myMusic=newSound();
myMusic.load(new URLRequest("whatever"));
sc=myMusic.play();

Similar Messages

  • Weird issue with loading and playing videos externally - URGENT

    I have a project I'm working on where I have an FLV Playback
    component on the stage, with thumbnail buttons below to create sort
    of a video gallery. When the user clicks on each of these buttons,
    a different FLV file will load in the FLV Playback component, which
    currently works GREAT when previewing in Flash.
    I'm using the following code to link the button input with
    the FLV component on the stage:
    btn_Audi.onRelease = function() {
    videoPlayer.contentPath = "Audi.flv";
    btn_Bridgestone.onRelease = function() {
    videoPlayer.contentPath = "Bridgestone.flv";
    However, when I go to Publish to a folder to upload to the
    web, I go to click on one of the thumbnails and the video never
    loads. I get the controller bar sitting there scrolling the
    barber-shop style colors, but no video loads. I've checked,
    re-checked, and triple-checked to make sure ALL the necessary files
    are in the directory (since it seems like it's having some issue
    finding or loading the video file(s)). I'm completely out of ideas
    and need to know if anyone has any thoughts as to what it could be.
    Oh, and should it matter that I have this videoPlayer
    component "buried" inside the project, as in Scene 1 > movieClip
    > movieClip > videoPlayer ? I wouldn't think it would... but
    maybe?
    Thank you so much in advance -
    Michael

    Hello Michael,
    Did you ever resolve why your videos weren't loading? I'm
    having exactly the same problem right now, and it's driving me
    nuts. The application runs fine on my development network, but only
    displays my loader bar on the live web server. I've triple-checked
    everything I can think of, but everything seems fine.
    Any advice or anything you might remember would sure be
    appreciated.
    Best,
    Paul

  • How to load and unload Multiple External SWF

    hello there,
    i need help to figuring out how to load and also unload(removing) multiple external SWF.
    so here is what i;m trying to do,
    i want to load multiple external SWF and play it on my main SWF now i hove no problem with just loading multiple SWF and placing it in the display list .The problem came up when i tried removing those loaded SWF from the display list ,The problem exist because i have no way to refer to what i have loaded and placed on the display list,
    i used a single loader instance to load all that external swf,
    i do know that we have to remove all the event listener related to the external SWF that we want to remove and for this purpose i have crated a function called destroy which the main objective for this function is to remove all event listener inside the swf and also isolating all variable so it would be eligible for garbage collecting, here is what the code look like:
    // Create this in every object you use
    public function destroy():void
         // Remove event listeners
         // Remove anything in the display list
         // Clear the references to other objects, so it gets totally isolated
    sorry it just a kind of pseudocode cause this function will customize with it's own property i did this just for the purpose of simplicity and easy understanding..,
    so now back to main problem how should i solve this problem??
    i tried used an arraf to save all the loaded swf
         the array is just used to save the what the loader is loading but the adding to display method is using
    movieClipActAsContainer.addChild(e.target.content); //the event is from the Event.COMPLETE
    but i have a hard time using that arrya back and matching it to the one i got from the display list.
    please do help me,
    any suggestion would be greatly appreciated,
    and if can pleas show me a source code or pseudocode of what you're suggesting to me cause my english is not so fluent yet,
    thanks before.

    Hey EI,
    I had done this kind of project recently and for loading and unloading different swfs. I had used loaders specific to that filename and for removing I had used a single movieclip instance name and on clicking that specific loader request name that needs to be removed will be requested from the specific function. As mentioned below
    Loading SWF:
    ===============================
    swfLoaderIndia.load(swfRequestIndia);//This will load the request
    If you are inside a movieclip while requesting use below code
    MovieClip(this.root).addChild(swfLoaderIndia);//This will load swf on stage
    or else
    Stage.addChild(swfLoaderIndia);
    Unloading SWF
    =====================================
    If you are inside a movieclip while requesting use below code
    MovieClip(this.root).removeChild(swfLoaderIndia);//This will unload swf on stage
    or else
    Stage.removeChild(swfLoaderIndia);
    Above code will be in specific function which will be requested when the loading and unloading is required.
    I hope this helps you in your project.
    With Regards,
    Sagar S. Ranpise

  • Loading and Playing Multiple Sounds

    I have written a loadSound function which handles loading and playing multiple sounds. This function works fine when I call this function in another keyframe i.e. the frame in which the function is not written. But when I call the function on the same frame in which the function is written the sounds gets mixed up. For example the function is written in 1st keyframe. If I call this function in 2nd, 3rd and 4th keyframe (with different sounds) it works fine. But when i call the same function in 1st, 2nd and 3rd keyframe it all gets messed up.
    In 1st keyframe the sound plays properly. When I move to 2nd Keyframe the 2nd sound plays. But when I move back to the 1st keyframe the 2nd and 1st keyframe sounds all get mixed up. This doesn't happen when I call the function in 2nd, 3rd and 4th keyframes.
    Below is my function:
    import flash.events.Event;
    import flash.media.Sound;
    import flash.net.URLRequest;
    import flash.events.ProgressEvent;
    import flash.events.IOErrorEvent;
    import flash.errors.IOError;
    import flash.media.SoundChannel;
    import flash.media.SoundMixer;
    import flash.events.TimerEvent;
    import flash.utils.Timer;
    import flash.display.MovieClip;
    import flash.media.SoundTransform;
    stop();
    var s:Sound;
    var localSound:SoundChannel = new SoundChannel();
    var req:URLRequest;
    var loadedPct:uint;
    var currentFrameArr:Array = ["One","Two","Three"];
    var urlArr:Array = ["sound/m01_t01_s01.mp3","sound/m01_t01_s02.mp3","sound/page10_11.mp3"];
    function loadSnd(currentFrm:String)
    s = new Sound();
    s.addEventListener(ProgressEvent.PROGRESS, onSoundProgress);
    s.addEventListener(Event.COMPLETE, onSoundLoaded);
    s.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
    localSound.stop();
    for (var i:uint=0; i<currentFrameArr.length; i++)
      if (currentFrm == currentFrameArr[i])
       req = new URLRequest(urlArr[i]);
    s.load(req);
    function onSoundProgress(evt:ProgressEvent):void
      loadedPct = Math.round(100 * (evt.bytesLoaded / evt.bytesTotal));
      trace("The sound is " + loadedPct + " % loaded");
    function onSoundLoaded(evt:Event):void
      localSound = s.play();
    function onIOError(evt:IOErrorEvent):void
      trace("The sound could not be loaded: " + evt.text);
    Call to this function in different frames:
    loadSnd("One");
    loadSnd("Two");
    etc
    If I pass the parameter 'One' in loadSnd it plays the 1st element in urlArray, 'Two' 2nd element and so on.
    I have been scratching my head since long over this.
    Can anybody please pinpoint the error.

    Got the solution. The SoundMixer.stopAll(); statement did the trick. The complete workable function is pasted below:
    import flash.events.Event;
    import flash.media.Sound;
    import flash.net.URLRequest;
    import flash.events.ProgressEvent;
    import flash.events.IOErrorEvent;
    import flash.errors.IOError;
    import flash.media.SoundChannel;
    import flash.media.SoundMixer;
    import flash.events.TimerEvent;
    import flash.utils.Timer;
    import flash.display.MovieClip;
    import flash.media.SoundTransform;
    stop();
    var s:Sound;
    var localSound:SoundChannel = new SoundChannel();
    var req:URLRequest;
    var loadedPct:uint;
    var currentFrameArr:Array = ["One","Two","Three"];
    var urlArr:Array = ["sound/m01_t01_s01.mp3","sound/m01_t01_s02.mp3","sound/page10_11.mp3"];
    function loadSnd(currentFrm:String)
      s = new Sound();
      s.addEventListener(ProgressEvent.PROGRESS, onSoundProgress);
      s.addEventListener(Event.COMPLETE, onSoundLoaded);
      s.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
      SoundMixer.stopAll();
      localSound.stop();
      for (var i:uint=0; i<currentFrameArr.length; i++)
      if (currentFrm == currentFrameArr[i])
      req = new URLRequest(urlArr[i]);
      break;
      s.load(req);
    function onSoundProgress(evt:ProgressEvent):void
      loadedPct = Math.round(100 * (evt.bytesLoaded / evt.bytesTotal));
      trace("The sound is " + loadedPct + " % loaded");
    function onSoundLoaded(evt:Event):void
      localSound = s.play();
    function onIOError(evt:IOErrorEvent):void
      trace("The sound could not be loaded: " + evt.text);
    Calling the function
    loadSnd("One");
    loadSnd("Two"); etc

  • How to load and display the external flv video files in dynamicly and the how to control the flv fil

    How to load and display the external flv video files in dynamicly using AS 3.0
    and  How to control the flv file  add the play paus button and add seekbar.
    I have using to load the flv file following code
    var flvPlaceHolder1:MovieClip = new MovieClip();
    var vid1:Video = new Video(734, 408);
    flvPlaceHolder1.addChild(vid1);
    addChild(flvPlaceHolder1);
    flvPlaceHolder1.x = 1059;
    flvPlaceHolder1.y = 152;
    var nc1:NetConnection = new NetConnection();
    nc1.connect(null);
    var ns1:NetStream = new NetStream(nc1);
    vid1.attachNetStream(ns1);
    var listener1:Object = new Object();
    listener1.onMetaData = function(evt:Object):void {};
    ns1.client = listener1;
    ns1.play("GV-1600 TURNING.flv");
    ns1.addEventListener(NetStatusEvent.NET_STATUS, statusChanged1);
    function statusChanged1(ns1:NetStatusEvent):void
             trace(ns1.info.code);
            if (ns1.info.code == 'NetStream.Buffer.Empty')
                 trace('the video has ended');
                 removeChild(flvPlaceHolder1);
                 //trace('removeChild');
                gotoAndPlay(1786);
    then how to add the play,paus ,full screen button    and   seekbar,volumebar.

    I have to Create the flash presentation for our company product
    In this presentation the left  side the text animation are displayed then right side the our product video is displayed.
    In this presentation i need the following option :
    1, The first product video and animation is finished then the next product is played
    2, then the video displayed  (size width and height 400x300) , I click this video to increase the size(ex:1000x700)
    3, then the playing video i control  it play, stop, paus button and volume bar, seek bar.
    4, then this presentation is displayed on 42 inches LCD TV so this full presentation is run full screen.
    I have finished first two steps 1 and 2
    the following are the screen short and code:-
    code :-
    var count=0;
    var flvPlaceHolder2:MovieClip = new MovieClip();   
    var vid2:Video = new Video(734, 408);
    flvPlaceHolder2.addChild(vid2);
    addChild(flvPlaceHolder2);
    flvPlaceHolder2.x = 1059;
    flvPlaceHolder2.y = 152;
    var nc2:NetConnection = new NetConnection();
    nc2.connect(null);
    var ns2:NetStream = new NetStream(nc2);
    vid2.attachNetStream(ns2);
    var listener2:Object = new Object();
    listener2.onMetaData = function(evt:Object):void {};
    ns2.client = listener2;
    ns2.play("GS-4000.flv");
    this.addEventListener(Event.ENTER_FRAME, BtnFadeIn2);
    function BtnFadeIn2(event:Event):void
        if (this.currentFrame == 387)
            /*flvPlaceHolder2.x = 30;
            flvPlaceHolder2.y = 140;
            vid2.width=1800;
            vid2.height=800;
            trace('Screen size is changed');*/
            if(count==0)
            flvPlaceHolder2.x = 30;
            flvPlaceHolder2.y = 140;
            vid2.width=1800;
            vid2.height=800;
            count++;
    ns2.addEventListener(NetStatusEvent.NET_STATUS, statusChanged2);
    function statusChanged2(ns2:NetStatusEvent):void
        trace(ns2.info.code);
        if (ns2.info.code == 'NetStream.Buffer.Empty')
                trace('the video has ended');
                 removeChild(flvPlaceHolder2);
                 //trace('removeChild');
                gotoAndPlay(433);
    flvPlaceHolder2.buttonMode=true;
    flvPlaceHolder2.addEventListener(MouseEvent.CLICK,home2);
    function home2(e:MouseEvent):void
        if(vid2.width==734 && vid2.height==408)
            flvPlaceHolder2.x = 30;
            flvPlaceHolder2.y = 140;
            vid2.width=1800;
            vid2.height=800;
        else
            flvPlaceHolder2.x = 1059;
            flvPlaceHolder2.y = 152;
            vid2.width=734;
            vid2.height=408;

  • 1120 error when attempting to load and play sounds

    I'm attempting to load and play a sound (which seems quite
    basic) but I am getting an 1120 error. Could anyone please help me
    figure out what I'm doing wrong?
    var hitSound:Sound = new Sound();
    var reqHitSound:URLRequest = new URLRequest("myAudio.mp3");
    hitSound.load(reqHitSound);
    hitSound.play();
    1120: Access of undefined property hitSound
    1120: Access of undefined property reqHitSound

    Yes, the mp3 is good and the path is correct. I'll put my
    complete code below.
    The error I get is:
    1120: Access of undefined property hitSound. (line 14 -
    hitSound.load(reqHitSound);)
    1120: Access of undefined property reqHitSound. (line 14 -
    hitSound.load(reqHitSound);)
    1120: Access of undefined property hitSound. (line 15 -
    hitSound.play();)
    Its almost like the code doesn't feel I've really defined
    hitSound as a Sound.
    Help please? Am I missing a component?

  • I have many photos with file extension of .PDD and that Photo Deluxe 4 no longer will operate in Win 7. How can I open?  Next in Elements 11, how do I load and print different pictures and different sizes options on the same page?

    I have many photos with file extension of .PDD and that Photo Deluxe 4 no longer will operate in Win 7. How can I open?  Next in Elements 11, how do I load and print different pictures and different sizes options on the same page?
    Thanks,
    Shir

    sbmgrams wrote:
    I have many photos with file extension of .PDD and that Photo Deluxe 4 no longer will operate in Win 7. How can I open?
    See here:
    Reading PhotoDeluxe PDD Files

  • Loading and Playing 2 videos at the same time

    Hello everyone
    I'm having a problem on loading and playing two videos at the same time on XletView.
    The background video, I'm loading by editing channels.xml that is located at config folder into xletview folder. I've just to add the file path and when i start the video it starts playing.
    But now, I have a problem. I have to load a file that is into my HD, and play it at the same time of the main(background) video.
    Do anyone know how to do this?

    anyone?
    PowerBook G4 1.67 GHz Mac OS X (10.4.7) 1.5 GB ram

  • Quicktime video (.mov file) will not load and play in Firefox 3.6.16

    I have a computer with Firefox 3.6.16 installed that will not play Quicktime videos (.mov files) in the browser. This is a desktop computer.
    Another computer (laptop) with exactly the same version of Firefox installed will load and play them perfectly in the Quicktime player.
    Both computers have Quicktime addin 7.6.9.0 installed and designated as the default application for Quicktime movies.
    Both computers play the videos correctly in IE 8.
    When attempting to play the video in Firefox, the player window opens and attempts to load the video, but soon seems to freeze leaving a black window open where the player should be.
    From what I have observed, this seems to be a problem related specifically to this computer, and since the video plays in IE I have ruled out the firewall blocking loading from the site.

    Hi, I've exactly the same problem, 'cept I've XP Pro. When I say exactly, I mean the format used is HDV 1080i60, along with everything else there.
    And I'm right there with you. Why Quicktime can't play a natively encoded HDV Quicktime file (using Final Cut Pro), is beyond me, but basically, I've used K-Lite Codec Pack, and Quicktime. Neither work, although Quicktime does ask for internet connectivity to download resources or something similar (I don't have Internet Access at home). I've used VLC on a friend's PC, and, while it works, there is a very strange, and irritating flicker where there's heavy movement
    Where can I get the resource needed, as another party needs to view the clip, and they already have it. So if they can update their codec library or similar, then that would be much better (as I wouldn't need to upload a FullHD Video again)
    thanks

  • Youtube videos not loading and playing on Mac Mini

    Safari can't stream videos from Youtube.  The videos may start to load and play for a few seconds to a minute, but I can't watch a single video all the way through without it continually pausing for minutes at a time, and then eventually just pausing indefinitely while the video tries to load.  I updated my Adobe Flashplayer plug-in (from Adobe's website), I reset Safari and emptied all of the internet info like cookies and things.  The mac is only a couple weeks old, so there's not a gazillion things added to Safari or anything like that, as far as extensions and plug-ins and whatnot.  I only have the "adblocker" extension, because it was recommended in a thread like this one, and had helped others with the youtube problem.  I'm not terribly computer savvy.  Please help! 

    From the menu bar, select
     ▹ System Preferences… ▹ Flash Player ▹ Advanced
    and click Delete All. Close the preference pane.
    From the Safari menu bar, select
    Safari ▹ Preferences... ▹ Privacy ▹ Remove All Website Data
    and confirm. Test.
    If you use a FireWire audio interface, disconnect it and test again.

  • Problem loading and playing samsung videos in elements

    Samsung videos will not play in elements

    hibernian
    No enough information to help you. Answers will be in the details.
    1. What version of Premiere Elements are you using and on what computer operating system is it running?
    2. What Samsung device is recording your videos that you want to edit in Premiere Elements?
    3. What are the properties of those videos, including video and audio compression, frame size, frame rate, variable frame rate, interlaced or progressive, file extension, and pixel aspect ratio?
    4. What are you or the program setting as the project preset to match the properties of your source media?
    5. Are you getting any error messages associated with "problem loading and playing samsung videos in elements"?
    6. Is there a problem loading and playing both video and audio or just video or just audio?
    Let us start here and then we can plan troubleshooting strategy.
    Thank you.
    ATR

  • Is there any way to load and play the iPad scrabble app on my Macbook?  i can't believe there is no scrabble app for my mac

    Is there any way to load and play the ipad scrabble app on my macbook?

    There hasn't been a Scrabble version for OS X since 10.3 -10.4 on PPC, the intel swtich and they just left.
    Scrabble owners will sue the living daylights out of anything that looks like it or uses the name.
    Would love to play on my new Mac latop
    Apple in their infinite wisdom didn't allow iOS apps to run/ported  as widgets etc on OS X Dashboard like many users requested long time ago.
    There is no Scrabble widget on Dashboard downloads page or anything close to it.

  • Flex 4.6 IOS Mobile packager - can it load and play swf's dynamically at run time?

    I have an app that shows the viewer slides in a SWFLoader object.  I load the slides at runtime from a remote server.  When I package the app for IOS using 4.6 the swf slides load and play fine in the IOS emulator on the PC.  They don't load, however, when I deploy to a provisioned iPad. 
    My guess is that IOS can handle doesn't know what to do with dynamically loaded swf data.  I'm not positive though because it plays in the emulator.  Is that emulator truly emulating xcode or is it running flash?
    Note:  this same app plays an rtmp flash stream just fine even on the device itself.  Just can't handle a dynamically loaded swf.

    The correct answer to this question appears to be that Apple's terms of service *do not* prohibit the loading of swf's on IOS from remote servers dynamically at runtime.  They prohibit the loading of swf's that *contain executable ActionScript code*. 
    I loaded a PPT into Adobe Connect and then retrieved the resultant slide swf's from the Connect server.  I took these swf's and loaded them into my iPad app, dynamically at runtime, from a remote server.  The swf's loaded and animations played.  I made no changes to my code.  I'm just using a plain old SWFLoader object.
    Loading swf's dynamically at runtime from remote servers into IOS works - if you make the swf's right.  How to do that I'm not sure.

  • Safari 8 does not properly load and play any mp4 video

    My Safari 8.0.3 on my OS X 10.10.2 does not actually load and play any MP4 video in-browser. All I see is the black loading bar.
    I have not installed any video codecs on my OS X, nor have I tinkered with any QuickTime settings.

    Perhaps a third parrty Safari add on that was compatible with the prior version of Safari but not 5.1 that's preventing pages to render as they should.
    Read here >  Safari: Unsupported third-party add-ons may cause Safari to unexpectedly quit or have performance issues

  • Help needed: How can I import a large audio collection with many playlists? iTunes crashes because so many playlists try to load and play at once.

    I've got a problem that I can't seem to figure out after reading scads of articles and posts. I'd be grateful for any help or ideas you can provide. Here's what's going on.
    I have a folder of GraphicAudio audio books. It contains roughly 500 subfolders, one for each book. In each folder are the mp3 files for the book and an m3u file that was supplied with the books at the time of purchase. None of this content is currently in my iTunes library.
    When I try to add this folder to my iTunes library, iTunes starts trying to play each playlist it encounters. It crashes after around 30 seconds. I suspect this is because it tries to switch and play playlists so rapidly.
    I don't actually want iTunes to start playing each playlist it finds. I just want to import my files. Once they're imported, I can select them and send individual books to my iPod Touch.
    Do any of you know of a work-around for this? I'm dreading the thought of having to import each subfolder one by one. I keep thinking that if I could just prevent iTunes from automatically trying to play the playlists, it would import the mp3s and playlist info without a problem. If there's no way to do this in iTunes, might there be a third party app that can manage it somehow?
    For reference, I'm using the latest version of 64 bit iTunes under 64 bit Windows 7.
    Thanks for taking the time to help me.

    I've written a script called DeDuper which can help remove unwanted duplicates. See this  thread for background.
    That said you should probably start by "undoing" the creation of extra mp3s. If you sort the song list on the Date Added column you can select then first song from the relevant batch, then scroll to the end of the group, hold shift and click to select the range. You can then delete and send to the recycle bin.
    My script won't be as effective against this group. The "Convert to format" tool may well specifiy a different bit rate from the source file, but it won't ever increase the quality of the audio. Clearly converting 128k mp3 to 256k mp3 would have no benefit so you want the original files.
    If you still have duplicates use the script to thin out what remains.
    tt2

Maybe you are looking for

  • G/l account while posting stock

    hi guru's my problem is while posting the stock in mb1c i am getting G/L account 799999 doesnot exit in the company code 1978 i have copied the co code 1978 from standard co code 1000 chart of account INT. where as chart of account INT (material mana

  • A problem about saving the picture control'image in a child VI.

    i want to use 'export image' method to get a picture control'image,so ,i have a child VI to use method 'export image',and a main VI to using the child VI,but when i run the main VI,there is no image is saved on the disk ,but if i open the child VI'fr

  • I have a question regarding emails being marked as unread when syncing with an exchange account.

    I have a question regarding emails being marked as unread when syncing with an exchange account. In the evening I can see I have 10 unread emails on my exchange account. I leave them unread. The following day, at work, I view and read all my mails fr

  • Java Object in javascript

    How can i call a java object and use it inside javascript? For example if i instantiate an integer in a java class, i want to pass it to javascript, do some work on it like for example incrementing it, and then i want to return its value. Can i do th

  • Error in portal for SRm trnasactions

    Hi, Im working on SRM 7.0 with EP 7.0.When logging into portal ,i get this following errors if i click on any of the SRM transactions(Procurement and Purchasing menu) . Portal runtime error. An exception occurred while processing your request. Send t