YTPlayerView - authoring support for YTPlayerView

I am using classes YTPlayerView

to play videos YouTube

. Below is the code I am using to load the video according to the device screen size (large for iPad and small for iPhone). And it works fine.

Problem - When I change the device mode to landscape, I want to zoom YTPlayerView

in and then in portrait mode. At the moment, the video is the same size for both screen modes.

- (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"];
}
-----
-----
}

      

I cannot use this check to increase the image size because the above code is not called between video playback.

if([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscape)

      

Do you have any ideas how to solve this problem? Or if there is any other solution using JavaScript and css as html string for webView.

+3


source to share


2 answers


YTPlayerView actually uses webview to play viedo, so you can only use css or javascript to resize. In the "Assets" folder there should be an html file named "YTPlayerView-iframe-player.html".

here is a css example:



<style>
    body { margin: 0; width:100%%; height:100%%; }
    html { width:100%%; height:100%%; }
</style>

      

+4


source


I have used YTPlayer in my bulletin board and have imposed restrictions on it as I am using autoplay in my project. It works great for me in both landscape and portrait modes. I think the solution to your problem is the self-timer



0


source







All Articles