Youtube_player_flutter: [BUG] Infinite loading of video

Created on 7 Mar 2020  ·  24Comments  ·  Source: sarbagyastha/youtube_player_flutter

Describe the bug
I tested the default example implemented in an app and the video is loading infinitely, the last message in debug console is
W/System (14804): A resource failed to call release

To Reproduce
Define your controller like this in initState()

_controller = YoutubePlayerController(
      initialVideoId: 'iLnmTe5Q2Qw',
      flags: YoutubePlayerFlags(
        forceHideAnnotation: true
      ),
    );

And implement your widget like this:

YoutubePlayer(
            controller: _controller,
            showVideoProgressIndicator: true,
            progressIndicatorColor: Colors.amber,
            onReady: () {
                print('Player is ready.');
            },
          ),

Expected behavior
A working youtube video should show up and wait for the user to start playing it

Technical Details:

  • Device: Emulator
  • OS: Android
  • Version API 28

    • Flutter master channel (latest update) but same problem on beta channel

Additional context
I checked this bug report: https://github.com/flutter/flutter/issues/24565
Because the controller is sending the same message if you're trying to use it.

The widget tree is like this:

Scaffold
  |-> SingleChildScrollView
    |-> Column
      |-> YoutubePlayer

Complete errored debug console:

D/EGL_emulation(14804): eglMakeCurrent: 0xe7195440: ver 3 1 (tinfo 0xe715fcd0)
D/eglCodecCommon(14804): setVertexArrayObject: set vao to 2 (2) 0 0
D/eglCodecCommon(14804): setVertexArrayObject: set vao to 0 (0) 0 0
D/EGL_emulation(14804): eglCreateContext: 0xd2bf3640: maj 3 min 0 rcv 3
D/EGL_emulation(14804): eglMakeCurrent: 0xd2bf3640: ver 3 0 (tinfo 0xd0257060)
D/eglCodecCommon(14804): setVertexArrayObject: set vao to 1 (1) 0 0
D/eglCodecCommon(14804): setVertexArrayObject: set vao to 2 (2) 0 0
D/eglCodecCommon(14804): setVertexArrayObject: set vao to 1 (1) 0 0
D/eglCodecCommon(14804): setVertexArrayObject: set vao to 2 (2) 0 0
D/eglCodecCommon(14804): setVertexArrayObject: set vao to 1 (1) 0 0
W/System  (14804): A resource failed to call release.
I/flutter (14804): The controller is not ready for method calls.
bug question

Most helpful comment

Same issue for me as well on Android Pixel 2 XL emulator. Video loads if I downgrade to v6.1.1.

minSdkVersion 21

I do not include webview_flutter.

Initialization is fairly simple:

_controller = YoutubePlayerController(
        initialVideoId: videoID,
        flags: YoutubePlayerFlags(
          mute: false,
          enableCaption: false,
          autoPlay: false,
        ),
      );

All 24 comments

Same issue. Any progress or workarounds?

I have the same issue. Video is loading forever.

It only happens on a real Android Device in release build.
Android Emulator (debug) is working, and iOS Simulator (debug) and Device (release) works too.

Device: Samsung Galaxy A6
Android: 9 (Pie)
Flutter 1.12.13+hotfix.9
youtube_player_flutter: ^6.1.0+7

This really is a showstopper and lets me think about using something like flutter_youtube_view instead...

Ok after some further investigation I found the reason for my problem. It seems that Android permissions need to be set by hand after creating a new flutter project. By default the release version doesn't have any permissions -> no access to the internet. Therefore the youtube-player cannot access the source-file and loads forever. Adding the following to the AndroidManifest.xml solved it for me:

<uses-permission android:name="android.permission.INTERNET"/>

Solution found on: Flutter released app not working on the device, when installed

Ok after some further investigation I found the reason for my problem. It seems that Android permissions need to be set by hand after creating a new flutter project. By default the release version doesn't have any permissions -> no access to the internet. Therefore the youtube-player cannot access the source-file and loads forever. Adding the following to the AndroidManifest.xml solved it for me:

<uses-permission android:name="android.permission.INTERNET"/>

Solution found on: Flutter released app not working on the device, when installed

It doesn't work for me.

Still have the same problem.

Not working on iOS devices or simulator for me either. Using 6.1.0+7

Another note if you try and FullScreen during this infinite load you get an error Invalid Video ID = Error Code: 1

I had the same issue.
the example was working fine but using the plugin inside my existing project results in infinite loading.

In my case, the issue was caused by webview_flutter: ^0.3.20+2

Removing this dependency from my pubspec solved the problem

I found my issue the video id's were actually waiting to be published. Set to premiere in x days. A real youtube player says this if you try to play the video that is about to premiere. Maybe this should be an added feature

Same problem on iPad 3 with iOS 9.3.5, and none of the above helped me

Should fix with v7.0.0.

Should fix with v7.0.0.

I'm using 7.0.0+3but the infinite loading before start video is still a problem on my Android emulator

I am having same infinite loading issue, any update on this problem?

Same issue for me as well on Android Pixel 2 XL emulator. Video loads if I downgrade to v6.1.1.

minSdkVersion 21

I do not include webview_flutter.

Initialization is fairly simple:

_controller = YoutubePlayerController(
        initialVideoId: videoID,
        flags: YoutubePlayerFlags(
          mute: false,
          enableCaption: false,
          autoPlay: false,
        ),
      );

Same issue for me as well on Android Pixel 3. Video keeps on loading, it works perfectly on iOS.

is this an issues with just Emulator ?? has anyone tried on real Android Device?

Any update would help.

Thank you.

Experiencing the same issue.
The video plays well though but the loader keeps on rotating at the bottom left of the video screen.

Did anyone find any solution for this issue?

Did anyone find any solution for this issue?

Downgrade to 6.1.1 package

Thanks @JigarKotak7 for replying, I downgraded it to v6.1.1 package but it was still not running in the emulator. So I tried @Gunlek idea to Define your controller in initState() and it worked, this is my code:

class AboutTopic extends StatefulWidget {
  final String videoLink;

  AboutTopic({this.videoLink});

  @override
  _AboutTopicState createState() => _AboutTopicState();
}

class _AboutTopicState extends State<AboutTopic> {
  YoutubePlayerController _controller;

  @override
  void initState() {
     _controller = YoutubePlayerController(
      initialVideoId:
          YoutubePlayer.convertUrlToId(widget.videoLink),
      flags: YoutubePlayerFlags(
          mute: false,
          autoPlay: true,
          disableDragSeek: true,
          loop: false,
          enableCaption: false),
    );

    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
       appBar: AppBar(
        title: Text('About'),
        centerTitle: true,
        leading: IconButton(
          icon: Icon(Icons.arrow_back),
          onPressed: () {
            Navigator.of(context).pop();
          },
        )
      ),

      body: YoutubePlayer(
        controller: _controller,
        showVideoProgressIndicator: true,
        bottomActions: <Widget>[
          const SizedBox(width: 14.0),
          CurrentPosition(),
          const SizedBox(width: 8.0),
          ProgressBar(isExpanded: true),
          RemainingDuration(),
        ],
        aspectRatio: 4 / 3,
        progressIndicatorColor: Colors.white,
        onReady: () {
          print('Player is ready.');
        },
      ),
    );
  }
}

@Hardikkr Happy it worked out for you.
below link has a bit of preview of the app I build for one of my client, where in I have used YouTube player. So if you have any questions do let me know.
https://www.youtube.com/watch?v=O3dy9p4ybes

@Hardikkr Happy it worked out for you.
below link has a bit of preview of the app I build for one of my client, where in I have used YouTube player. So if you have any questions do let me know.
https://www.youtube.com/watch?v=O3dy9p4ybes

i am also having some issues in playing video it is loading infinietely and i icant figure out why

also same problem

I am having same infinite loading issue, It' working in emulator but real device it's not working

hey @santhoshisrimanthula
in case it's helpful for you. I can feel your frustration lol.

so. the latest version works on a few phones and doesn't work on other phones.
I think it has something to do with the android version

I solved this problem by downgrading into version youtube_player_flutter: ^6.1.1

image

I had internet permission only for debug manifest. After adding internet permission to the main manifest, It worked for me.

Was this page helpful?
0 / 5 - 0 ratings