flutter_youtube_view
flutter_youtube_view copied to clipboard
'loadPlayer()' is deprecated
/Users/laszlokomaromi/Documents/Tools/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_youtube_view-2.0.4/ios/Classes/FlutterYoutubeView.swift:169:21: 'loadPlayer()' is deprecated: renamed to 'loadPlayerHTML'
Please update
Same problem for me, are they working on a solution?
Same problem, app crashing in IOS... what is the solution please !
Hi! I had the same problem. Even though I'm not a Swift developer, but I found this solution which I tested and works. There seems to be some kind of problem with the Bundle stuff...
in file: FlutterYoutubeView.swift line: 171 Add this code:
let htmlString: String? =
"""
<!DOCTYPE html>
<html>
<head>
<style>
html, body { margin: 0; padding: 0; width: 100%; height: 100%; background-color: #000000; }
</style>
</head>
<body>
<div id="player"></div>
<div id="explain"></div>
<script src="https://www.youtube.com/iframe_api" onerror="webkit.messageHandlers.onYouTubeIframeAPIFailedToLoad.postMessage('')"></script>
<script>
var player;
var time;
YT.ready(function() {
player = new YT.Player('player', %@);
webkit.messageHandlers.onYouTubeIframeAPIReady.postMessage('');
function updateTime() {
var state = player.getPlayerState();
if (state == YT.PlayerState.PLAYING) {
time = player.getCurrentTime();
webkit.messageHandlers.onUpdateCurrentTime.postMessage(time);
}
}
window.setInterval(updateTime, 500);
});
function onReady(event) {
webkit.messageHandlers.onReady.postMessage('');
}
function onStateChange(event) {
webkit.messageHandlers.onStateChange.postMessage(event.data);
}
function onPlaybackQualityChange(event) {
webkit.messageHandlers.onPlaybackQualityChange.postMessage(event.data);
}
function onPlaybackRateChange(event) {
webkit.messageHandlers.onPlaybackRateChange.postMessage(event.data);
}
function onPlayerError(event) {
webkit.messageHandlers.onError.postMessage(event.data);
}
function onApiChange(event) {
webkit.messageHandlers.onApiChange.postMessage(event.data);
}
</script>
</body>
</html>
"""
self.player.loadPlayerHTML(htmlString!)
comment this code:
//self.player.loadPlayer()
Now it should work!!!
Hi! I ended up wrapping the changes in a new plugin, based on this one. I did this because when you build you app using Codemagic, for example, it retrieves the non modified files and keeps causing problems.
The plugin's name is flutter_youtube_view_plus https://pub.dev/packages/flutter_youtube_view_plus
It has only two modifications:
- Solves the bundle problem (cause of the crash)
- Adds a parameter to the video player to remove the YouTube link (modestbranding)
Enjoy!
Hi! I ended up wrapping the changes in a new plugin, based on this one. I did this because when you build you app using Codemagic, for example, it retrieves the non modified files and keeps causing problems.
The plugin's name is flutter_youtube_view_plus https://pub.dev/packages/flutter_youtube_view_plus
It has only two modifications:
- Solves the bundle problem (cause of the crash)
- Adds a parameter to the video player to remove the YouTube link (modestbranding)
Enjoy!
it solved my crash problem thanks
Thank you @tuvia, I can confirm that your fork works fine, but why create a new package and don't create a pull request. Is there a reason for that?
Hi! Thank you for your comment. I just needed a quick and fast fox for a production app... That's the only reason.