Avatar billede alarma Nybegynder
31. oktober 2003 - 17:13 Der er 4 kommentarer

Hvordan stopper den efter hver sang?

Hej...
Jeg har en player, hvor den har følgende kode:

function loadAndPlay (some_cb) {
  holderMC.lyd.stop();
  loadMovie ("sound/"+some_cb.getSelectedItem().data+".swf", holderMC);
  holderMC.lyd.start (0, 999);
 
 
}

function afspil () {
    if (!pavs) {       
        holderMC.lyd.start (0, 999);       
}    else       
        holderMC.lyd.start (p, 999);
        pavs = 0;
}


function pause () {
    p = holderMc.lyd.position/1000;
    pavs = 1;
    holderMC.lyd.stop();
}
function sluk () {
    pavs = 0;
    holderMC.lyd.stop();
}


Hver track har en swf for sig selv og hedder track01.swk , track02.swf osv. osv.. med koden:

var mainTimeline = this;
/*
* Method: Sound.checkLoadProgress()
*  Desc: Checks progress of a load().
*        Called only by preload(). Reports download progress
*        by invoking a custom Sound.onBytesLoaded() handler.
*/
Sound.prototype.checkLoadProgress = function () {
  // Check how many kilobytes have loaded.
  var kbLoaded = Math.floor(this.getBytesLoaded()/1024);
  // Check the size of the file loading, in kilobytes.
  var kbTotal = Math.floor(this.getBytesTotal()/1024);
  // Calculate the percent complete.
  var percentDone = isNaN(Math.floor(kbLoaded/kbTotal * 100)) ?
                    0 : Math.floor(kbLoaded/kbTotal * 100);
  // Execute the onBytesLoaded() callback, which
  // typically would display load progress.
  this.onBytesLoaded(this.getBytesLoaded(),
                    this.getBytesTotal(),
                    kbLoaded,
                    kbTotal,
                    percentDone);
}

/*
* Method: Sound.clearLoadCheck()
*  Desc: Cancels an interval calling checkLoadProgress().
*/
Sound.prototype.clearLoadCheck = function () {
  // If there is a load interval for this Sound object...
  if (this.loaderID) {
    // ...stop calling it.
    clearInterval(this.loaderID);
  }
}

/*
* Method: Sound.preloadSound()
*  Desc: Begins the download of a sound file and executes
*        checkLoadProgress() every 200ms until the file has loaded.
*        Parameters are the same as Sound.loadSound().
*/
Sound.prototype.preloadSound = function (url, isStreaming) {
  // Always stop any previous preload before proceeding.
  this.clearLoadCheck();

  // Call checkLoadProgress() every 200 milliseconds.
  this.loaderID = setInterval(this, "checkLoadProgress", 200);

  // Load the Sound file.
  this.loadSound(url, isStreaming);
}

// =================
// Usage
// =================
// Create a sound object.
lyd = new Sound();

// Assign an onLoad() callback.
lyd.onLoad = function (success) {
  // Cancel the preload interval (REQUIRED!).
  this.clearLoadCheck();

  // If the load was successful...
  if (success) {
    // ...use the new Sound. For example, if the loaded
    // sound is an event sound, we can start it like this:
    // this.start();
    mainTimeline.loadMsg_txt.text = "100 %";
    _parent.playing=true;
  } else {
    // ...otherwise, perform failure operations.
    mainTimeline.loadMsg_txt.text = "Load failed.";
  }
}

// Assign an onBytesLoaded() callback. This is where each
// individual Sound object can decide what to do
// with the preload information.
lyd.onBytesLoaded = function (bytesLoaded, bytesTotal, kbLoaded, kbTotal, percentLoaded) {
  mainTimeline.loadMsg_txt.text = percentLoaded + " % nede";
}

// Load a streaming sound.
lyd.preloadSound("sound/ftc.mp3", true);
lyd.onSoundComplete = function() {
    this.preloadSound("sound/ftc.mp3", true);
}

Hvordan får jeg playeren til at stoppe efter nummeret er færdig...???? Iøjeblikket går den på uendeligt loop
Avatar billede mat Nybegynder
31. oktober 2003 - 17:25 #1
uden at jeg har kigget nærmere på det, men har du prøvet at fjerne:

lyd.onSoundComplete = function() {
    this.preloadSound("sound/ftc.mp3", true);
}

?
Avatar billede alarma Nybegynder
31. oktober 2003 - 17:38 #2
Perfekt, men det virker kun på min pc,.... Ikke når jeg ligger det på nettet
Avatar billede mat Nybegynder
31. oktober 2003 - 17:44 #3
tøm din cache?
Avatar billede svendthomsen Nybegynder
18. april 2005 - 18:42 #4
skal den stoppe ligger du denne kode ind :

stopAllSounds();
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
IT-kurser om Microsoft 365, sikkerhed, personlig vækst, udvikling, digital markedsføring, grafisk design, SAP og forretningsanalyse.

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester