Git Product home page Git Product logo

avbidirectionalqueueplayer's Introduction

This is a basic library to extend AVQueuePlayer to provide the ability to play previous items (IE move backwards in the queue). This is impossible with the normal AVQueuePlayer, since when an item is finished playing it is removed from the queue for good. This class gets around that by maintaining a copy of the array of the array used to initialize the queue and keeping an index integer, and re-populating the queue from the previous item when the 'play previous song' message is sent. This is useful if you want a more-or-less fully fledged music player, but do not want to use MPMediaPlayer for whatever reason.

It should be noted that since this class both maintains a copy of the array used to create it and re-creates the queue when necessary, this class uses a bit more memory than the normal AVQueuePlayer, and requesting a previous song can be slow. In testing we have found this imperceptible unless the array of items you're initializing is gigantic, but if it's vital that your app squeezes out every bit of performance possible; or you do not need to be able to play a previous song, we recommend that you use AVQueuePlayer instead

This class works the same way as AVQueuePlayer, but with the following methods added:

-(void)playPreviousItem
This method pauses the AVQueuePlayer, clears the queue, and re-populates the queue using the array that the player was generated with, from the prior song on. It then re-sets the seek time to 0 and plays the player. The overall effect is that of playing the previous song in the queue.

-(Boolean)isAtBeginning
This method simply returns true if the player is playing its first item, and false if it is not.

-(int)getIndex
This method returns the index in the queue of the currently playing element.

LICENSING INFORMATION: This code is released under a 2-clause BSD license. In a nutshell, that means that you're free to modify or use this code in any project you want (including commercial products). You don't need to release the code of any project in which you use this library and your code does not itself need to be licensed under the BSD license. However, you may not remove the license text from the source code of this library, and you must credit this library (and me, Daniel Giovannelli, as its creator) somewhere in the app. 

Also, though it's not required, if you do wind up using this library feel free to drop me an email at [email protected] and let me know what you're using it for - I'm always interested in seeing how people use the things I make.



______

CHANGES
2014/07/16  (JRTaal) Greatly simplified and cleaned up code, meanwhile fixed number of bugs.
                     Renamed to more apt AVBidirectionalQueuePlayer

avbidirectionalqueueplayer's People

Contributors

dgiovann avatar jrtaal avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.