run a media application background with UI while in screen lock - android-service

How could I continue to play media even with screen lock?
The player has a progress bar that shows how far the current music has been played and there is a list of songs to be played.
When screen is locked, the player stops after about 1 minute and resumed when screen is unlocked.
Some suggestions were to use Services but from my understanding, to communicate with the progress bar, objects are to be serialized and used as input variables of an intent putExtra in the startService(new Intent(this, MyMediaPlayerClass.class));
What other approaches could I try?

Related

Youtube iframe api. Player state gets stuck on BUFFERING state on mobile devices

For my app I need to constantly monitor the state of the youtube player but for some reason onStateChange behaves differently on desktop and mobile. In particular I have the following problem: when I try to change the current time of the player to the point that is not buffered yet and the player is currently in PAUSED state, it switches to the BUFFERING state and never goes back to PAUSED state even after it finishes buffering. On the desktop it switches to BUFFERING and then back to PAUSED which is exactly what I want.
I use custom loading overlay when the player is buffering so this behavior complete breaks the functionality. The overlay just gets stuck on mobile devices forever.
If anyone experienced similar issues please let me know.
Thanks.

iOS multitasking switcher system image vs application image discrepancy workaround

It seems to me that the system takes a different screen capture that the one my app takes on applicationWillResignActive.
To my surprise there is a delay of about 0.6 secs between the image taken by the system (b) and the image taken by the game (d). It kind of makes sence if the system needs to take the screen capture before applicationWillResignActive, but for a game with fast moving objects this can be easily noticed by the player.
How can I workaround this?
The following are the steps the player makes and how it causes such discrepancy:
(a) The player pulses the home button when she is playing. (b) The system screen capture is taken. (c) The player taps the game icon. (d) The game is launched with the screen capture taken on applicationWillResignActive. (e) The game is paused showing the discrepancy in a fast moving object.
I believe this is because your game rendering is not on main thread(certainly it shouldn't be on main thread), so when applicationDidEnterBackground/applicationWillResignActive is returned, the system takes a screen shot from video card's buffer immediately.
At this time, your game loop thread is still running, so it may update some frames before it is paused.
I don't know how you implement your game loop, but you can try this:
In applicationDidEnterBackground/applicationWillResignActive, put a global semaphore(dispatch_semaphore_t) and block the main thread, in your game loop, observe the semaphore and if it exist, pause your game loop, then signal the semaphore.
This will assure that the screen shot is taken after your game is paused.
Also notice that after applicationWillResignActive, the system will take the snapshot for task switcher, and after applicationDidEnterBackground, the system will take snapshot for next time you app enter foreground.
Hope this will help you.

can I run movie player in background when mirroring to external screen - objective c

I have an application that plays video from local disk and when a second screen is connected (through AV composite cable) it switch the movie view to the external screen. this is working fine so far. what I want is, when the user press the home button and the app goes to background mode; I want to continue playing the video in the second screen while the app is running in the background mode. this works for audio, as I have set my application to continue play audio in background mode and it is working fine: the audio continue to play in the background mode fine. now is it possible to continue play video as well, and how?
This is not possible. It is outside of the scope of an iOS app to continue powering a screen while it is in the background.

How do I play an alarm sound and present a custom view instead of just a notification?

I'm working on an alarm clock application for iOS 4.x. The other alarm clock applications that I've seen are able to present the user with something other than a local notification (i.e., a custom view) and are able to play a sound file. I've been looking into how that's done and have only found this solution:
Play sound with screen turned off / don't let iPhone go to sleep
Is there another approach or is this the best practice?
When your app is not visible, you can't display anything. The silent sound workaround is a cool trick but when a user presses your home button, your app is not visible (and might get destroyed under certain conditions) -> therefore you can't display anything.
So if you tell your user to use your alarm clock by firing it up and then press the sleep button it will work - you can display anything on your screen after the user unlocks the iphone again.
Needless to say that playing sound (even silent sound files) drains the battery so your user might be disappointed if he's not woken up because his iphone has run out of battery.
And yes, there is best practice: Local Notifications! Beginning with iOS 5 it will display your apps icon next to the notification...

OpenNETCF DirectShowPlayerControl display is going black randomly when playing videos if the player is disposed and recreated

I have a application that runs on touch enabled device with WinCE 3.5 OS. I have a show player control to display adds when the system is left idle for some configured amount of time..
So the DirectShowPlayerControl will be iniated every time the show player is launched and will be destroyed when it is closed...
The player for the first time plays videos continuously for any amount of time. Once the player is destroyed and recreated the video are changing but the display goes black and in between if some small video is placed that alone is displayed.
Whenever the form is closed am calling DirectShowPlayerControl.Dispose() method.