Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Infinite loading of video #169

Open
Gunlek opened this issue Mar 7, 2020 · 25 comments
Open

[BUG] Infinite loading of video #169

Gunlek opened this issue Mar 7, 2020 · 25 comments
Assignees
Labels
bug Something isn't working question Further information is requested

Comments

@Gunlek
Copy link

Gunlek commented Mar 7, 2020

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: flutter/flutter#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.
@Gunlek Gunlek added the bug Something isn't working label Mar 7, 2020
@bpastukh
Copy link

Same issue. Any progress or workarounds?

@rafaelmaeuer
Copy link

rafaelmaeuer commented Apr 25, 2020

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...

@rafaelmaeuer
Copy link

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

@nthungdev
Copy link

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.

@emmett-deen
Copy link

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

@emmett-deen
Copy link

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

@Mapk26
Copy link

Mapk26 commented May 4, 2020

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

@emmett-deen
Copy link

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

@Gicminos
Copy link

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

@sarbagyastha
Copy link
Owner

Should fix with v7.0.0.

@sarbagyastha sarbagyastha added the question Further information is requested label May 31, 2020
@enricobenedos
Copy link

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

@harshbarnwal
Copy link

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

@ComplexCarbos
Copy link

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,
        ),
      );

@JigarKotak7
Copy link

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.

@raghuck
Copy link

raghuck commented Oct 11, 2020

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

@littleironical
Copy link

Did anyone find any solution for this issue?

@JigarKotak7
Copy link

Did anyone find any solution for this issue?

Downgrade to 6.1.1 package

@littleironical
Copy link

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.');
        },
      ),
    );
  }
}

@JigarKotak7
Copy link

JigarKotak7 commented Dec 1, 2020

@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

@obaid317
Copy link

@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

@muhajirdev
Copy link

also same problem

@santhoshi-tikme
Copy link

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

@muhajirdev
Copy link

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

@davidengler
Copy link

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

@sunnystas
Copy link

Had an issue with the constant loading of the video player.
The solution was Define your controller in initState()! Thank you guys @Gunlek and @littleironical

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests