[AS3] Music Player - Play/Pause

At the moment, I am attempting to make a music player that will play a specific song of my choosing.
I am stuck at the part where you can pause the sound, and then play it in the same place.
I have tried many things such as using the timer utilities.
Right now, when I pause it, 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, playSong);
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 pause method - when you pause store the position property of the channel object - and then when you play, use the position to play from.
var pos:Number = 0;
play Btn:
channel = song.play(pos);
pause Btn:
pos = channel.position;
channel.stop();

Similar Messages

  • Nokia 101 music player play only first 20 songs

    hi friends ... i have a problem...whenever i download songs in my memory card,my music player play only first 20 songs,and other songs show me format error.... please help me what can i do with this ????
    Moderator's notes: Moved into it's own thread

    I am experiencing exactly the same problem. I recently purchased Nokia 3555 and HS-49 headset to listen to music in stereo. However, I only get mono sound from the right. I called customer care services before I purchased HS-49 and they said it's compatible with Nokia 3555. Yes, I can listen to music, but it's not in stereo. I turned on "stereo widening effect," but it doesn't change anything.
    Accoring to the catalog on the web, the phone has stereo bluetooth capability...So, I think it should also produce stereo sound through a wired stereo headset especially with HS-49 which is listed as a compatible headset.
     I really appreciate if anybody can teach me how to listen to music in stereo on my Nokia 3555.
    Thanks

  • Please Advice AS3 Music Player

    Please advice. I am planning to write a program to a music
    player in AS3. The final player have to option like browse the
    computer and select the music files and play. similarly like
    realplayer/winamp. Is there any way to browse files from system
    using fla/swf file. If it is please advice.

    you can do that in action script
    create a button and name it browseBtn. and in actions layer
    put this code
    browseBtn.addEventListener(MouseEvent.CLICK, browseListener);
    function browseListener(evt:MouseEvent):void {
    file.browse();
    in this way you can browse the files on ur system
    browse method also accept filefilter parameter that is null
    bydefault so you can also put a file type filter like mp3, avi, gsm
    sound types etc
    if u feel any problem then i am here to guide you.
    Regards
    maani janjua

  • 3500 Classic Music Player Play Playlists

    Hi,
    Can some one help me with this issue.
    I created playlist using nokia music manager and music player is not able to play the same and get error message.
    I tried creating a playlist using phone and editing the same by music manager but still not able to play it dont get error message but nothing happens.
    I can just put songs in the favorites and thats atmost i can do...
    Please help me with the same.
    Thanks & Regards,
    Mohit

    STEP1:- You have to empty favourites first as follows:-
    MUSIC LIBRARY > MY TRACKS > FAVOURITES > CLEAR TRACK LIST
    ( Now favourites is empty )
    STEP2:- Select your desired songs and fill them in favourites as follows:-
    Browse Artists or Album or Genere or Most played or Recently Added or Recently played or Never played -- and -- Select song and Add to favourites.
    ( Now favourites is filled with your desired songs)
    Step3:- Save your playlist as follows:-
    OPEN FAVOURITES > PLAY (songs) > OPTIONS > SHOW TRACKS > OPTIONS > SAVE AS PLAYLIST > Name your playlist > save(ok)
    ( Now your playlist is saved in "My Tracks" )
    To play your playlist, you go to MUSIC LIBRAY > Track lists > My Tracks > NOW PLAY your playlist
    ( Now your playlist gets loaded in 5 seconds and starts playing )
    (Note:- Kindly fill your desired songs not more than 25 to 35 in each playlist otherwise it will take much time for loading when you play. These playlists are advandced .m3u file playlists. .m3u file playlist is nothing but a kind of playlist consisting of mp3/acc/etc., format songs)
    If you want to CREATE another YOUR OWN PLAYLIST, kindly do the above said 3 STEPS . You can create lots of playlists now. I hope that you are happy with this details.
    Enjoy and Be happy
    Thanks a lot
    Moderator Note: Email address removed
    Message Edited by prodigy on 18-Dec-2008 07:36 AM

  • MP3 Player Play/Pause?

    I'm making an MP3 player.  I can't get the play/pause toggle to work.  I'm not sure how to have the event be toggled on and off. Sorry, I'm a newbie to flex.
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:net="flash.net.*" xmlns:media="flash.media.*" creationComplete="mySound.load(myURLReq)" themeColor="#000000" borderColor="#000000" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FFFFFF, #FFFFFF]">
        <mx:Script>
            <![CDATA[
                private function appInit():void {
                    stage.addEventListener( KeyboardEvent.KEY_DOWN, keyPressHandler );
                private function keyPressHandler( e:KeyboardEvent ):void {
                    // if the spaceBar is pressed then toggle play/pause
                    if( e.charCode == 32 ) {
                        if( this.focusManager.getFocus() != toggleBtn ) {
                            this.focusManager.setFocus( toggleBtn );
                            // whatever happens when you click on the button you place here
                            // it's best to have a 'clickHandler' that calls another method
                            toggleBtnHandler();
                private function clickHandler( e:Event ):void {
                    toggleBtnHandler();
                private function toggleBtnHandler():void {
                    if( toggleBtn.label == "PLAY" ) {
                        toggleBtn.label = "PAUSE";
                    } else {
                        toggleBtn.label = "PLAY";
            ]]>
        </mx:Script>
    <mx:Button id="toggleBtn"
            x="10" y="70" toolTip="Press the spacebar to toggle label"
            click="clickHandler( event );"
            label="PLAY"/>
       <mx:Number id="myPos">0</mx:Number>
       <net:URLRequest id="myURLReq" url="01-amy_macdonald-dont_tell_me_that_its_over.mp3" />
       <media:SoundChannel id="mySoundChannel" />
       <media:Sound id="mySound" />
       <mx:Panel title="MP3 Player">
         <mx:Text id="prog" />
         <mx:ControlBar>
           <mx:Button id="play" label="PLAY" click="mySoundChannel = mySound.play(myPos, 0, null);" />
           <mx:Button id="pause" label="PAUSE" click="myPos = mySoundChannel.position; mySoundChannel.stop();" />
           <mx:Button id="stop" label="STOP" click="mySoundChannel.stop();" />
         </mx:ControlBar>
       </mx:Panel>
    </mx:Application>

    http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=15&catid=288&threadid =1248142&highlight_key=y&keyword1=mp3
    http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=15&catid=288&threadid =1249411&highlight_key=y&keyword1=mp3
    http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=15&catid=288&threadid =1247499&highlight_key=y&keyword1=audio

  • My 5610 music player plays so softly that I can ha...

    I can't get the volume to work on my 5620 music player. I have used the volume buttons on the side but it doesns't do anything.
    Have noted a bar guide on side that might indicate the volume bars are set low but can't move them up. Anyone out there know how to fix this would greatly appreciate it,

    press the d pad to the right or leftor up and down this works when playing a tone on phone the side keys should work whilst in play mode
    If  i have helped at all a click on the white star below would be nice thanks.
    Now using the Lumia 1520

  • N-series Music Player plays album tracks in alphab...

    This bug is still in the N85 firmware (V 30.019). So the firmware has now been updated twice, with the error still in it.
    However, I have found a workaround, that is easy to use and does not require too much work. It's a bit on the geeky side, I'm afraid, but not that difficult.
    The Problem
    I have found that N85 (and presumably many other N-series devices as well) cannot correctly read and play music albums, but instead plays the tracks in alphabetical order. The same occurs no matter how you transfer the audio to the device. Even thought the Music Player cannot read the tags in the MP3 files, but it does handle M3U playlists correctly.
    Background
    [A short explanation for those of you who don't know what M3U playlists are. They were originally developed to be used with the computer music player WinAmp, but have since become a rather common little tool. Playlist is basically a text file, with a name like michael_jackson_thriller.m3u, that lists the contents of a music album (or indeed any other collection of music that you like) and describes the sequence of music files to be played. It sort of tells the music player application what you want to hear and in what order.
    When you double click an M3U playlist in your computer, your music player software will open and play the music files in that playlist, automatically. In other words, a playlist does not contain any music, but instructions about where to find them in your computer's or device's memory. You can use playlists in your Nokia N-series phone's music player as well.]
    The Solution
    Always include an M3U file with each album that you transfer to your phone. Then, instead of the album open the corresponding playlist and hey presto! it plays correctly. As an added bonus, you get noticeably shorter gaps between tracks, which is especially nice when you play mixed music (like DJ sets or classical music). Please note that you can't use PLS files (another common playlist format).
    What you want to do is get a helper application to your computer that can easily (or even automatically) create playlists, and then transfer them to your device's Music folder in mass media mode. The simply update your Music Library in your phone and go to Playlists in the Music Player.
    I have found the following (Windows) applications particularly useful.
    Oddgravity Playlist Creator
     A compact tool that creates playlists automatically. I usually select one folder (one album), let the app create the playlist in the same folder, and than just drag (copy) the folder to my phone's mass memory. The whole thing takes something like 60 seconds.  
    iTunes Export
     A tool that turns your iTunes playlists into M3U playlists. Can be fully automated.
    Medieval CUE Splitter
    If you use CUE files to split whole albums, this app can create M3U files while you split the album file.
    PS Otherwise I think that Carthage should be destroyed, and that Nokia really should fix that bug! 
     tommi_p

    NO .
    E series have the basic features of NOKIA'S music player while hi-end Nseries phones have extra software wise better performance and some of them have better audio chip.
    Why is this?
    Just to distinguish it is an ESeries phone and that is a Nseries?

  • [AS3] Music Player - Progress Bar

    I have created a topic on help with a play/pause button that was solved and now I moved onto the progress bar.
    Now I need more help because I seem to be getting some errors.
    I will post only the progress bar coding.
    var dragSpace:Rectangle;
    var percent:Number;
    var seeking:Boolean;
    class SeekControl extends MovieClip {
        function seekControl() {
            dragSpace = new Rectangle(0, 3, 167, 0);
            seeking = false;
            percent = 0;
            seekHit.addEventListener(MouseEvent.MOUSE_DOWN, dragHandle);
            seekHandle.addEventListener(MouseEvent.MOUSE_DOWN, dragHandle);
            seekHandle.addEventListener(MouseEvent.MOUSE_UP, endDrag);
        function dragHandle(event:MouseEvent):void {
            seeking = true;
            seekHandle.startDrag(true, bounds);
        function endDrag(event:MouseEvent):void {
            seeking = false;
            seekHandle.stopDrag();
            fillBar.x = seekHandlc.x – fillBar.width;
            percent = 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', Frame 1, Line 53    1093: Syntax error.
    Scene 1, Layer 'Actions', Frame 1, Line 53    1084: Syntax error: expecting rightbrace before fillBar.
    Scene 1, Layer 'Actions', Frame 1, Line 59    1093: Syntax error.
    Scene 1, Layer 'Actions', Frame 1, Line 59    1084: Syntax error: expecting 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 minus signs in those equations appear to be something other than ascii-text.  I get the small dark vertical rectangles in their place.  So that is probably the issue.
    I f I use Notepad they appear normally though.  And I don't see anything wrong with the code syntax per the intent.

  • Lumia 520 music player gets paused automatically!

    I got this problem from today morning. Whenever I play any music file on my speakers it gets paused automatically after a few seconds of playing and when I play it again it gets paused again. I have been facing this problem only while playing music on my speakers whereas when I play it on my headphones it works perfectly fine. Can anyone please suggest a solution. Thank you
    Solved!
    Go to Solution.

    strange indeed mate, shouldn't be the case. have you checked that you are up to date with the latest firmware for your device, and also that you are up to date with the latest Nokia system app updates from the Store? also try performing a soft reset, and check that your back cover has no damage etc.

  • N95 - how do I stop Music Player playing my sound ...

    I'm listening to songs on the bus, and suddenly, I've got a 2 minute recording of my other half snoring in my headphones. Or a 30 second sound clip of a man giving me directions to the Ikea store. Or a memo to myself to check the price of blu-ray players.
    For Goodness sake, music is music. Sound clips are not music. Can't the N95 tell the difference?
    I've looked everywhere on the phone for an option to stop this annoying feature, but I can't find anything.
    I'd move my sound clips to my PC, but Lifeblog won't touch 'em.
    Thanks.
    Tiburonsmoke  /

    Thak you. I'll give it a go. Really, I shouldn't have to go to these lengths, but if it works...  
    I don't know if my reply will be allowed to stay up here, but - for the record - the N95 is a truly mediocre phone, IMHO. 
    I went to the trouble of updating the firmware a few months ago, only to find that the most obvious bugs (slider crashes, predictive text glitches (my phone substitutes 'upx' for 'try' and 'rage' for 'said' and won't let me cancel them), camera software that blatantly ignores exposure settings +/-ev, etc.) WEREN'T FIXED.
    That's right, they WEREN'T FIXED.
    I took a look at the N97 the other day, and changed my mind. If Nokia can't get the N95 right, I'd be mad to get an N97.
    Thank you once again. 
    Tiburonsmoke (smoking from the ears)

  • Music player will only play audio on Music Videos

    I agree. On the iPhone (4) with iOS5 in the Video player you have a all your Movies, TV Shows, Music Videos and Podcasts that can be played individually, with no Shuffle option. If you use the Music Player you can you have all your music and you can Shuffle a Playlist, you can Shuffle an Artists, you can Shuffle an Album and you can Shuffle by Podcast album. Since the Music Player plays videos correctly this would seem to be the correct solution: use Music player instead of Video player.
    Like the iPhone, on the iPad (1G) with iOS5 the Video player doesn't Shuffle, each video (Movie, TV Show, Music Video and Podcast) must be played individually. However, on the iPad, the Music player DOESN'T play Music Videos correctly (it tries, but repeated selecting the video image to bring the video to fore actually causes the Music player to crash). It plays the audio only and provides on a preview size snapshot from the video. So while you can start playing one video and selecting the Shuffle button on the right side of the Track Status and the song will play and will Shuffle when done, there is no actual VIDEO playing. Clearly the application is broken.

    Actually there is no legit way at all to downgrade.
    Restore wiil always restore to the latest available software.

  • Music player problem after 2.3 update

    Hi all,
    I updated my x10i to 2.3.3. After the update most of my music on sd card was not showing up in the music player. Some of them are, but majority is missing. Every piece of music is ripped with Windows Media player and transferred with PC companion. I can play them if I navigate there with file manager and open manually. Music player plays them, but says "unknown". They were all working fine before the update. How to fix this problem?
    BR,
    Antti

    Unfortunately this appears to be fairly standard across the board from what I have seen in regards to the .wma file extension. What I would advise to get you around this would be to use the MediaGo software to transfer these files back to the handset so that they are converted to a supported format. I apologise for any inconvenience this may cause.
    http://mediago.sony.com/enu/introduction/
     - Official Sony Xperia Support Staff
    If you're new to our forums make sure that you have read our Discussion guidelines.
    If you want to get in touch with the local support team for your country please visit our contact page.

  • Media buttons not responding when music is playing in background

    Hi All,
    I have listened to some music today on my Curve 8520 and I just realized a problem.
    When I play the music, I'll go back to the home screen, while music is still playing the background, i tried to pause the music using play/pause button at the top of the phone but it didnt work, so i tried the other two button which is the previous and next track button, they both dont work either.
    So I go back to now playing part on my phone, so i can see my music playing, and then I tried the top 3 media button and it all works fine so I know there isnt any wrong with the buttons themselve.
    Does any one know why when the music is playing in the background, the top 3 media buttons doesn't work?
    Thanks

    Check out bugs 2200274 and 2008854. I think it was fixed in patchset 10.
    Regards,
    Robin Zimmermann
    Forms Product Management

  • Stop music being played from speaker when disconne...

    Hi, i have a bluetooth car radio which i use for streaming music from my n95, however when i switch on or off the ignition the bluetooth disconnects causing the speakers to activate. The same applies to when im listening through headphones and the cable disconnects, does anyone know of a solution to this short of taking the speaker out?

    I think it would be extremely annoying to me if I had to answer a Pop-up window every time the headphones are dissconnected and I'm listening to music asking "are you sure you want to switch to speaker mode?" and have the music muted.
    And I'm sure a lot of people will think it's a bug if the music player will pause when you lose connection to BT headset. Wouldn't you think so?
    640K Should be enough for everybody
    El_Loco Nokia Video Blog

  • Music player in control center doesn't work in iOS 7

    I can't even use music player with pause, forward or anything in control center. If I wan't to skip to next song I have to slide the track till the end to go to next song.
    And I can't even use my bluetooth control too.

    Switch off and then switch on again solved the issue for me...

Maybe you are looking for

  • Unable to install Creative Cloud in Windows 8.1

    I've also tryed installing Adobe Applications Manager as part of a potential fix, however get the same to responses. One is that some of the files can;t be opened due to sucurity issues The other tells me I need to run it as an Administrator, which I

  • How to update record in Table control

    Dear Friends,   I have table control that has space for 10 records but i need to update 15 record from the flat file which is getting into the table how can i do this. Regards, MAHENDRA.

  • How to send a iweb file or project via email?

    I've done a web site using iweb. My client requested it so he can update and change it himself using iweb. How can I send it to him via email? I tried sending the "domain" file but it's not supported as an attachment. Is there a solution, or the only

  • Failed to mount database "General Users". Error: An Active Manager operation failed

    Failed to mount database "General Users". Error: An Active Manager operation failed. Error: The database action failed. Error: Database 'General Users' on server 'EX02' cannot be mounted due to a previous error: At '12/3/2014 3:52:17 PM' the Exchange

  • Illustrator CS4 won't open any files since installing CS6

    Every since I installed CS6, whenever I try to open files in Illustrator (all files, not just the new downsaved from CS6 files), the program goes into "Not Responding" and I can't do anything until I crash out. It also will not let me create new file