Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
877 views
in Technique[技术] by (71.8m points)

objective c - Youtube in iOS5 - done button Tapped

In iOS5 i want to load Youtube movies, and i done it with:

- (void)embedYouTube:(NSString *)urlString frame:(CGRect)frame {

NSString *embedHTML = @"
<html><head>
<style type="text/css">
body {
background-color: transparent;
color: white;
}
</style>
</head><body style="margin:0">
<embed id="yt" src="%@" type="application/x-shockwave-flash" 
width="%0.0f" height="%0.0f"></embed>
</body></html>";
NSString *html = [NSString stringWithFormat:embedHTML, urlString, frame.size.width, frame.size.height];
videoView = [[UIWebView alloc] initWithFrame:frame];
[videoView loadHTMLString:html baseURL:nil];
[self.view addSubview:videoView];

}

calling by:

        [self embedYouTube:@"http://www.youtube.com/v/PqtUSSdf8b4" frame:CGRectMake(0, 0, self.view.frame.size.width, 100)];

And i have standard Youtube frame with "done" button. When i hit done button i'm redirect to my root VC. why? how can i get to my VC (the one when i'm calling it) ?

And more important - how to catch "done button" event ?

EDIT: I have MainVC and DetailVC. MainVC calls DetailVC as a ModalViewController. From there I call this embedYouTube method. When i'm hitting done on this screen: enter image description here

i'm returning to MainVC not DetailVC. Why? How to catch this event?

EDIT: And iOS 6 displays only black background - nothing. Why?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The fullscreen video player will dismiss when you tap the done button, this is encapsulated into that full screen player which the system automatically presents as part of this youtube/flash safari embed trick. You shouldn't try to do anything when this is used.

About iOS 6 - iOS 6 no longer supports this way of embedding YouTube videos in your application (source)

As of iOS 6, embedded YouTube URLs in the form of http://www.youtube.com/watch?v=oHg5SJYRHA0 will no longer work. These URLs are for viewing the video on the YouTube site, not for embedding in web pages. Instead, the format that should be used is described here: https://developers.google.com/youtube/player_parameters.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...