我正在使用YTPlayerView类来播放YouTube视频。下面是我用来根据设备屏幕大小加载视频的代码( iPad的大尺寸和iPhone的小尺寸)。而且效果很好。
问题--当我将设备模式改为景观时,我想要更大的YTPlayerView然后是纵向模式。目前,对于两种屏幕模式,视频都有相同的大小。
- (BOOL)loadWithPlayerParams:(NSDictionary *)additionalPlayerParams {
NSDictionary *playerCallbacks = @{
@"onReady" : @"onReady",
@"onStateChange" : @"onStateChange",
@"onPlaybackQualityChange" : @"onPlaybackQualityChange",
@"onError" : @"onPlayerError"
};
NSMutableDictionary *playerParams = [[NSMutableDictionary alloc] init];
[playerParams addEntriesFromDictionary:additionalPlayerParams];
if([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad)
{
[playerParams setValue:@"551px" forKey:@"height"];
[playerParams setValue:@"768px" forKey:@"width"];
}
else
{
[playerParams setValue:@"250px" forKey:@"height"];
[playerParams setValue:@"320px" forKey:@"width"];
}
-----
-----
}我不能用这个检查来提供更大的大小来查看,因为上面的代码没有在视频播放之间调用。
if([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscape)你们知道如何解决这个问题吗?或者,如果有任何其他解决方案使用JavaScript和css作为webView的html字符串。
发布于 2014-10-13 06:45:06
YTPlayerView实际上使用webview来播放viedo,所以您只能使用css或javascript来更改大小。资产文件夹中应该有一个名为"YTPlayerView-iframe-player.html“的html文件。
下面是css示例:
<style>
body { margin: 0; width:100%%; height:100%%; }
html { width:100%%; height:100%%; }
</style>发布于 2015-07-08 10:16:31
我在我的故事板中使用了YTPlayer,并且在我的项目中使用了自动收费。在风景和肖像模式下对我都很好。我认为解决你的问题的办法是自动收费。
https://stackoverflow.com/questions/25382952
复制相似问题