diff --git a/lib/src/player/raw_youtube_player.dart b/lib/src/player/raw_youtube_player.dart index 96bc4cae..7eca45d5 100644 --- a/lib/src/player/raw_youtube_player.dart +++ b/lib/src/player/raw_youtube_player.dart @@ -35,6 +35,7 @@ class _RawYoutubePlayerState extends State YoutubePlayerController controller; PlayerState _cachedPlayerState; bool _isPlayerReady = false; + bool _onLoadStopCalled = false; @override void initState() { @@ -94,7 +95,14 @@ class _RawYoutubePlayerState extends State webController ..addJavaScriptHandler( handlerName: 'Ready', - callback: (_) => _isPlayerReady = true, + callback: (_) { + _isPlayerReady = true; + if (_onLoadStopCalled) { + controller.updateValue( + controller.value.copyWith(isReady: true), + ); + } + }, ) ..addJavaScriptHandler( handlerName: 'StateChange', @@ -206,6 +214,7 @@ class _RawYoutubePlayerState extends State ); }, onLoadStop: (_, __) { + _onLoadStopCalled = true; if (_isPlayerReady) { controller.updateValue( controller.value.copyWith(isReady: true), @@ -316,12 +325,12 @@ class _RawYoutubePlayerState extends State player.cueVideoById(id, startAt, endAt); return ''; } - + function loadPlaylist(playlist, index, startAt) { player.loadPlaylist(playlist, 'playlist', index, startAt); return ''; } - + function cuePlaylist(playlist, index, startAt) { player.cuePlaylist(playlist, 'playlist', index, startAt); return ''; @@ -356,7 +365,7 @@ class _RawYoutubePlayerState extends State player.setPlaybackRate(rate); return ''; } - + function setTopMargin(margin) { document.getElementById("player").style.marginTop = margin; return ''; diff --git a/lib/src/player/youtube_player.dart b/lib/src/player/youtube_player.dart index 53c7b01f..4c2b7c59 100644 --- a/lib/src/player/youtube_player.dart +++ b/lib/src/player/youtube_player.dart @@ -289,6 +289,7 @@ class _YoutubePlayerState extends State { } Widget _buildPlayer({Widget errorWidget}) { + final EdgeInsets padding = MediaQuery.of(context).padding; return AspectRatio( aspectRatio: _aspectRatio, child: Stack( @@ -297,7 +298,7 @@ class _YoutubePlayerState extends State { children: [ Transform.scale( scale: controller.value.isFullScreen - ? (1 / _aspectRatio * MediaQuery.of(context).size.width) / + ? (1 / _aspectRatio * (MediaQuery.of(context).size.width - padding.right - padding.left - padding.bottom)) / MediaQuery.of(context).size.height : 1, child: RawYoutubePlayer(