A Flash Developer Resource Site

Page 2 of 2 FirstFirst 12
Results 21 to 31 of 31

Thread: Building a Media Player

  1. #21
    Registered User
    Join Date
    Apr 2001
    Location
    Akron OH, USA
    Posts
    4,841
    ----
    I don't have an actionscript manual
    ----

    there is an HTML version that comes with Flash. Select ActionScript Dictionary under the help menu.

    This should help with stop action and arrays.

    Code:
    trace(urls[count]) ; //show url
    just displays the selected url.

    you can execute whatever code you want in place of the line above. For example:

    Code:
    loadMovie("_level1",urls[count]);
    note that you can also use loadMovieNum() which is a little more convenient for loading SWF into levels. Generally when you load into levels use loadMovieNum and use loadMovie() for loading into mcs.

    ex.

    loadMovieNum(1,"urlto.swf");

    vs.

    loadMovie("_level1","urlto.swf");

  2. #22
    Banned by GMF ™
    FK´s Banning Machine

    Join Date
    Sep 2003
    Location
    Houston
    Posts
    40
    Okay, I took a while to read through some of the actionscript dictionary regarding some of the commands we're using. One thing tho, is when I clicked on stop, there wasn't any information on what strings go with it. I tried just the stop by itself, but that didn't work. Where can I find the rest of the missing pieces? The stuff I found, wasn't much help at all with loading external mp3's......Or am I looking in the wrong place?

    Help > ActionScript Dictionary > stop

  3. #23
    Registered User
    Join Date
    Apr 2001
    Location
    Akron OH, USA
    Posts
    4,841
    When you put a sound on the timeline you control its playback using movieclip navigation methods such as play, stop, gotoAndPlay, gotoAndStop.

    When you attach a sound or load a sound to a sound object then you use sound object start and stop methods to control sound.

    You are using timeline sounds so read about movieclip.stop, not sound object.stop. The movieclip.stop method requires no arguments.

    if you load a streaming sound only SWF into _level1 you can stop(actually a pause behavior) playback with:

    _level1.stop(); //stops playhead for _level1

    resume playback
    _level1.play(); // plays last paused or frame 1
    Last edited by hp3; 12-18-2003 at 02:21 PM.

  4. #24
    Banned by GMF ™
    FK´s Banning Machine

    Join Date
    Sep 2003
    Location
    Houston
    Posts
    40
    What's a level? I've seen you talk about levels before? How do I load into levels instead of the code I've been using for play? ....Or is that a level?

    // button for loading song 1
    on(release){
    _level1.unloadMovie(); // stop loading old stream
    loadMovieNum("http://www.houstonwakeboarding.com/nickleback.swf",1); // load new song into level1
    }

    //my stop button
    on(release){
    _level1.stop(); //stops playhead for _level1
    }
    on(release){
    _level1.play(); // plays last paused or frame 1
    }

    It doens't work tho, what am I doing wrong?
    Last edited by fat_sac; 12-18-2003 at 02:51 PM.

  5. #25
    Registered User
    Join Date
    Apr 2001
    Location
    Akron OH, USA
    Posts
    4,841
    notice in your code example that you are using loadMovieNum(). This loads SWF into levels. In your case level 1.

    loadMovieNum("urlto.swf",1); // load new song into level1

    A level is an empty slot where you can load SWF. You can also replace an exisisting movie clip with a SWF. In this case you use loadMovie(), not loadMovieNum().

    One advantage of using levels is that they are already built into the Flash player. Unlike movieclips, where you would have to create one first then load into it, levels already exist, you just load into them.

    The target path to a level is

    _levelN with N representing the numerical id of the level.

    _level1 is level number 1.

    loadMovieNum() is only for loading SWF into levels.
    loadMovie() can load SWF into both movieclips and levels, but is most typically for loading into movie clips.

  6. #26
    Banned by GMF ™
    FK´s Banning Machine

    Join Date
    Sep 2003
    Location
    Houston
    Posts
    40
    So should I do loadMovieNum() for the first song, then loadMovie() for all the rest?

  7. #27
    Registered User
    Join Date
    Apr 2001
    Location
    Akron OH, USA
    Posts
    4,841
    Like I said above, loadMovieNum() is for loading into levels and loadMovie() most typically for loading into movie clips. You question then implies that you are considering load one song into a level and another song into a movieclip.

    I do not understand the logic this approach. Why would consider using loadMovieNum() for one song and loadMovie() for the rest?

    Normally in a jukebox app you load all SWF into the same target, which could be a level or a movie clip. When you load a SWF into a target occupied by another SWF, Flash replaces the old with the new. This helps to free up ram and is the most efficient way to handle the loading.

    So you choose to load all songs into a mc with loadMovie() or all songs into a level with loadMovieNum(). But not both.

  8. #28
    Banned by GMF ™
    FK´s Banning Machine

    Join Date
    Sep 2003
    Location
    Houston
    Posts
    40
    Ok, that makes a little more sense. I got screwed up womehow and thought that you would initiate the level with loadMovieNum(), and then replace it with loadMovie()??Maybe??? I was really backwards I guess.

    So what we've got now is, load external .swf's into level one with loadMovieNum(), then control it with :

    //my stop button
    on(release){
    _level1.stop(); //stops playhead for _level1
    }
    on(release){
    _level1.play(); // plays last paused or frame 1
    }

    Then I would replace each new .swf with the old one into the same level the first one was loaded into?

    Ok, how do I initiate the first .swf without having to press play, ie. when the player opens it would automatically start the first song? Then, how would I jump to the next one? Is this the code I would use to go backwards, and modify it a little to skip forwards?

    // previous button
    on(release){
    count = (count <= 0) ? urls.length - 1 : count - 1;
    trace(urls[count]); //show the url
    }

    // next button
    on(release){
    count = (count == urls.length - 1) ? count = 0 : count + 1;
    trace(urls[count]); //show the url
    }

    Then I would put the array where? I still don't understand what part of the movie it belongs in. Do I assign it to a button?...Or does it go in a frame of the movie which is the mp3 player? Once I get the array in, I would replace (urls[count]) with the urls maybe, that are in the array?

  9. #29
    Registered User
    Join Date
    Apr 2001
    Location
    Akron OH, USA
    Posts
    4,841
    -----
    Ok, how do I initiate the first .swf without having to press play, ie. when the player opens it would automatically start the first song?
    -----
    call loadMovieNum() or loadMovie(), whichever you prefer, from a frame not a button.

    ex.

    // frame 1
    loadMovieNum("urlto.swf",1) // automatically load swf into level 1

    Flash will automatically play the sound (assuming you do not have a stop action in a frame before the sound starts). If you set the sound to stream sync it will load a small amount of the sound first, to get a head start, then start playing the sound as it loads the rest. If you set the sound to start/event sync, flash will load the sound completely then play it.

    -----
    Then I would put the array where? I still don't understand what part of the movie it belongs in. Do I assign it to a button?...
    -----
    generally you only include code inside of buttons that needs to be executed by the button's event. All other code can go inside a frame.

    For more help on basics of where to add ActionScript and soforth, you should ask in the newbies forum.

    lets keep to the sound related issues here.

  10. #30
    Junior Member
    Join Date
    Aug 2001
    Posts
    7
    Hi, I've built a media player using most of the same code here, I was just wondering how to make it so the external swf music files load in a random order?

  11. #31
    Registered User
    Join Date
    Apr 2001
    Location
    Akron OH, USA
    Posts
    4,841
    you can either randomly select a song from a list each time or randomly shuffle a playlist and move sequentially through the playlist.

    the advantage of the second approach is that you do not have repeats.

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