gpt4 book ai didi

objective-c - 横向嵌入 YouTube 视频

转载 作者:可可西里 更新时间:2023-11-01 04:59:48 25 4
gpt4 key购买 nike

我的应用程序中有一个嵌入式 YoutTube 视频。整个应用程序被锁定为只能纵向运行,但我希望在用户点击缩略图上的播放按钮后视频可以横向播放。以下是嵌入式 YouTube 视频的代码。

//
// YouTubeView.h
// KFBNewsroom
//
// Created by KFB on 11/8/12.
// Copyright (c) 2012 com.kfb. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface YouTubeView : UIViewController
{
IBOutlet UIWebView *thumbnailView;
}
@property (nonatomic, retain) IBOutlet UIWebView *thumbnailView;

@end






//
// YouTubeView.m
// KFBNewsroom
//
// Created by KFB on 11/8/12.
// Copyright (c) 2012 com.kfb. All rights reserved.
//

#import "YouTubeView.h"

@interface YouTubeView ()

@end

@implementation YouTubeView
@synthesize thumbnailView;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}

- (void)viewDidLoad
{
[super viewDidLoad];
self.title = @"Monthly Video";
// Do any additional setup after loading the view from its nib.
// webView is a UIWebView, either initialized programmatically or loaded as part of a xib.

NSString *htmlString = @"<html><head><meta name = \"viewport\" content = \"initial-scale = 1.0, user-scalable = no, width = 280\"/></head><body style=\"background:#F00;margin-top:0px;margin-left:0px\"><div><object width=\"280\" height=\"218\"><param name=\"movie\" value=\"http://www.youtube.com/embed/videoseries?list=PL0B9BF37A24840E28&amp;hl=en_US""></param><param name=\"wmode\" value=\"transparent\"></param><embed src=\"http://www.youtube.com/embed/videoseries?list=PL0B9BF37A24840E28&amp;hl=en_US""type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\"280\" height=\"218\"></embed></object></div></body></html>";

[thumbnailView loadHTMLString:htmlString baseURL:[NSURL URLWithString:@"http://www.youtube.com/playlist?list=PL0B9BF37A24840E28&feature=plcp"]];

}

- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

@end

最佳答案

要接收设备旋转的通知,您需要将项目配置设置为也使用横向模式。然后,如果您有 UIViewController 类,则需要实现旋转以忽略纵向以外的所有内容。在您拥有视频的 Controller 中,您只需覆盖它以接受风景。

关于objective-c - 横向嵌入 YouTube 视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13381037/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com