Open h-code opened 9 years ago
Thanks for posting this fix. I was having the same problem. Cheers
I have no problem.
:+1: Same issue for me
steps:
So i can't predict correct size and add it as params before autolayout Any ideas ?
Found a better workaround in YTPlayerView-iframe-player.html new resize function
<script src="https://www.youtube.com/iframe_api"></script>
<script>
var resizePlayer = function() {
var player = document.getElementById('player');
var width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth || document.height;
var height = window.innerHeight || document.documentElement.clientHeight|| document.body.clientHeight || document.width;
player.style.width = width + 'px';
player.style.height = height + 'px';
};
window.addEventListener('resize', resizePlayer);
var player;
YT.ready(function() {
player = new YT.Player('player', %@);
resizePlayer();
window.location.href = 'ytplayer://onYouTubeIframeAPIReady';
});
This will allow to resize playerView as usual (for example autolayout on rotation) And player will not stuck with size from params. Player will be resized automatically with webView
@iulukaya need a pull request ? or maybe merge https://github.com/youtube/youtube-ios-player-helper/pull/87 ?
Hi,
In my app The YTPPlayer should resize depending on device size Unfortunately when running on iPad the width is correct but not the height.
I got the correct behaviour by patching the height and size
[playerParams setValue:[NSString stringWithFormat: @"%0.00f", self.frame.size.height] forKey:@"height"];
[playerParams setValue:[NSString stringWithFormat: @"%0.00f", self.frame.size.width] forKey:@"width"];
instead of
[playerParams setValue:@"100%" forKey:@"height"]
[playerParams setValue:@"100%" forKey:@"width"]
Regards JM