[AS3] Music Player - Play/Pause

For the moment, I'm trying to make a music player that will play a specific song of my choice.

I am stuck at the part where you can pause the sound and then read it in the same place.

I tried many things such as the use of the timer utilities.

Right now, when I stop, it stops, and when I press play, it plays from the beginning.

Stop();

var channel: SoundChannel;
var soundCheck:Boolean = true;
var song: Sound = new Sound (new URLRequest ("song.mp3"));
Channel = song.play ();

musicPlay.addEventListener (MouseEvent.CLICK, rhyme);
function playSong(evt:MouseEvent):void
{
If (! soundCheck)
{
Channel = song.play ();
}
soundCheck = soundCheck;
}

musicPause.addEventListener (MouseEvent.CLICK, pauseSong);
function pauseSong(evt:MouseEvent):void
{
If (Soundcheck)
{
Channel.Stop ();
}
soundCheck =! soundCheck;
}

Since there is no explicit method break - when you press and hold store the position property of the object of channel - and then when you play, use the position to read from.

var pos:Number = 0;

play Btn:

Channel = song.play (pos);

Btn pause:

POS = channel.position;

Channel.Stop ();

Tags: Adobe Animate

Similar Questions

  • [AS3] Music player - progress bar

    I created a topic on help with a play/pause button that was resolved, and now I switched to the progress bar.

    Now, I need help because I think I'm getting some errors.

    I will post only the progress bar coding.

    var dragSpace:Rectangle;
    var p: Number;
    var seek: Boolean;

    class SeekControl extends MovieClip {}
    function seekControl() {}
    dragSpace = new Rectangle (0, 3, 167, 0);
    Research = false;
    % = 0 ;

    seekHit.addEventListener (MouseEvent.MOUSE_DOWN, dragHandle);
    seekHandle.addEventListener (MouseEvent.MOUSE_DOWN, dragHandle);
    seekHandle.addEventListener (MouseEvent.MOUSE_UP, endDrag);
    }

    function dragHandle(event:MouseEvent):void {}
    searching = true;
    seekHandle.startDrag (true, limits);
    }

    function endDrag(event:MouseEvent):void {}
    Research = false;
    seekHandle.stopDrag ();
    fillBar.x = seekHandlc.x - fillBar.width;
    p = seekHandle.x/100;
    dispatchEvent (new Event ("seekChange"));
    }

    function moveSeekPos(perc:Number):void {}
    fillBar.x = (fillBar.width * perc)-fillBar.width;
    if(!seeking)
    seekHandle.x = 100 * perc.;
    }
    }
    }

    changeSeek.addEventListener ("seek_change", changeSeekBar);
    function changeSeekBar(event:Event):void {}
    position = song.length * changeSeek.percent;
    If (soundCheck = true) {}
    Channel.Stop ();
    Channel = song.play (position);
    }
    }

    function updateSeek(event:Event):void {}
    If (soundCheck = true) {}
    var perc:Number = channel.position / song.length;
    changeSeek.moveSeekPos (perc);
    }
    }

    Scene 1, Layer 'Actions', image1, line 53 1093: syntax error.
    Scene 1, Layer 'Actions', image1, line 53 1084: syntax error: expected rightbrace before fillBar.

    Scene 1, Layer 'Actions', image1, line 59 1093: syntax error.
    Scene 1, Layer 'Actions', image1, line 59 1084: syntax error: expected rightbrace before fillBar.

    LINE 53

    fillBar.x = seekHandlc.x - fillBar.width;

    LINE 59

    fillBar.x = (fillBar.width * perc)-fillBar.width;

    If I copy your code into a text editor (Textpad, not Notepad), the sign less in these equations seem to have a different value of the ascii text.  I get the small vertical rectangles dark in their place.  This is probably the question.

    I f I use Notepad they normally appear well.  And I see nothing wrong with the syntax of code by intention.

  • Music guard play/pause randomly and keep Siri activation with Apple earbuds in

    So about a month ago I bought a pair of new headphones from Apple at the Apple Store, they worked very well until last week, they kept turning on my music and stop randomly and activation of Siri. First is was not often, but now if that happens constantly, and it's really got on my nerves. I was looking through all the discussions, but they have had the problem with the Apple earbuds No. This is never happen to me before with the other Apple hear buds I've owned. I think I might have just gotten a lemon but I really want to go buy another pair.

    Accessories Apple are guaranteed for one year from their date of purchase, even if purchased separately from the iPhone, which in this case, they follow the warranty period of the iPhone. Feel free to contact Apple for support and service - Apple supported. You can either an appointment at the Genius Bar on your headphones or have them be replaced by express delivery by putting in place the replacement telephone. It seems as if the remote party on your helmet is somehow physically stuck inside that controls everything you described and it continues only when the headphones are connected. They will be able to set you up with a replacement, free of any cost to you as long as your helmet were not thrown or clearly abused.

  • AS3 Play Pause in embedded video

    Hello

    I use AS3 and have incorporated a video into flash using player. I want to play pause video.

    Then, I use of ns.pause (); to pause the video and his work. NS indicates the name of the instance.

    At the same time, I use of ns.play (); to play the video. But it's not working.

    Pls Help.

    I checked the steps.

    use test_FLK.stop (); for stop or pause button

    use test_FLK.play (); for 'play' button it will play case collapsed.

    test_FLK is the name of the FLVPlayback instance.

  • FN + play/pause, previous + next is not working for windows media player

    I use windows media player.

    I use fn + play/pause button very useful for me.
    They have stopped working.
    I don't know how to bind the keys properly.
    Default keys are now Ctrl + P and Ctrl + Alt + Home

    Hello

    (1) did you make any changes before the show?

    (2) what is the brand and model of the keyboard?

    Method 1: Mouse, keypad, touchscreen and keyboard with Windows problems

    http://Windows.Microsoft.com/en-us/Windows/help/Mouse-touchpad-keyboard-problems-in-Windows#V1H=tab01

    Method 2: Some function keys or keyboard shortcuts do not work correctly on a computer that is running Windows 7

    http://support.Microsoft.com/kb/975741

    Reference: Solve unexpected function (F1 - F12) or other special key on a Microsoft keyboard behaviors

    http://support.Microsoft.com/kb/894513?WA=wsignin1.0

    Please report if you are still having the problem. I will be happy to provide you with the additional options that you can use to get the problem resolved.

  • Z10 blackBerry music player won't 'Play All'

    My music player will play the first song in a sequence of songs but won't move to the next, when the first is more.  I select ALL PLAY, but it is not good. I have to manually select the 2nd song. He will repeat that one too if I don't choose the third song.

    Make sure that the icon repeat is not highlighted (blue), one touch, he highlights, second touch 1 appears, third press deactivates it.

  • Button Play/Pause in AS3

    I search on the internet, but I can't find a simple way to create a button play/pause in AS3. All the solutions I find are for older versions so buttons could applied actionscript directly on them.

    I created a flash animation and exported as a .swf to work with a single layer in a new .fla file. I have three layers created, button, video and actionscript. What I need is a button that looks like a pause button when the animation is played, and to stop the animation when you click on it. Would be nice if it could also pass to a play button when paused.

    It may be due to the where you have placed the code. Here's a basic example: HERE

  • Play Pause Widget AS3

    Hello

    I read a lot of discussion about it, and I'm trying to create a widget that will allow the button to switch between the images of Play/Pause and to play and to pause the captivate as needed.

    Now my script reads as follows: the button to switch between play and pause pictures. But will not pick up the .rdcmndPause = 1; .rdcmndResume = 1.

    Can anyone help?

    This. Pause.Visible = true;

    This.play1.visible = false;

    This.play1.addEventListener (MouseEvent.Click, hidePlay);

    This. Pause.addEventListener (MouseEvent.CLICK, hidePause);

    function hidePlay (event: MouseEvent): void {}

    This. Pause.Visible = true;

    This.play1.visible = false;

    MovieClip (parent) .rdcmndPause = 1;

    }

    function hidePause (event: MouseEvent): void {}

    This. Pause.Visible = false;

    This.play1.Visible = true;

    MovieClip (parent) .rdcmndResume = 1;

    }

    Hello

    To pause the maintime Captivate you could do the following:

    function hidePlay (event: MouseEvent): void {}

    This. Pause.Visible = true;

    This.play1.visible = false;

    Pause the Captivate maintimeline

    var myRoot:MovieClip = MovieClip (root);

    var mainmov:MovieClip = MovieClip (myRoot.parent.root);

    mainmov.rdcmndPause = 1;

    }

    Same way for play to resume:

    function hidePause (event: MouseEvent): void {}

    This. Pause.Visible = false;

    This.play1.Visible = true;

    Play the maintimeline Captivate

    var myRoot:MovieClip = MovieClip (root);

    var mainmov:MovieClip = MovieClip (myRoot.parent.root);

    mainmov.rdcmndResume = 1;

    }

    Thank you and best regards.

    Roger Simon

  • Problem with Play Pause AS3 button on the main timeline

    I was wondering if someone can help with this? Have tried to create a play/pause for the main timeline button in my flash movie.

    Created a clip with 1 frame - a chart of the break, and then on the 2nd frame - game graphics, labeled 'pause' and executives 'play' consecutively and put a stop action on the first frame of the movieclip.

    Then put the following code in the layer actions on the main timeline (and gave the name of "ppBtn" instance of movieclip):

    var pp:Boolean = true;


    function ppState(event:MouseEvent) {}

    {if (pp)}

    Stop();

    event.target.gotoAndStop ('pause');

    pp = false;

    } else {}

    Play();

    event.target.gotoAndStop ('play');

    pp = true;

    }

    }

    ppBtn.addEventListener (MouseEvent.CLICK, ppState);

    He works at the stopping and starting of the film but the real movieclip is not switch between the break and the game graphics (a few stays on the framework - 1st of 'pause' State). Any help in this very appreciated!

    Thank you

    What answer was helpful (correct)?  Could mark you?

  • Turn off the music player built into the Droid 3?

    Hello. If I have a podcast in my Droid 3, the player built-in music play the podcast automatically file whenever it receives a stereo Bluetooth to my audio system automatically. I don't like the music player because there is no function "Resume Play" where I can pause the game, save the position and resume playing when I restart the music player later. My MP3 Clip + SanDisk player can do, but the most expensive Droid 3 with the built-in music player does not have this feature.

    In addition, if I have another podcatcher application, the integrated music player seems to prevail and will even play on the the third podcast player app, then you start to get several podcasts playing at the same time.

    No idea how to turn off the music permanently player? I of course can't uninstall it.

    Thanks in advance.


  • Problems with music (stop) playing and attachment

    Guys, bought this Milestone 2 (froyo 2.2) some weeks to the Brazil. Great device, but consumes a lot of battery and got two major issues so far:

    (1) no endearing not work (using the local carrier Vivo or TIM) - after having included ', dun' with 'default' on the type of APN, he is able to connect to 3 G, but the ad hoc network is not broadcast.

    (2) simple can not play music... actually, it plays for about 1 minute or so and stops. Music app is still running (I tried embeded music + and Cubed) but the music is stopped, not paused. This occurs when you are using headphones or without, when pluged to feed or not...

    Some of the people with the same problem on other forums.

    Clues?

    Which Motorola could maybe check this? Don't know if this Froyo associated...

    Kind regards

    Tiago.

    Hello.

    on the subject of 1) Milestone 2 has a mobile hotspot, not home (ad hoc mode). If you would link to the Milestone 2 the same way as on your WiFi at home.

    You are able to find the Milestone 2 Hotspot as a router, once it starts?

    (2) first of all, please check if the connected music player is not included in auto taskmanagers builtin off list.

    Then check if the time-out in the connected music player is disabled.

    I had this problem once. After a reset, the player worked fine again, so this might also be worth a try.

    tiago_br wrote:

    Guys, bought this Milestone 2 (froyo 2.2) some weeks to the Brazil. Great device, but consumes a lot of battery and got two major issues so far:

    (1) no endearing not work (using the local carrier Vivo or TIM) - after having included ', dun' with 'default' on the type of APN, he is able to connect to 3 G, but the ad hoc network is not broadcast.

    (2) simple can not play music... actually, it plays for about 1 minute or so and stops. Music app is still running (I tried embeded music + and Cubed) but the music is stopped, not paused. This occurs when you are using headphones or without, when pluged to feed or not...

    Some of the people with the same problem on other forums.

    Clues?

    Which Motorola could maybe check this? Don't know if this Froyo associated...

    Kind regards

    Tiago.

  • Satellite A200-1AG: can use the play, pause buttons with other software?

    Hey

    I have question about my satellite A200-1AG.
    It's as well as the power button some other which are assigned to media player.
    Can I reprogrammed in some way to the music of change/play/stop/skip with the buttons?

    I never use media center, I know it is asigned a deflaut with the toshiba Vista Home recovery disk, but I just use winamp

    Is there a solution?

    No, as far as I know you cannot reconfigure the keys like play, pause, stop, etc.
    They can be used only with WMP (windows media, media center player)

  • E280v2 music constantly playing, participating screen scrolling

    I'm a newbie here. 1 MP3 player. I know that I have v2, I've seen verification of firmware help to know that I. I looked through 33 pages of posts and none so far address my issue. Somehow the monkey behind the e280v2 (me), got the music to play constantly and can not get deselected. I also loaded an Overdrive Audiobook, and whether it is music or audiobook, both appear on a screen of scrolling at the bottom of the window. I can't stop it. I can pause so I don't hear it, but the text info keeps rolling down. I tried to check the settings and can not understand. Please help me, gently, using non-technical terms. I'm not very savy to this kind of stuff. Any help would be greatly appreciated. Thank you in advance for your help! Diana

    Do not be afraid. Your mental health is safe and secure. The truth is that there is NO downtime on your drive. Or a lot of other or the other. BREAK is as close as you will get to it, and when you return to the main menu, that either played it, whatever .mp3 or radio, it scroll on the bottom of the screen to let you know what's on when you left.

    There is no 'need' for a function breakpoint on these flash memory mp3 players as there are no moving parts to wear. No rolls capstan casstte tape recorders, no CD to turn around, not nothing. If no STOP function.

    Just something, it must be endured.

  • you are looking for an mp3 and acc music player application

    Hi all

    I'm looking for a music player that I can load into my craft mp3 songs and VAC and power play in offline mode in iPhone. I already use Apple music app but am looking for something else too.

    Any recommendations?

    the application of Aboriginal music do this thing.

    Just put the music in iTunes and sync with your iPhone.

  • 5 c music player

    I have an iPhone 5 c running iOS 9.3.5. Try to add music, but when I try to open the music player, I get an advertisement for the apple's music and the screen freezes. I can't access the actual music files (transferred from my PC via iTunes). I can see on the PC that the files have been moved successfully to the phone but iPhone music player won't let me see them. I disabled music apple 'view' in settings and rebooted the phone but no change. Any help would be appreciated

    Hello!

    I have a similar problem:

    Since the 9.3.5 iOS update, whenever I run the music app it shows the screen MUSIC (= Ad) then it crashes (return to the home screen) after two seconds.

    When I push the play button in the control center, it plays music for two seconds, then stops.

    Something more: he asked for a cellular connection before it crashes and it crashes once again this setting enabled • • •

    _744, |-)

    –––––––––––––––––––––––––

    iPhone 5 c - iOS 9.3.5 - EN

Maybe you are looking for