control audio play in background - iphone

I have a tablewview and by click a table row a subview appear as player and play audio in my app . I added play in background mode and controls it while in background , it works .
The problem I have is , when I move to another view (exactly when the subview being disappear) I can't control or stop the audio.
how can I let the controls keep detect the audio playing while I'm in any other views of my app? also how can I let the subview appear when I back to my view again to allow stop or show the progress status?
I hope anybody can help

Please see the above link to find this solution and must read "Comment"... :)
Playing music in background ios app
another link may help you...iOS SDK : playing music on the background and switching views

You will have to keep a Strong reference to your view, or, at least, to your object currently playing a sound.
I'll suggest using a protocol between viewControllers to let the parent view controller catch the reference before dismissing the view containing the player.
You'll find much more explanation at Ray Wenderlich website's Audio playing tutorial.

Related

Embedded video in iPhone with smooth transition to MPMoviePlayerController

In the new American Idol app there are embedded videos that, if you tap them, start playing and showing "pause" and "augment" buttons. When you tap the augment button, you get an animation that smoothly launches the full screen MPMoviePlayerController. Do you know how did they make it?
I have implemented something like this by adding a gesture tap on that and implement the logic of the gesture. On a tap I have added a view with buttons like share (in my case). I am sorry I don't have that code anymore.

customising MPMovieplayer

In my new app,I have to show videos in MPMovieplayer.Client gave me the design as in screenshot
I want to know whether it is possible to customize like this(including the top like,skip buttons and the custom slider)
If it is possible,help me to learn more about that
You can do it pretty easily with AV Foundation specifically AVPlayer class, it is the framwork underneath MPMoviePlayer. It will give you the options to have an abstract video/audio player and you'll be able to create you own customize UI
Here's an example code to start with AVPlayer
AVPlayer will work, but I hear it can be more complicated than working with a more higer level solution like MPMoviePlayer. I've been working on making my own customized UI for a video stream using MPMoviePlayer.
Whenever you create your MPMoviePlayer object, just set control style to none with: MPMovieControlStyleNone this leaves your video player ready for you to make customize controls. I suggest using a UIToolbar and then setting UIBarButtonItems onto your toolbar. Once your toolbar has all your buttons, add the toolbar to the subview with the addSubview method. You can then add functionality to the buttons and slider with the MPMediaPlayback Protocol with methods like play and pause. By the way, the top like and skip buttons could just be UIButtons which are pretty customizable. Lastly, if you want the controls to disappear on a tap then look into Gesture Recognizers.
Of course you can style your buttons and position your toolbar as needed, but this should get you a basic start.
Here's a custom class I wrote that works in iOS6 and newer.
https://github.com/busterbooth/bbMoviePlayer
You can control and re-skin just about every aspect of the MPMoviePlayer as long as you do the following.
MPMoviePlayerController *mp= [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:#"http://example.com/video.file"]];
mp.controlStyle = MPMovieControlStyleNone;

UIImagePickerController pushed on my own UINavigationalController?

I'm trying to take the UIImagePickerController set to UIImagePickerControllerSourceTypeCamera (ie when it allows the user to take a picture) and push it on my own UINavigationalController but it doesn't work (can't push a UINavigationalController onto another UINavigationalController).
I'm wondering, is there anyway to make a custom version of this camera module, much like you can do with the UIImagePickerControllerSourceTypePhotoLibrary UIImagePickerController using ALAssets? I'd just like to not have to pop up the camera as a modal view and would like to push it on my own UINavigationalController.
You can custom camera using AVFoundation.
Refer Sample AVCam for how to use AVFoundation for it.
Your main issue is that the UIImagePickerController is itself a UINavigationController, so pushing that onto a navigation controller is going to have problems (as you've already found)
As Prince has mentioned, your best bet is to use the AVFoundation to create your own. The downside is you'll (by default) lose the nice features of the camera app such as touch to focus, pinch to zoom etc. but these can all be added yourself.
Check out this tutorial which gives you a nice explanation on how to use the AVFoundation library for this, and also shows you how to add things like an overlay to the camera screen. Then you can easily find on google/stackoverflow how to add things like tap to focus :)

video full screen with all controls disabled

I have a video that needs to be activated when scanning a qr-code. When starting a video needs to be shown full-screen and without controls (volume and other buttons). Is there a code for this? Also is it possible to disable all functions of the iphone, so the user needs to view the full video? I would be so greatfull f somebody would answer me..
You can set the controlStyle property of an MPMoviePlayerController to MPMovieControlStyleNone. You'll have a fullscreen movie with no controls. Just remember to set the delegate so you can dismiss the video when it finishes playing.

How Can I Implement Custom Previous/Next Buttons Over MPMovieplayer?

I have implemented a listing of videos in a UITableView. When I touch on a particular video then the video plays in an MPMovieplayer. Now, I want to make it so that if I touch on a next button, then the next video in the UITableView will play. How can I implement this?
Search for "MPMoviePlayer overlay" on stack overflow
Put an overlay over the movie with a previous and next button on it.
Make the buttons target methods that control MPMoviePlayer.