initialize method
Initialize video player with URL Supports both direct video URLs and YouTube URLs
Implementation
Future<void> initialize(String url, {String? title}) async {
try {
_setState(PlaybackState.loading);
_errorMessage = null;
_videoTitle = title;
// Check if it's a YouTube URL
if (YouTubeService.isYouTubeUrl(url)) {
await _initializeYouTubeVideo(url);
} else {
await _initializeDirectVideo(url);
}
_setState(PlaybackState.ready);
notifyListeners();
} catch (e) {
_setState(PlaybackState.error);
_errorMessage = 'Failed to initialize video: ${e.toString()}';
notifyListeners();
rethrow;
}
}