Stopping video in viewWillAppear:(bool)animated method - iphone

In my viewWillAppear:(bool)animated method I want to stop video playing. How can I do this? I am new I don't know much.
I am playing a video on this screen. I have a tab which shows table view. When I click on the tab the table view is shown but video is playing in background: we can hear the music.

If you are using MPMoviePlayerController, call -pause on that object.

Related

Why VideoPlayerViewController can be presented from iPad but not from iPhone?

I have a universal app and 2 storyboards(for iPad and iPhone). In a view controller, when I tap a button, a video is starting to play. I am doing that with:
-(void)playMoviesForItems:(NSArray *)shopItems{
VideoPlayerViewController* moviePlayer = [self.storyboard instantiateViewControllerWithIdentifier:#"videoPlayerController"];
[self presentViewController:moviePlayer animated:NO completion:nil];
[moviePlayer playMoviesForItems:shopItems];
}
In iPad, everything works fine. But in iPhone, i can hear the sound of the movie, but there is no view. It is not presented like it does in iPad.
So where am I wrong? Is it the good way to present a video controller?
I think your frame for the video player is not setted properly.You have to use proper class or like present modal view controller.I am able to play the video in iphone using video player.How come it will not work for you?Is apple making junk changes i hope not so..

iOS view offset after youTube video execution

I am calling a youtube channel on a UIWebView. When user selects a video, device launches its video player as normal. However, when video ends or user finishes it returning to view, an offset is applied to whole app!! All views have an offset on top but this only happens on iPad and iPad simulator with compatibility mode, on iPhone and iPhone simulator not! How to solve it? Thank you.
Problem is that status bar dissapears after video execution.
[[UIApplication sharedApplication] setStatusBarHidden:NO]; problem is beeing solved when an event is fired using NSNotificationCenter

iPhone - Need to replay background sound when it comes to foreground from background

My application plays a background music when it launches. It stops when I quit the application. But not playing the music again when I open my application. The application has 2 views and I want to play background sound on only main view. So when the app launches it should play the sound until user quit the app or when the user goes to the second view in the app. The sound should be played again only when the user returns to the main view. Currently, I am calling the sub function which plays the sound in 'viewDidLoad' function. please help.
Thanks
Try using this method in your AppDelegate:
- (void)applicationDidBecomeActive:(UIApplication *)application
DidBecomeActive Apple Documentation

Issue with MPMoviePlayerController playing an audio after a YouTube Video is opened in a Webview

In one View Controller ViewController1, I have tried to open a You tube video embedded in a UIWebview. It opens in the Movie Player window and then I use the "Done" button to come out of the movie player window. Again in another view controller ViewController2 in the same application, I open a MPMoviePlayerController(MPMoviePlayerController *audioplayer) to play an audio file using streaming. However, it remains in the paused state on opening the player. Even when i call the method [audioplayer play], the application automatically sets back the playback state to paused (i rechecked and it is not done through my code).
But if i reopen the application and in view controller ViewController2 i play the audio alone, then MPMoviePlayerController *audioplayer plays successfully.
Any idea what i might be doing wrong ?
This issue was found to be specific only to ios4.0.
This issue doesnt occur in ios4.1 and above.

UIImagePickerController AVAudioPlayer

When I open a UIImagePickerController, I can display the device's camera input stream.
But when I play an AVAudioPlayer with [player play] then the camera stops working.
How can I deal with that?
you can't because UIIMagePickerController is controlling the audio, you will need to use low level AVFoundation in order to do that.
checkout AVCam sample code how to record a movie and add the view as subview , that way you will stay in control of the audio and will be able to play audio.