15

Rootviewcontroller has a webview that plays a youtube video and it has one camera button. User can click on camera button and record video. up to this point its working fine

When I dismiss the camera controller and try to play the video in webview, its frame gets disturbed even though I tried removing and again adding on view.

When I dismiss the camera controller without recording the video its working ok... Here is the imageenter image description here code to play video

 GDataEntryBase *entry2 = [[AppDelegate.feed entries] objectAtIndex:[tag intValue]];
    NSArray *contents = [[(GDataEntryYouTubeVideo *)entry2 mediaGroup] mediaContents];
   NSString *urlString=[NSURL URLWithString:[[contents objectAtIndex:0] URLString]];

    NSString *embedHTML = @"\
    <html><head>\
    <style type=\"text/css\">\
    body {\
    background-color: black;\
    color: black;\
    }\
    </style>\
    </head><body style=\"margin:0\"><div>\
    <embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \
    width=\"736\" height=\"571\"></embed></div>\
    </body></html>";
    NSString *html = [NSString stringWithFormat:embedHTML, urlString, webplay.frame.size .width, webplay.frame.size.height];
    NSLog(@"html=%@",html);
        [webplay loadHTMLString:html baseURL:nil];
Rayfleck
  • 12,116
  • 8
  • 48
  • 74
GameLoading
  • 6,688
  • 2
  • 33
  • 57

4 Answers4

1
-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
    [self dismissModalViewControllerAnimated:YES];


    [self viewDidLoad];
// or if u write code in your viewdidapper method than

    [self viewDidAppear:NO];

}

you can load your entire view again on cancel button click.

Parth Bhatt
  • 19,381
  • 28
  • 133
  • 216
freelancer
  • 1,658
  • 1
  • 16
  • 37
0

I did check but it was layer problem I used hit test to solve this problem.

Here is a link that show how to use hit test

Community
  • 1
  • 1
GameLoading
  • 6,688
  • 2
  • 33
  • 57
0

Playing movies by using the webviewcontroller gives a lot of issues (for instance with rotation). It's always a better idea to use the dedicated movie classes.

If you still need to use the webview for some reason or the other, I found out that by: - setting the RootViewController in a temp variable - setting the RootViewController to nil - restoring the RootViewController again with the contents of the stored variable

the whole viewstack is reinitialized and would solve a lot of the issues I had with the rotation going weird. Wo knows the 'hack' might work for you as well.

Toad
  • 15,593
  • 16
  • 82
  • 128
0

Do you need the "<div>" tag? Try removing them as see what happens.

Also, this link below worked for me and it provides good sample code. I altered the way I was using YouTube to fit this model and was easily able to build a table populated by youtube links in the cells. As you tapped on the cells, the video would play within a frame.

http://iosdevelopertips.com/video/display-youtube-videos-without-exiting-your-application.html

Hope this helps.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Mike
  • 121
  • 4