Skip to content

[BUG] Error Code 150 – Playback on other apps has been disabled #1149

@Ab-Aayan

Description

@Ab-Aayan

Is there an existing issue for this?

  • I have searched the existing issues

Package

youtube_player_flutter

What happened?

Playback on other apps has been disabled by the video owner
Error Code: 150

What is the expected behaviour?

The video should either:

Play normally inside the app, or

Provide a clear way to handle/recover from this restriction (fallback, callback, or documentation guidance).

How to reproduce?

Add youtube_player_flutter: ^9.1.3

Initialize YoutubePlayerController

Try playing a YouTube video that has embedding restrictions

The player displays Error Code 150

Future _initializeYouTubePlayer() async {
if (currentVideoKey == null || currentVideoKey!.isEmpty || _isDisposing) {
return;
}

try {
  final controller = YoutubePlayerController(
    initialVideoId: currentVideoKey!,
    flags: const YoutubePlayerFlags(
      autoPlay: true,
      mute: false,
      enableCaption: false,
    ),
  );

  controller.addListener(() {
    if (mounted && !_isDisposing) {
      setState(() {
        _isFullScreen = controller.value.isFullScreen;
      });
    }
  });

  if (mounted && !_isDisposing) {
    setState(() {
      _youtubeController = controller;
    });
  }

  if (kDebugMode) print('YouTube player initialized successfully');
} catch (e) {
  if (kDebugMode) print('Error initializing YouTube player: $e');
  ScaffoldMessenger.of(context).showSnackBar(
    AppSnackBar.customWithIcon(
      message: 'Error initializing YouTube player.',
      backgroundColor: Colors.redAccent,
      icon: Icons.error_outline,
    ),
  );
}

}

Flutter Doctor Output

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions