Need to loop some music using existing code

  • spowart
  • Newbie
  • Newbie
  • User avatar
  • Posts: 12
  • Loc: London United Kingdom

Post 3+ Months Ago

Hi

I have been learning how to create a MP3 player in Flash which plays the mp3 from an external folder and dynamically loads it into the exising movie. It also has track info which is located aswell in an external folder as a txt file.

I have the MP3 player fully working however I want to add some more code to loop the MP3 2 to 3 times before it automatically goes to the next track.

I have tried to use this code within part of the code:

bgMusak.start(0, 2);

However I am not sure if I am doing it in the right place cause it is not looping.

Here is part of the code:


Code: [ Select ]
//----------------<sound initialization>-------------------\\
var curTrackNum:Number = 0;
var bgMusak:Sound;
// autosize some text fields
this.helpBubble.autoSize = "center";
this.trackInfo.autoSize = "left";
// load the track info vars
var myMusicLv:LoadVars = new LoadVars();
myMusicLv.load("vars/track_info.txt");
//----------------< Sound setup >-----------------------------\\
function stopMusak() {
    delete bgMusak;
}
function playMusak() {
    bgMusak = new Sound();
    //-----< Loop >------------------------\\
    //bgMusak.start(0, 2);
    //-----< Loop >------------------------\\
    bgMusak.onSoundComplete = function() {
        if (curTrackNum == (myMusicLv.totalTracks-1)) {
            curTrackNum = 0;
        } else {
            curTrackNum++;
        }
        playMusak();
    };
    bgMusak.onID3 = function() {
        //trackInfo.text = "artist : "+bgMusak.id3.TCOM+" | track : "+bgMusak.id3.TIT2;
        trackInfo.text = "T : "+bgMusak.id3.TIT2;
    };
    bgMusak.onLoad = function(success) {
        if (!success) {
            trackInfo.text = "Failed to load track.";
        }
    };
    bgMusak.loadSound("mp3s/mp3-"+curTrackNum+".mp3", true);
  1. //----------------<sound initialization>-------------------\\
  2. var curTrackNum:Number = 0;
  3. var bgMusak:Sound;
  4. // autosize some text fields
  5. this.helpBubble.autoSize = "center";
  6. this.trackInfo.autoSize = "left";
  7. // load the track info vars
  8. var myMusicLv:LoadVars = new LoadVars();
  9. myMusicLv.load("vars/track_info.txt");
  10. //----------------< Sound setup >-----------------------------\\
  11. function stopMusak() {
  12.     delete bgMusak;
  13. }
  14. function playMusak() {
  15.     bgMusak = new Sound();
  16.     //-----< Loop >------------------------\\
  17.     //bgMusak.start(0, 2);
  18.     //-----< Loop >------------------------\\
  19.     bgMusak.onSoundComplete = function() {
  20.         if (curTrackNum == (myMusicLv.totalTracks-1)) {
  21.             curTrackNum = 0;
  22.         } else {
  23.             curTrackNum++;
  24.         }
  25.         playMusak();
  26.     };
  27.     bgMusak.onID3 = function() {
  28.         //trackInfo.text = "artist : "+bgMusak.id3.TCOM+" | track : "+bgMusak.id3.TIT2;
  29.         trackInfo.text = "T : "+bgMusak.id3.TIT2;
  30.     };
  31.     bgMusak.onLoad = function(success) {
  32.         if (!success) {
  33.             trackInfo.text = "Failed to load track.";
  34.         }
  35.     };
  36.     bgMusak.loadSound("mp3s/mp3-"+curTrackNum+".mp3", true);


Can anyone help me? :roll: :cry:

Post Information

  • Total Posts in this topic: 1 post
  • Users browsing this forum: No registered users and 4 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.