Flash Actionscript 3 - sound seeking/playing

2020-07-24 06:30发布

问题:

I have an audio file which is 4 hours long. I created a standart player to manage my needs - works fine, but you dont seek more than 12180000 miliseconds in position count player stops. If you position the sound to play 12100000 (few seconds earlyear) - plays fine and if it countinues to play without changing the position by code, it is good till the end. I dont get any errors, or any kind of information regarding this kind of issue.

soundChannel = sound.play(12180000); // DOES NOT PLAY, NO ERRORS
soundChannel = sound.play(12100000); // PLAYS FINE, AND CONTINUES TO PLAY TILL THE END
  • Sound is fully loaded, before playing.

So anybody have any ideas?

回答1:

this is interesting... I cannot get it to play past 12173943 milliseconds. For me, it works up that that exact number, but anything after that, it won't play. My guess is flash allots a certain amount of memory for sounds and that number right there calculates to the maximum amount of memory allotted for that file. Hopefully someone else can chime in. I am using the MP3 provided by Rummer and this was my test code

import flash.media.*;
import flash.events.*;
import flash.net.*;

var channel:SoundChannel = new SoundChannel();
var sound:Sound = new Sound();
sound.load(new URLRequest("podcast.mp3"));
sound.addEventListener(Event.COMPLETE, soundLoaded);
sound.addEventListener(IOErrorEvent.IO_ERROR, onError);

function soundLoaded(e:Event):void
{
    channel = sound.play(12173943);
}

function onError(e:IOErrorEvent):void
{
    trace(e);
}

I'm using Flash CS5.5 and exporting for flash 10.2. I would highly consider splitting your mp3s into sections. The first time my SWF loaded, flash hung for a good 10 seconds before it played because of how large the mp3 is.

=============== AS2 version that works

var my_sound:Sound = new Sound();
my_sound.onLoad = function(success:Boolean)
{
    if (success)
    {
        my_sound.start(12180);
    } 
};
my_sound.loadSound("podcast.mp3", true);