2012-09-14 35 views
12

Xin chào tôi có ứng dụng với webviews và tôi nhúng video youtube. Bây giờ tôi đã cài đặt iOS6 nhưng chúng không hoạt động nữa.iOS 6 nhúng youtube

Có ai đó đã tìm thấy giải pháp không?

MyCode:

- (void)viewDidLoad 
{ 
    [scrollvideoView setScrollEnabled:YES]; 
    [scrollvideoView setContentSize:CGSizeMake(320,2300)]; 
    [scrollvideoView setPagingEnabled:NO]; 

    [super viewDidLoad]; 
    // Do any additional setup after loading the view. 

    //Variabelen 
    NSInteger x1 = 25; 
    NSInteger x2 = 123; 
    NSInteger x3 = 220; 
    NSInteger sz = 75; 

    //Label height rij1 
    NSInteger yt1 = 45; 

    /* de Videos */ 
    //Eerste rij 
    NSInteger y1 = 0; 
    [self embedYouTube:@"http://www.youtube.com/watch?v=MFARZYEGqK8" frame:CGRectMake(x1, y1, sz, sz)]; 
    [self embedYouTube:@"http://www.youtube.com/watch?v=cD7WHGvXqEA" frame:CGRectMake(x2, y1, sz, sz)]; 
    [self embedYouTube:@"http://www.youtube.com/watch?v=8onqmHPBJOo" frame:CGRectMake(x3, y1, sz, sz)]; 

    //Setting de labels 
    UILabel *videoLabel1 = [[UILabel alloc] initWithFrame:CGRectMake(x1, yt1, sz, sz)]; 
    videoLabel1.text = @"Videoclip daor heb ik schijt an"; 
    [self.scrollvideoView addSubview:videoLabel1]; 
    videoLabel1.backgroundColor = [UIColor clearColor]; 
    videoLabel1.font = [UIFont fontWithName:@"Arial" size: 9.0]; 
    videoLabel1.textColor = [UIColor whiteColor]; 

    UILabel *videoLabel2 = [[UILabel alloc] initWithFrame:CGRectMake(x2, yt1, sz, sz)]; 
    videoLabel2.text = @"Videoclip goeie been verkeerde bed"; 
    [self.scrollvideoView addSubview:videoLabel2]; 
    videoLabel2.backgroundColor = [UIColor clearColor]; 
    videoLabel2.font = [UIFont fontWithName:@"Arial" size: 9.0]; 
    videoLabel2.textColor = [UIColor whiteColor]; 

    UILabel *videoLabel3 = [[UILabel alloc] initWithFrame:CGRectMake(x3, yt1, sz, sz)]; 
    videoLabel3.text = @"Wavin flag (giel beelen)"; 
    [self.scrollvideoView addSubview:videoLabel3]; 
    videoLabel3.backgroundColor = [UIColor clearColor]; 
    videoLabel3.font = [UIFont fontWithName:@"Arial" size: 9.0]; 
    videoLabel3.textColor = [UIColor whiteColor]; 

    //Tweede rij 
    NSInteger y2 = 100; 
    [self embedYouTube:@"http://www.youtube.com/watch?v=-cJz3YGRlMI" frame:CGRectMake(x1, y2, sz, sz)]; 
    [self embedYouTube:@"http://www.youtube.com/watch?v=ZdQRcAnPCvk" frame:CGRectMake(x2, y2, sz, sz)]; 
    [self embedYouTube:@"http://www.youtube.com/watch?v=KNcT5O1qk40" frame:CGRectMake(x3, y2, sz, sz)]; 

} 

- (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]; 
    UIWebView *videoView = [[UIWebView alloc] initWithFrame:frame]; 
    [videoView loadHTMLString:html baseURL:nil]; 
    [self.scrollvideoView addSubview:videoView]; 
    //[videoView release]; 
} 
+2

đọc lưu ý phát hành iOS 6. có một lưu ý ở trong đó về việc này. –

+1

Apple đã xóa ứng dụng Youtube gốc, đó thực sự là những gì liên quan đến việc phát video Youtube trong iOS trước đó. Tôi đang cố gắng tìm một người thay thế, không may mắn. –

+0

Bạn có sắp xếp điều này không? – Daniel

Trả lời

11

Câu hỏi hay và vấn đề tôi vừa nhận thấy và đã tìm ra giải pháp.

Tôi đã tìm thấy câu nói này trong ghi chú phát hành iOS 6 dưới phần/WebKit Safari:

Tính đến iOS 6, URL YouTube nhúng trong các hình thức của http://www.youtube.com/watch?v=oHg5SJYRHA0 sẽ không còn hoạt động được. Các URL này để xem video trên trang web YouTube, không phải để nhúng trong các trang web. Thay vào đó, định dạng sẽ được sử dụng được mô tả tại đây: https://developers.google.com/youtube/player_parameters.

Quay lại trang web dành cho nhà phát triển của Google có vẻ như trình phát video phải được nhúng bằng cách sử dụng khung nội tuyến, không được quá nhiều công việc.

Hy vọng điều đó sẽ hữu ích.

3

Nếu bạn không cần straigh-forward auto-play, sau đó bạn có thể có lẽ sử dụng iframe với nút play

 <iframe height="90" width="75" src="http://www.youtube.com/embed/VIDEOID"></iframe> 

, khi bạn nhấn nút phát, toàn màn hình người chơi tiếp quản (ít nhất là cho các ứng dụng của tôi trong iOS 6)

Nếu bạn biên dịch ứng dụng với SDK cơ sở cũ hơn 5.1 (5.0), mọi loại nhúng YouTube cũ vẫn hoạt động ngay cả trong iOS 6. Giống như:

<embed src="http://www.youtube.com/watch?v=VIDEOID" type="application/x-shockwave-flash"  widht="64" height="64"></embed> 
+0

ý nghĩa của bộ kit dev 5.1 (5.0) là gì? –

+3

SDK cơ sở cũ hơn, tôi đã chỉnh sửa để loại bỏ sự nhầm lẫn này. – PetrV

+0

Cảm ơn rất nhiều, tôi đã xây dựng nó bằng cách sử dụng 5.0 như sdk cơ bản và nó hoạt động –

5

// từ Qiqi giúp đỡ tôi đã chơi youtube video trong iOS6 như sau và nó đang làm việc cho tôi

// đây là url của tôi về youtube: http: //www.youtube.com/watch? V = s9KU-oOa6pA

// videoid: s9KU-oOa6pA

 CGRect frame = CGRectMake(5,55, 310,200); 
    NSString *embedHTML =[NSString stringWithFormat:@"\ 
          <html><head>\ 
          <style type=\"text/css\">\ 
          body {\ 
          background-color: transparent;\ 
          color: blue;\ 
          }\ 
          </style>\ 
          </head><body style=\"margin:0\">\ 
          <iframe height=\"200\" width=\"310\"  src=\"http://www.youtube.com/embed/s9KU-oOa6pA\"></iframe>\ 
          </body></html>"]; 
    UIWebView *videoView = [[UIWebView alloc] initWithFrame:frame]; 

    videoView.backgroundColor = [UIColor clearColor]; 
    [videoView loadHTMLString:embedHTML baseURL:nil]; 
    [self.view addSubview:videoView]; 
Các vấn đề liên quan