Handle DONE buttons and video finish playing events in UIWebview - iphone

I have a UIWebview which will play a YOUtube video playlist, and I need to handle the events when user click DONE button and close the webview.
So far, the working solution i found is to handle UIMoviePlayerControllerDidExitFullscreenNotification, but when UIWebview finish playing a video in the list it will exit the fullscreen mode and enter back to fullscreen mode to play the next one. My app handles the event of exiting fullscreen as pressing DONE button and only the first song of the list get played.
My question is that is there anyway to handle DONE button click events without handling UIMoviePlayerControllerDidExitFullscreenNotification, or to handle those two events separately?

Related

AVPlayer background playing issue

I am playing Music from Url using AVPlayer and clicking on the play button will take some time to play because of buffering. There are two cases that i have explained below.
Success case: I am clicking on the play button and the AVPlayer buffers and starts playing. After the player have started playing i am pressing the home button and the application goes to the background and the playing continues.
Failure case: I am clicking on the play button and the AVPlayer starts buffering. I will press the home button and the application goes to the background while the AVPlayer is buffering and before its starts playing. AVPlayer doesn't play in the background even though play command is already issued.
and suggestions?
Thanks in advance,
Norbert
if the buffering takes more than 2 seconds, the task will be frozen before playback starts.
use
task = [application beginBackgroundTaskWithExpirationHandler:...
the second problem is that AVPlayer's status fails if trying to start playing in the background if you don't acquire the remote controls.
[application beginReceivingRemoteControlEvents];
One of those should fix the issue.

Continuous background audio with MPMoviePlayerController?

I am using MPMoviePlayerController to play streaming audio. I'm trying to get background audio working correctly. Right now, audio continues to play when you exit the app - the lock-screen and multi-tasking bar controls even work.
When a song finishes, the app is supposed to advance to the next track and play it. It works when the app is open but not when it is in the background (a song finishes but does not advance to the next track). If a song finishes and you re-open the app, however, the next song will start up immediately.
I am currently using NSNotificationCenter to keep track of when tracks end to advance to the next track (in my app delegate). Again, it works like a charm when the app is open. Is there a better way to do this to keep audio playing after a song is done?
I had this issue lately. Hope the answer helps other people.
If you have a playlist for example and want to play the next song while in background mode or lock mode add this line of code on your viewDidLoad:
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
This makes the app supports remote control events.

iPhone:Event when start video recording button clicked?

I like to know, are there any events can get triggered in our program whenever user is clicking on Camera start/stop buttons to record/stop the video?
From my application, it is possible to launch Video camera and start video recording and come back with the recorded video. I am using UIImagePickerController and didFinishPickingMediaWithInfo to get the data. It works fine. I want to handle something whenever user starts the video recording by clicking on built-in camera start button. Is it possible?
Please advise.
Thank you!
This is not possible using UIImagePickerController's default interface. You could however create a custom view (including a record button) and show it over the controller using the cameraOverlayView property. When the user presses your custom record button, call start/stopVideoCaptureā€”this would provide you with the information you're after.

MPMoviePlayerViewController method click on pause

I'm using MPMoviePlayerViewController and I want to know if there is a method that can tell me when the user clicks on the Pause button for the video, like an observer?
You should use MPMoviePlayerController instead :
Movie Player Notifications
The MPMoviePlayerController class generates numerous notifications to keep your application informed about the state of movie playback. In addition to being notified when playback finishes, interested clients can be notified in the following situations:
When the movie player begins playing, is paused, or begins seeking forward or backward
When the scaling mode of the movie changes
When the movie enters or exits fullscreen mode
When the load state for network-based movies changes
When meta information about the movie itself becomes available
For more information, see the Notifications section in this document.
http://developer.apple.com/library/ios/#documentation/MediaPlayer/Reference/MPMoviePlayerController_Class/MPMoviePlayerController/MPMoviePlayerController.html

Keep playing sound with MPMoviePlayerController and locked screen?

When you're watching a video with MPMoviePlayerController and the user presses the top button to lock the screen, the app goes to sleep and so does the sound from the video.
Is there any way to prevent the lock from stopping the sound? If not, is there a way to intercept the lock, to create a "custom lock", to save some battery but keep playing the video?
Sounds like you haven't set your audio session category. Set the AVAudioSession's category property to AVAudioSessionCategoryPlayback to indicate that the app's major purpose is to play back audio, and it therefore should ignore the screen lock button and ring/silent switch. If you're working with the lower-level C API, you'll be using AudioSessionSetProperty(kAudioSessionCategory_MediaPlayback), but it's the same concept.