ipad摄像头和webview youtube视频播放问题。

时间:2022-09-17 20:28:14

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

Rootviewcontroller有一个webview,可以播放youtube视频,它有一个摄像头按钮。用户可以点击相机按钮和录制视频。到目前为止,它的工作还不错。

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.

当我关闭相机控制器并尝试在webview中播放视频时,它的帧会受到干扰,即使我尝试删除和添加视图。

When I dismiss the camera controller without recording the video its working ok... Here is the imageipad摄像头和webview youtube视频播放问题。 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];

4 个解决方案

#1


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.

在“取消”按钮单击时,您可以再次加载整个视图。

#2


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.

使用webviewcontroller播放电影会带来很多问题(例如旋转)。最好使用专门的电影类。

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

如果出于某种原因,您仍然需要使用webview,我发现by: -在temp变量中设置RootViewController -将RootViewController设置为nil -再次使用存储变量的内容恢复RootViewController

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.

整个viewstack被重新初始化,这会解决我在旋转时遇到的很多问题。我知道“黑鬼”也可能对你有用。

#3


0  

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

我做了检查,但这是层问题,我用hit test来解决这个问题。

Here is a link that show how to use hit test

这里有一个链接,展示了如何使用hit test

#4


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.

此外,下面的链接也对我有用,它提供了很好的示例代码。我改变了使用YouTube的方式来适应这个模型,并且很容易在单元格中构建一个由YouTube链接填充的表。当你点击单元格时,视频将在一个框架内播放。

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

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

Hope this helps.

希望这个有帮助。

#1


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.

在“取消”按钮单击时,您可以再次加载整个视图。

#2


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.

使用webviewcontroller播放电影会带来很多问题(例如旋转)。最好使用专门的电影类。

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

如果出于某种原因,您仍然需要使用webview,我发现by: -在temp变量中设置RootViewController -将RootViewController设置为nil -再次使用存储变量的内容恢复RootViewController

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.

整个viewstack被重新初始化,这会解决我在旋转时遇到的很多问题。我知道“黑鬼”也可能对你有用。

#3


0  

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

我做了检查,但这是层问题,我用hit test来解决这个问题。

Here is a link that show how to use hit test

这里有一个链接,展示了如何使用hit test

#4


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.

此外,下面的链接也对我有用,它提供了很好的示例代码。我改变了使用YouTube的方式来适应这个模型,并且很容易在单元格中构建一个由YouTube链接填充的表。当你点击单元格时,视频将在一个框架内播放。

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

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

Hope this helps.

希望这个有帮助。