Open fibau opened 2 weeks ago
I'm facing a similar issue, after updating video ids with hyphen is not working.
As a temporary workout by loading the video using url, this is found to be working.
import 'package:youtube_player_iframe/youtube_player_iframe.dart';
extension YoutubePlayerControllerEx on YoutubePlayerController {
/// Due to a bug we are converting the videoid to url
static fromVideoId({
required String videoId,
YoutubePlayerParams params = const YoutubePlayerParams(),
bool autoPlay = false,
double? startSeconds,
double? endSeconds,
}) {
final controller = YoutubePlayerController(params: params);
final url = 'http://www.youtube.com/v/$videoId';
if (autoPlay) {
controller.loadVideoByUrl(
mediaContentUrl: url,
startSeconds: startSeconds,
endSeconds: endSeconds,
);
} else {
controller.cueVideoByUrl(
mediaContentUrl: url,
startSeconds: startSeconds,
endSeconds: endSeconds,
);
}
return controller;
}
}
@Anupdas do you know from which version the bug was introduced? I may decide to downgrade unless it's fixed. Migrating to using URL can't be done in my project. If it's not fixed I may try your solution in the future. My project isn't released now so there is no need for URL migration.
Duplication of #981
Is there an existing issue for this?
Package
youtube_player_iframe (Default)
What happened?
I am trying to play videos in my app using youtube_player_iframe and have used the package for a while and I think the bug was introduced in a recent update as I have not encountered the issue before even though I have used the package a lot.
Below is what happens when I play videos with hyphens in id (first and second have hyphens in ids)
My app:
Example app of the package(second video has hyphen and don't load):
In the example app, the second video of the video list page doesn't load and it's the only one that have an hyphen in it. When I replace it with another ID it works. The homepage doesn't have that problem even though two of the video IDs have hyphens in it.
SO I think it happens when YoutubePlayerController.fromVideoId is used?
This is a sample of my code:
This is a shorter sample
What is the expected behaviour?
I expect the videos to load but they show error or black screen
How to reproduce?
You play a video by using YoutubePlayerController. The video ID should have an hyphen in it, such as: wG8gYDWj-mg
Flutter Doctor Output