Web view is blank after watching video in full screen - iphone

In my app, i open a html page which contains a video. when i try to get back from watching video from full screen.
The Web view is disappear.
I don't know why this happen.
My code is as follow:
-(void)viewWillAppear:(BOOL)animated
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(update:) name:#"UIMoviePlayerControllerWillExitFullscreenNotification" object:nil];
}
it also goes into update method but webview is not shown to me.

Related

UIWebView streaming youtube does not go to fullscreen on iPad

I have a button that unhides a UIWebView and then streams a youtube video. On the iphone it works fine and pressing the play button goes straight to fullscreen and then when its finished hitting the done button hides the UIWebView and return control to app.
However when I try the same on iPad, pressing play does not automatically go to fullscreen (you can hit the fullscreen control but I dont want users to have that option) - is there a way to do this please?
The code I have is:
- (IBAction)topButton:(id)sender {
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(youTubeFinished:) name:#"UIMoviePlayerControllerWillExitFullscreenNotification" object:nil];
videoWebView.hidden=NO;
NSString *embedcode = [self.detailItem objectForKey:#"youtubeEmbedCodeBeginner"];
[[self videoWebView]loadHTMLString:embedcode baseURL:nil];
}
and:
-(void)youTubeFinished:(NSNotification *)notification{
// your code here
videoWebView.hidden=YES;
}
Any help would be appreciated
Try This
selector:#selector(someSelector) name:#"UIMoviePlayerControllerDidEnterFullcreenNotification" object:nil]
// For iOS 4.3 and above:
UIMoviePlayerControllerDidEnterFullscreenNotification
UIMoviePlayerControllerDidExitFullscreenNotification
// For iOS 4.2 and below:
UIMoviePlayerControllerDidEnterFullcreenNotification
UIMoviePlayerControllerDidExitFullcreenNotification
Thanks

how to perform different actions for the done button and the video player finish method of embedded youtube webview in iPhone

I am new to iPhone. Please help me in solving this issue:
I have embedded YouTube webview in Iphone. My problem is when clicking the done button of YouTube I want to call a class and when the video finishes playing an different class should be called. Can anybody help me on identifying what are the methods called on click of done button and finish of YouTube player in iPhone?
Thanks
If the video is played in UIWebView then you can access when the video is played and when Done button is pressed using the following code along with the code you have used to load url in webview
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(videoPlayStarted:) name:#"UIMoviePlayerControllerDidEnterFullscreenNotification" object:nil];
//For Done Button
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(videoPlayFinished:) name:#"UIMoviePlayerControllerDidExitFullscreenNotification" object:nil];
And it can be accessed through
BOOL isVideoInFullScreenMode;//Temperory added here.. must be in .h file or at teh top if required
-(void)videoPlayStarted:(NSNotification *)notification{
//Your stuff here
isVideoInFullScreenMode = YES;
}
-(void)videoPlayFinished:(NSNotification *)notification{
//Your stuffs here
isVideoInFullScreenMode = NO;
}
You are in a UIWebView, so the done button isn't related to your application: pressing the button will never call your application.
The only method you have are from UIWebViewDelegate and they are:
webView:shouldStartLoadWithRequest:navigationType:
webViewDidStartLoad:
webViewDidFinishLoad:
webView:didFailLoadWithError:
If you have to know when player finish, I suggest you to try this class: LBYouTubeView, it will play youtube video on your player component, so you can use Player delegate's method to to do what you asked for.

How to play video in iphone landscape mode?

I have one application in which list of videos that are coming through xml parsing are displayed in tableview. When I click particular video it should be played in landscape mode.
For that I followed tutorial:
http://iosdevelopertips.com/video/how-to-play-movies-from-application-bundle-or-from-a-remote-server-url.html
It works perfectly but it uses separate modalcontroller so when I press done button on the video or completed video is completed it returns to the that modal view and on which
back button appears and when I press that back button after that I can go back to list of videos screen.but I want to go directly back to the screen which displays list of videos.
for that if i write code using pushviewcontroller than application crashes.How can i solve this problem.any tutorial or sample code?
- (void) moviePlayBackDidFinish:(NSNotification*)notification
{
[[UIApplication sharedApplication] setStatusBarHidden:YES];
// Remove observer
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:nil];
[self dismissModalViewControllerAnimated:YES];
DonationVideoViewController *dvvc=[[DonationVideoViewController alloc] initWithNibName:"DonationVideoViewController" bundle:nil];
[self.navigationController pushViewController:dvvc animated:YES];
}
UPDATE:I have solved the issue by using the code for calling custommovieplayercontroller in the same class where I have displayed the list of videos. So now video ends it remains to the page I want and I need to go to other page using pushviewcontroller
You should probably push dvvc in viewDidDisappear. But like Till says, we need to see the error message you are getting.

Iphone web application problem on iphone keyboard open

I have a problem of layout in view my website on iphone/Ipad, when the iphone keyboard open The whole website moved to top due to which user will not be able to view the top content while the keyboard is open. When keyboard is close the website will be back to its original position.
Implement the below nottification methods in init method of the controller showing your website:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(keyboardWasShown:)
name:UIKeyboardDidShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(keyboardWasHidden:)
name:UIKeyboardDidHideNotification object:nil];
try setting the frame of your website in the corresponding notification methods (keyboardWasShown,keyboardWasHidden). Eg:- Say your webSiteView is the view disaplying your website and x,y are the coordinates of the view when keyboard is not visible. When the keyBoard is shown, set the frame of the webSiteView with the new x1 and y1 coordinates that will show the view the way you want.
- (void)keyboardWasShown: (id)sender {
[webSiteView setFrame:CGRectMake(x1,y1,w,h)];
}
- (void)keyboardWasHidden: (id)sender {
[webSiteView setFrame:CGRectMake(x,y,w,h)];
}
Also if you are not able to see the entire webSite, try adding your webSiteView into a scrollView and set the frame of the ScrollView in the notification methods.

Returning from dismiss modal view controller - any way to detect?

Wonder if anyone can help me. I have a setup whereby a main menu presents the main game as a modal view controller. At this point it also stops playing the main menu music.
The problem is that when the game view controller dismisses itself (e.g when user quits game) and returns to the main menu I cannot get the main menu music to start playing again.
Is there some way I can get the music in the main menu to start playing again ? E.g a delegate method that is called when the main game dismisses ?
Thanks,
Martin
You can do it with the NotificationManager
// set up notification
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(playMusic:)
name:#"musicNotification"
object:nil];
// send notification
[[NSNotificationCenter defaultCenter] postNotificationName:#"musicNotification"
object:self];
// clean up notification
[[NSNotificationCenter defaultCenter] removeObserver:self];
[super dealloc];
- (void) playMusic:(NSNotification *) notification
{
// play the music here
if ([[notification name] isEqualToString:#"musicNotification"])
NSLog (#"Received musicNotification!");
}