I am developing a Deezer Web Player here http://deezer.gopagoda.com, but I am facing the problem that I don't know how to add the same song multiple times to list with the DZ.player.addToQueue method... Every time I add a song, I print the Queue Object and I get the song only once!!
I know that's not the best way, but you could use DZ.playTracks with several times the same track id. I'd agree with you that you wouldn't be able to dynamically change the queue, but I don't see any other solution for now.
Related
I'm in search of a best practice approach to schedule playlists using Liquidsoap. My current approach creates plenty of delays, hence not meeting the requirements for seamless playback.
Requirements:
After scheduling a new playlist is due to be scheduled, it should remove all previously scheduled playlist-items.
Avoid any delays when clearing previously queued playlist-items.
My current implementation:
Schedule a bunch of files (represent a playlist) by pushing them to an equeue
This queue starts playing
When the next timeslot is due, a new playlist cannot simply be queued, because it would only start after all tracks queued by the previous playlist are finished playing. Because of this, I'm removing all tracks of the previous playlist first using a Liquidsoap server script. This process is time-consuming and delays the timely execution of step 4.)
Schedule the new files by pushing them to an equeue.
How can I do this more elegantly?
Is it possible to clear an equeue w/o creating delays?
If there are "more correct" Liquidsoap features to achieve this, like a playlist (can I control when it is actualy played?) or request.dynamic (which is deprecated) instead of an equeue, please let me know.
Update: I'm currently using two queues: A and B. One minute before queue A should be playing I populate it with tracks (playlist). When it should be actually playing I turn up the volume. Then, one minute before queue B should be playing I populate this one. When it's actually time to be played I transition the volume from queue A > B. In theory this solution would be fine, but the issue here is that I'm not aware of a way that the queues pause until I turn up the volume. The tracks already seem to start playing at the very moment when the queue/playlist is filled.
It's hard to tell without reading the complete script, but I'm sure it's not possible to pause a queue. At best you can remove an item via the server interface: if it's the currently playing item and it's alone in the queue, then it will stop that queue. You might be interested by the Beets examples, that discuss how an external program can populate sources.
To switch from playlists A to B, the Liquidsoap way is to populate B exactly when it's time and an operator like fallback will make the transition. See also fallback.skip.
I am working on radio application where i need to convert speech to text. For that i am using third party api's. For geting better results i want to run two api's at the same time and compare the output. this should happen when user clicks on record button.
I know we can do this using GCD but not getting exact idea of how we can achieve this.
Need suggestion.
Thank you.
Th short answer is that you create two GCD queues, one for each Speech-to-Text task. Within each block, you call the two different APIs with the same input data. Then you either wait for the result, or get the block to invoke a callback status method when completed.
Note that you will need to ensure that the speech engines can safely run on background threads.
This is fairly straightforward if you want to record the audio first, then submit the data to two different engines for processing. But it sounds like you might want to start processing the audio as soon as the user clicks Record? In that case, it very much depends on the APIs as to how you feed them data in real time. You might want to just run them on separate threads explicitly and feed them data as it comes in.
Thanks to the updates to GameKit API in iOS 6, I am finally able to implement my turn-based board game the way it should be, complete with turn timeouts and better programmatic creation of matches. However, I am running into an issue that I cannot seem to solve. My desire is to have Game Center running entirely invisible to the end-user, so that everything is programmatic and uses my own custom interfaces.
Therefore, I use my own custom table view to display matches, not the default GKTurnBasedMatchmakerViewController. Right now, I have no problem displaying open matches using the -loadMatchesWithCompletionHandler: method. I also use a custom screen to create a match, with a direct creation for auto-match (not a problem) and a table view that loads Game Center friends of the localPlayer for invitation. Since the playersToInvite attribute can now be filled with playerID's, this is possible in iOS 6.
My main problem is handling the invitation on the recipient's side. Lets say I invite Bob to play my game in a two-player match. Right now I can't seem to find a notification for a new invite on Bob's end. The -handleTurnEvent: only gets called for existing matches or if the banner notification is touched (which I can't guarantee the user will do), and -handleInviteFromGameCenter: does nothing for me in this case.
The only way I have come up with to detect new invites and thus update my custom game view controller is to call the -loadMatchesWithCompletionHandler: method and check for new matches in which lastTurnDate of the invited participant is nil and against an existing array of open matches. I run this check about every 10 seconds in the background since I can't find a notification in GKTurnBasedEventHandler that is called when a new invite is received. Please help!
EDIT: In the end, I have just implemented a pull-to-refresh functionality. There is no way without implementing polling or some other method that would just waste the user's data on their phone, so on demand refreshing is the most ideal solution in my opinion.
Please see this : GKInvite Reference and more specifically inviteHandler.
You just need to register an inviteHandler which will be called after Bob accepts the invite in GK/GC.
T.
I'm currently working on a new game for iOS using Cocos2D. The game needs to advance states after x amount of time since the first launch. So for example:
State - Time
initial launch
24hrs
48hrs
My first idea was to just get the data and time on first launch and save it to a file. Then I could check it ever now and again to see how much time has passed. The problem with this is I need it to be in realtime so that the changes will take effect immediately once the state is reached. It also needs to continue when the user is not using the app. The functionality I'm looking for is kind of similar to how the iOS strategy games work where you build structures that take x amount of time.
Anyway my question(s) is; is there some sort of library that can accomplish this and how can I get it to continue after the user exits the app?
It can't. There is - apart from kind of misusing video/music playing etc. no way for your app to do work while it is not running.
You have two things you can do to simulate that behavior (and I suppose the strategy games do this, too):
You can calculate at any time while a user is still running your app the points in the future when something should happen (eg a housing structure is finished). When the user leave your app, store these future times as local events - then the user will get notified that something has happened in your game (eg message "The church has been built. Do you want to go to church now?)". Pressing yes will open your app, and you can do whatever is necessary to indeed build the church. So in fact you don't do it at the time when it occurred, but when the user opens your app the next time.
Like 1, but without notification. Just remember when the user leaves the app (eg in your settings, I would use a property list; set it when the app delegate gets the appWillResignActive event), and the next time he starts do whatever would have been done in the meantime - he won't be able to tell the difference :-).
It's all about make believe here :-).
When using in-app audio in the iPhone SDK, it is possible to allow users to select a list from their ipod library and create an in-app local playlist. If I want to persist this choice, it is easy to serialize the data and write to file, then recover.
Just vanilla like this, however, leads me to think there is going to be something wrong. For example, what if the user syncs and removes sounds? I can loop across them all and query the iPod DB at setup time, but with lists that could be 50,000 long, this could take some time.
How are other people doing this and what are some gotchas that I haven't though about?
I would just do it lazily,
If a user wants to play a song, you could query the iPod DB, for that song in particular and maybe the whole song "Album" in case the user removed the Album. This would require two requests to the database before playing each song, but you could benchmark if it's fast enough, etc.
You could also put an option somewhere to "sync" the application with the iPod DB, but given as a choice for the user, giving the user a "warning" that it could take a while, maybe even giving him a time estimation for the size of his particular library.
I think that from a usability/battery saving point of view, this would be better than querying the whole database each time your application starts, or even in the background.
I initially posted a response around saving the individual MPMediaItems. After some thought and a reread of the documentation for MPMediaPickerControllerDelegate, I think the approach to use is to save the representiveItem property of the MPMediaItemCollection and use that to construct an MPMediaQuery at runtime.