Check for last button tap Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!How to check for an active Internet connection on iOS or macOS?How do I check if a string contains another string in Objective-C?How to check iOS version?Push a new view on button tapUsed XCTesting to tap on tableview cellsDoes Looping remotely fetched video in AVPlayer cause redownload?How to highlight a button without holding it in?Play Next Song AVAudioPlayerAVplayer won't play audio from url in lockscreen or backgroundMPMediaPlayer prepend not keeping track of queue

Nose gear failure in single prop aircraft: belly landing or nose-gear up landing?

Random body shuffle every night—can we still function?

Can you force honesty by using the Speak with Dead and Zone of Truth spells together?

If Windows 7 doesn't support WSL, then what is "Subsystem for UNIX-based Applications"?

Would color changing eyes affect vision?

Tips to organize LaTeX presentations for a semester

Resize vertical bars (absolute-value symbols)

Did any compiler fully use 80-bit floating point?

Rationale for describing kurtosis as "peakedness"?

Is openssl rand command cryptographically secure?

What would you call this weird metallic apparatus that allows you to lift people?

Mounting TV on a weird wall that has some material between the drywall and stud

After Sam didn't return home in the end, were he and Al still friends?

Does the Black Tentacles spell do damage twice at the start of turn to an already restrained creature?

What is the origin of 落第?

Asymptotics question

A proverb that is used to imply that you have unexpectedly faced a big problem

What does Turing mean by this statement?

Is there hard evidence that the grant peer review system performs significantly better than random?

Getting out of while loop on console

How much damage would a cupful of neutron star matter do to the Earth?

What order were files/directories output in dir?

Monty Hall Problem-Probability Paradox

I can't produce songs



Check for last button tap



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!How to check for an active Internet connection on iOS or macOS?How do I check if a string contains another string in Objective-C?How to check iOS version?Push a new view on button tapUsed XCTesting to tap on tableview cellsDoes Looping remotely fetched video in AVPlayer cause redownload?How to highlight a button without holding it in?Play Next Song AVAudioPlayerAVplayer won't play audio from url in lockscreen or backgroundMPMediaPlayer prepend not keeping track of queue



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








-3















I'm using an AVPlayer and when I click the forward button to go to the next song it automatically downloads the song As expected. But if I click the forward button many many many times the app gets very laggy. So is there a way to call the function of the forward button if it isn't tapped for example for Two seconds?
I'm using Xcode 10 with Swift 4.2 and Firebase for downloading the URL and passing it in the AVPlayer with AVPlayerItem(url: url)










share|improve this question






























    -3















    I'm using an AVPlayer and when I click the forward button to go to the next song it automatically downloads the song As expected. But if I click the forward button many many many times the app gets very laggy. So is there a way to call the function of the forward button if it isn't tapped for example for Two seconds?
    I'm using Xcode 10 with Swift 4.2 and Firebase for downloading the URL and passing it in the AVPlayer with AVPlayerItem(url: url)










    share|improve this question


























      -3












      -3








      -3








      I'm using an AVPlayer and when I click the forward button to go to the next song it automatically downloads the song As expected. But if I click the forward button many many many times the app gets very laggy. So is there a way to call the function of the forward button if it isn't tapped for example for Two seconds?
      I'm using Xcode 10 with Swift 4.2 and Firebase for downloading the URL and passing it in the AVPlayer with AVPlayerItem(url: url)










      share|improve this question
















      I'm using an AVPlayer and when I click the forward button to go to the next song it automatically downloads the song As expected. But if I click the forward button many many many times the app gets very laggy. So is there a way to call the function of the forward button if it isn't tapped for example for Two seconds?
      I'm using Xcode 10 with Swift 4.2 and Firebase for downloading the URL and passing it in the AVPlayer with AVPlayerItem(url: url)







      ios swift avfoundation






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 9 at 1:25









      rmaddy

      247k27329394




      247k27329394










      asked Mar 8 at 23:03









      SwiftNewlingSwiftNewling

      30815




      30815






















          2 Answers
          2






          active

          oldest

          votes


















          0














          You could capture the time and implement your code. Try this code:



          var lastTap:Date = Date(timeIntervalSince1970: 0)

          func buttonTapped(sender:Any)
          // Checks if it has been tapped in the last two seconds
          if (Date().timeIntervalSince(lastTap) < 2)
          return

          lastTap = Date()

          // Perform playing
          playSong()






          share|improve this answer























          • not working. Found another way that worked myself

            – SwiftNewling
            Mar 9 at 10:21


















          0














          This works:



          var timer: Timer!


          in Button action:



          if let timer = timer 
          timer.invalidate()

          timer = Timer.scheduledTimer(timeInterval: 0.5, target: self, selector: #selector(play), userInfo: nil, repeats: false)


          @objc func play()
          self.play()






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55072211%2fcheck-for-last-button-tap%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            You could capture the time and implement your code. Try this code:



            var lastTap:Date = Date(timeIntervalSince1970: 0)

            func buttonTapped(sender:Any)
            // Checks if it has been tapped in the last two seconds
            if (Date().timeIntervalSince(lastTap) < 2)
            return

            lastTap = Date()

            // Perform playing
            playSong()






            share|improve this answer























            • not working. Found another way that worked myself

              – SwiftNewling
              Mar 9 at 10:21















            0














            You could capture the time and implement your code. Try this code:



            var lastTap:Date = Date(timeIntervalSince1970: 0)

            func buttonTapped(sender:Any)
            // Checks if it has been tapped in the last two seconds
            if (Date().timeIntervalSince(lastTap) < 2)
            return

            lastTap = Date()

            // Perform playing
            playSong()






            share|improve this answer























            • not working. Found another way that worked myself

              – SwiftNewling
              Mar 9 at 10:21













            0












            0








            0







            You could capture the time and implement your code. Try this code:



            var lastTap:Date = Date(timeIntervalSince1970: 0)

            func buttonTapped(sender:Any)
            // Checks if it has been tapped in the last two seconds
            if (Date().timeIntervalSince(lastTap) < 2)
            return

            lastTap = Date()

            // Perform playing
            playSong()






            share|improve this answer













            You could capture the time and implement your code. Try this code:



            var lastTap:Date = Date(timeIntervalSince1970: 0)

            func buttonTapped(sender:Any)
            // Checks if it has been tapped in the last two seconds
            if (Date().timeIntervalSince(lastTap) < 2)
            return

            lastTap = Date()

            // Perform playing
            playSong()







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Mar 8 at 23:48









            Amir.n3tAmir.n3t

            192111




            192111












            • not working. Found another way that worked myself

              – SwiftNewling
              Mar 9 at 10:21

















            • not working. Found another way that worked myself

              – SwiftNewling
              Mar 9 at 10:21
















            not working. Found another way that worked myself

            – SwiftNewling
            Mar 9 at 10:21





            not working. Found another way that worked myself

            – SwiftNewling
            Mar 9 at 10:21













            0














            This works:



            var timer: Timer!


            in Button action:



            if let timer = timer 
            timer.invalidate()

            timer = Timer.scheduledTimer(timeInterval: 0.5, target: self, selector: #selector(play), userInfo: nil, repeats: false)


            @objc func play()
            self.play()






            share|improve this answer



























              0














              This works:



              var timer: Timer!


              in Button action:



              if let timer = timer 
              timer.invalidate()

              timer = Timer.scheduledTimer(timeInterval: 0.5, target: self, selector: #selector(play), userInfo: nil, repeats: false)


              @objc func play()
              self.play()






              share|improve this answer

























                0












                0








                0







                This works:



                var timer: Timer!


                in Button action:



                if let timer = timer 
                timer.invalidate()

                timer = Timer.scheduledTimer(timeInterval: 0.5, target: self, selector: #selector(play), userInfo: nil, repeats: false)


                @objc func play()
                self.play()






                share|improve this answer













                This works:



                var timer: Timer!


                in Button action:



                if let timer = timer 
                timer.invalidate()

                timer = Timer.scheduledTimer(timeInterval: 0.5, target: self, selector: #selector(play), userInfo: nil, repeats: false)


                @objc func play()
                self.play()







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 9 at 10:23









                SwiftNewlingSwiftNewling

                30815




                30815



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55072211%2fcheck-for-last-button-tap%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    1928 у кіно

                    Захаров Федір Захарович

                    Ель Греко