Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

add repeat sound and More mp3 to this player

Participant ,
Mar 10, 2013 Mar 10, 2013

hi , i have simple Start/pause/Stop Mp3 player

here is action script :

//imports the necessary as events

import flash.events.Event

import flash.events.MouseEvent;

import flash.media.Sound;

import flash.media.SoundChannel;

import flash.net.URLRequest;

var isPlaying:Boolean = new Boolean();

var pausePosition:Number = new Number();

//Create an instance of the Sound class

var soundClip:Sound = new Sound();

//Create a new SoundChannel Object

var sndChannel:SoundChannel = new SoundChannel();

//Load sound using URLRequest

soundClip.load(new URLRequest("song.mp3"));

//Create an event listener that wll update once sound has finished loading

soundClip.addEventListener(Event.COMPLETE, onComplete, false, 0, true);

controller.addEventListener(MouseEvent.MOUSE_DOWN, btnPressController, false, 0, true);

stop_btn.addEventListener(MouseEvent.MOUSE_DOWN, btnPressStop, false, 0, true);

function onComplete(evt:Event):void {

    //Play loaded sound

    sndChannel = soundClip.play();

    isPlaying = true;

}

function btnPressController(evt:MouseEvent):void

{

    switch(isPlaying)

    {

        case true:

            controller.gotoAndStop(2);

            pausePosition = sndChannel.position;

            sndChannel.stop();

            isPlaying = false;

        break;

        case false:

            controller.gotoAndStop(1);

            sndChannel = soundClip.play(pausePosition);

            isPlaying = true;

        break;

    }

}

function btnPressStop(evt:MouseEvent):void

{

    pausePosition = 0;

    sndChannel.stop();

    controller.gotoAndStop(2);

    isPlaying = false;

}

but now i need to add Repeat Function to repeat Sound , i add this script :

soundClip.addEventListener(Event.SOUND_COMPLETE,introloop);

function introloop(e:Event):void {

    sndChannel = soundClip.play(0, 9999);

    isPlaying = false

}

but it now work.

any help ??  thanks ...

Also It will be Great if Help me to add more Than One sound ( maybe With Next sound bt )

TOPICS
ActionScript
603
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 10, 2013 Mar 10, 2013

Why do you specify isPlaying to be false i the introloop function?

You should put a trace in that function to see if the end of the sound is detected

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 11, 2013 Mar 11, 2013

thanks

i just use isPlaying = false or True for a little bit Hope and nothing chance ...

where i must Put Trace script and how this script can help me ??

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 14, 2013 Mar 14, 2013
LATEST

ok i solved the repeat Problem ...

now anyone can help me about adding more Mp3 tracks and Next button please

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines