Coder Social home page Coder Social logo

sarbagyastha / youtube_player_flutter Goto Github PK

View Code? Open in Web Editor NEW
682.0 27.0 755.0 68.28 MB

Flutter plugin for playing or streaming YouTube videos inline using the official iFrame Player API. Supports both Android and iOS platforms.

License: BSD 3-Clause "New" or "Revised" License

Objective-C 0.30% Dart 78.15% Kotlin 0.15% Swift 0.82% Java 0.06% HTML 3.48% Ruby 1.47% CMake 6.81% C++ 8.25% C 0.51%
youtube youtube-player youtube-video android ios flutter flutter-plugin android-youtube-player ios-youtube video-player

youtube_player_flutter's Introduction

Youtube Player IFrame

YOUTUBE PLAYER IFRAME

pub package licence Download Stars Top Language effective dart Web DEMO

Flutter plugin for playing or streaming YouTube videos inline using the official iFrame Player API. The package exposes almost all the API provided by iFrame Player API. So, it's 100% customizable.

Note: This package only provides default youtube web player's skin. If you need Youtube Android player like player with gesture support, use youtube_player_flutter instead. youtube_player_flutter also uses this package as dependency. (Migration Pending)

Supported Platforms:

  • Android
  • iOS
  • Web

YOUTUBE PLAYER IFRAME

Click here for WEB DEMO

Salient Features

  • Inline Playback
  • Supports captions
  • No need for API Key
  • Supports custom controls
  • Retrieves video meta data
  • Supports Live Stream videos
  • Supports changing playback rate
  • Support for both Android and iOS
  • Adapts to quality as per the bandwidth
  • Exposes builders for building custom controls
  • Playlist Support (Both custom and Youtube's playlist)

For Web, Flutter's HtmlElementView. For Android & iOS, the package uses flutter_inappwebview under-the-hood.

If your app uses services workers, you may need add additional configuration on the app startup code, in order to ensure that the web view behaviour don't get unstable. To do so, please refer to the flutter_inappwebview documentation.

Since flutter_inappwebview relies on Flutter's mechanism for embedding Android and iOS views, this plugin might share some known issues tagged with the platform-views label.

Requirements

  • Android: minSdkVersion 17 and add support for androidx (see AndroidX Migration)
  • iOS: --ios-language swift, Xcode version >= 11
  • Web: None

Setup

Web

No Configuration Required.

iOS

No Configuration Required.

Follow the guide here for complete iOS setup

Android

Set minSdkVersion of your android/app/build.gradle file to at least 17.

Follow the guide here for complete Android setup

Note: Although the minimum to be set is 17, the player won't play on device with API < 20 (19 if Hybrid Composition is enabled). For API < 20 devices, you might want to forward the video to be played using YouTube app instead, using packages like url_launcher or android_intent.

Using the player

YoutubePlayerController? _controller;
 void initState() {
    super.initState();
    _controller = YoutubePlayerController(
      initialVideoId: videoId,
    
      flags: YoutubePlayerFlags(autoPlay: true, mute: false, startAt: 0),
    );
}


//--------------- in Widget build(BuildContext context) -------------------
YoutubePlayer(
  controller: _controller!,
  showVideoProgressIndicator: true,
  progressIndicatorColor: Colors.amber,
  progressColors: ProgressBarColors(
    playedColor: Colors.amber,
    handleColor: Colors.amberAccent,
  ),
  onReady: () {
    _controller!.addListener(listener);
  },
),

###For FullScreen Support

YoutubePlayerBuilder(
    player: YoutubePlayer(
      showVideoProgressIndicator: true,
      controller: _controller!,
    ),
    builder: (context, player) {
      return Column(
        children: [
          // some widgets
          player,
        ],
      );
    },
),

Want to customize the player?

The package provides YoutubePlayerBuilder, which can be used to create any custom controls.

For example, let's create a custom play pause button.

YoutubePlayerBuilder(
   controller: _controller, // This can be omitted, if using `YoutubePlayerControllerProvider`
   builder: (context, value) {
      return IconButton(
         icon: Icon( 
                  value.playerState == PlayerState.playing
                    ? Icons.pause
                    : Icons.play_arrow,
         ),
         onPressed: () {
          value.playerState == PlayerState.playing
            ? context.ytController.pause()
            : context.ytController.play();
         },
      );
   },
);

Available Methods

Methods available for YoutubePlayerController.

Method Description
play() Plays the currently cued/loaded video.
pause() Pauses the currently playing video.
stop() Stops and cancels loading of the current video.
nextVideo() Loads and plays the next video in the playlist.
previousVideo() Loads and plays the previous video in the playlist.
playVideoAt(index) Loads and plays the specified video in the playlist.
load(videoId, {startAt, endAt}) Loads and plays the specified video.
cue(videoId, {startAt, endAt}) Loads the specified video's thumbnail and prepares the player to play the video.
loadPlaylist(list, {listType, startAt, index}) Loads the specified list and plays it.
cuePlaylist(list, {listType, startAt, index}) Queues the specified list of videos.
mute() Mutes the player.
unMute() Unmutes the player.
setVolume(volume) Sets the volume of player.
seekTo(position, {allowSeekAhead}) Seeks to a specified time in the video.
setSize(size) Sets the size in pixels of the player.
setPlaybackRate(rate) Sets the playback speed for the video.
setLoop(loop) Enables or disables looping.
setShuffle(shuffle) Enables or disables shuffling playlist.
reset() Resets the controller.
convertUrlToId(url, {trimWhiteSpaces}) Converts fully qualified YouTube Url to video id.
getThumbnail(videoId, {quality, webp}) Grabs YouTube video's thumbnail for provided video id.
onEnterFullScreen() Called when player enters fullscreen.
onExitFullScreen() Called when player exits fullscreen.
invokeJavascript(function) Invoke custom javascript function.
hideTopMenu() Hides the title and share icons at the top of player (May violate YouTube's TOS. Use at your own risk.)
hidePauseOverlay() Hides the related videos overlay while player is paused (May violate YouTube's TOS. Use at your own risk.)

Youtube Player Parameters

All the available parameters.

Parameter Description
autoPlay Specifies whether the initial video will automatically start to play when the player loads. Default = true
mute Mutes the player. Default = false
captionLanguage Caption language. Default = 'en'
enableCaption Enables caption by default. Default = true
color Specifies the color that will be used in the player's video progress bar to highlight the amount of the video that the viewer has already seen. Default = red
showControls Indicates whether the video player controls are displayed. Default = true
enableKeyboard Enables or disables the player to respond to keyboard controls. Default = false
enableJavaScript Enables or disables the player to be controlled via IFrame or JavaScript Player API calls. Default = true
endAt Ends the playback in specified time.
showFullscreenButton Shows or hides the fullscreen button from displaying in the player. Default = false
interfaceLanguage Sets the player's interface language.
showVideoAnnotations Enables or disables video annotations to be shown by default. Default = true
loop Enables or disables the player to play the initial video again and again. Default = true
playlist Specifies a list of video IDs to be played after initialVideoId.
playsInline Controls whether videos play inline or fullscreen in an HTML5 player on iOS. Default = true
strictRelatedVideos Enabling ensure that related videos will come from the same channel as the video that was just played. Default = false
startAt Starts the video at specified time.
desktopMode The controls will be alike Youtube Desktop's controls.
useHybridComposition Enable Hybrid Composition

Limitation

For Android: Since the plugin is based on platform views. This plugin requires Android API level 19 or greater.

License

Copyright 2021 Sarbagya Dhaubanjar. All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above
      copyright notice, this list of conditions and the following
      disclaimer in the documentation and/or other materials provided
      with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

youtube_player_flutter's People

Contributors

abhi011999 avatar arolleaguekeng avatar buildtheui avatar carlosfiori avatar chandrabezzo avatar chisatomatsuzaki avatar curvel avatar erickzanardo avatar figengungor avatar godwin-codeprism avatar hiiamalanou avatar hsangtini avatar hugoheneault avatar inc16sec avatar jacob-hutchings avatar johnpryan avatar keithcwk avatar kevmoo avatar mdalameen avatar mloft74 avatar moseco avatar olegsvs avatar paulhfch avatar sami-kouatli-act avatar sarbagya-acme avatar sarbagyastha avatar sayene avatar sgehrman avatar shix0 avatar tinhhuynh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

youtube_player_flutter's Issues

transformClassesWithMultidexlistForDebug

Hi I've got the following error

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
> com.android.build.api.transform.TransformException: Error while generating the main dex list.```

Is there something something to do with Upgrading to AndroidX?

Incompatibity with google_sign_in

If you have this package installed together with google_sign_in, it won't build. Does anyone have a workaround for it?

dependencies:
  youtube_player_flutter: ^1.1.0
  google_sign_in: ^4.0.1+3
D8: Program type already present: android.support.v4.os.ResultReceiver$MyResultReceiver

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: D:\_Development\SmoothCookies-AppFlutter\teste\build\app\intermediates\transforms\dexBuilder\debug\2.jar, D:\_Development\SmoothCookies-AppFlutter\teste\build\app\intermediates\transforms\dexBuilder\debug\3.jar, D:\_Development\SmoothCookies-AppFlutter\teste\build\app\intermediates\transforms\dexBuilder\debug\4.jar, D:\_Development\SmoothCookies-AppFlutter\teste\build\app\intermediates\transforms\dexBuilder\debug\5.jar, D:\_Development\SmoothCookies-AppFlutter\teste\build\app\intermediates\transforms\dexBuilder\debug\6.jar, D:\_Development\SmoothCookies-AppFlutter\teste\build\app\intermediates\transforms\dexBuilder\debug\7.jar, D:\_Development\SmoothCookies-AppFlutter\teste\build\app\intermediates\transforms\dexBuilder\debug\8.jar, D:\_Development\SmoothCookies-AppFlutter\teste\build\app\intermediates\transforms\dexBuilder\debug\9.jar, D:\_Development\SmoothCookies-AppFlutter\teste\build\app\intermediates\transforms\dexBuilder\debug\10.jar, D:\_Development\SmoothCookies-AppFlutter\teste\build\app\intermediates\transforms\dexBuilder\debug\11.jar, D:\_Development\SmoothCookies-AppFlutter\teste\build\app\intermediates\transforms\dexBuilder\debug\12.jar, D:\_Development\SmoothCookies-AppFlutter\teste\build\app\intermediates\transforms\dexBuilder\debug\13.jar, D:\_Development\SmoothCookies-AppFlutter\teste\build\app\intermediates\transforms\dexBuilder\debug\14.jar, D:\_Development\SmoothCookies-AppFlutter\teste\build\app\intermediates\transforms\dexBuilder\debug\15.jar, D:\_Development\SmoothCookies-AppFlutter\teste\build\app\intermediates\transforms\dexBuilder\debug\16.jar, D:\_Development\SmoothCookies-AppFlutter\teste\build\app\intermediates\transforms\dexBuilder\debug\17.jar, D:\_Development\SmoothCookies-AppFlutter\teste\build\app\intermediates\transforms\dexBuilder\debug\18.jar, D:\_Development\SmoothCookies-AppFlutter\teste\build\app\intermediates\transforms\dexBuilder\debug\19.jar, D:\_Development\SmoothCookies-AppFlutter\teste\build\app\intermediates\transforms\dexBuilder\debug\20.jar, D:\_Development\SmoothCookies-AppFlutter\teste\build\app\intermediates\transforms\dexBuilder\debug\21.jar, D:\_Development\SmoothCookies-AppFlutter\teste\build\app\intermediates\transforms\dexBuilder\debug\22.jar, D:\_Development\SmoothCookies-AppFlutter\teste\build\app\intermediates\transforms\dexBuilder\debug\23.jar, D:\_Development\SmoothCookies-AppFlutter\teste\build\app\intermediates\transforms\dexBuilder\debug\24.jar, D:\_Development\SmoothCookies-AppFlutter\teste\build\app\intermediates\transforms\dexBuilder\debug\25.jar, D:\_Development\SmoothCookies-AppFlutter\teste\build\app\intermediates\transforms\dexBuilder\debug\26.jar, D:\_Development\SmoothCookies-AppFlutter\teste\build\app\intermediates\transforms\dexBuilder\debug\27.jar, D:\_Development\SmoothCookies-AppFlutter\teste\build\app\intermediates\transforms\dexBuilder\debug\28.jar
  Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
  Program type already present: android.support.v4.os.ResultReceiver$MyResultReceiver

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 3s
*******************************************************************************************
The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
See https://goo.gl/CP92wY for more information on the problem and how to fix it.
*******************************************************************************************
Finished with error: Gradle task assembleDebug failed with exit code 1

App Crashes on full-screen button pressed for LANDSCAPE!

Hey,
Thanks for the package!

But there's an issue which is a very fundamental one:
The app functions nicely, until the ** Full-Screen Button for Landscape mode** is pressed

Actions to crash the app:
Open App --> Let the video play --> Press FullScreen Icon --> App Crashes

Request you to please look into the issue.
Any help is hugely appreciated!

Thanks.

Unlisted Videos not playing

It keeps on loading forever. Unlisted videos don't need login for playing it, IDK why it doesn't work even then

Support for setlooping

Is there any way to implement setlooping(true) with this plugin, if not detecting VideoEnd event may allow that by replaying it.

How to start the videos at a specific time?

Hello, this is more a doubt of how to use than a real issue...

I'm trying to start the videos at a specific time, but I couldn't do that before the video start.
If I let the video start automatically and then call controller.seekTo( ... ) when press a button, for instance, the video goes correctly to the specific time.

Can you help me with that?
Thanks!

Sugguestion: go to portrait mode when click "fullscreen button" in fullscreen mode

Prerequisite

YoutubeScaffold(
      fullScreenOnOrientationChange: true

The device auto rotation turned ON
the device is holding horizontally
Android device

Expectation (suggestion)

When I tap on the fullscreen button of the default control, it should exit the fullscreen mode and bring me back to my normal layout.

Reality

The screen stays at fullscreen.

Video Pauses on Resize

When dynamically increasing the width of the video player, it stops playing. I would expect it to continue playing as the size changes. This would allow a user to minimize/maximize videos to their own sizes instead of using the fullscreen functionality.

import 'package:flutter/material.dart';
import 'package:youtube_player_flutter/youtube_player_flutter.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  double width = 100.0;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Transition Demo',
      home: Scaffold(
          appBar: AppBar(
            title: Text('Demo'),
          ),
          body: Column(
            children: <Widget>[
              YoutubePlayer(
                context: context,
                videoId: "iLnmTe5Q2Qw",
                flags: YoutubePlayerFlags(
                  autoPlay: true,
                  showVideoProgressIndicator: true,
                ),
                width: width,
              ),
              FlatButton(child: Text('Increase'), onPressed: () => setState(()=> width += 10)),
            ],
          ),
        ),
    );
  }
}

After clicking the button to change the width, the console outputs the following. It looks like it is unintializing the video, then reloading it.

D/ViewRootImpl@d4a2009[MainActivity](12807): ViewPostIme pointer 0
D/ViewRootImpl@d4a2009[MainActivity](12807): ViewPostIme pointer 1
D/Dialog  (12807): mIsSamsungBasicInteraction = false, isMetaDataInActivity = false
D/InputTransport(12807): Input channel constructed: fd=189
D/ViewRootImpl@9528d35[MainActivity](12807): setView = DecorView@b2a75ca[MainActivity] TM=true MM=false
D/OpenGLRenderer(12807): eglDestroySurface = 0x74c3bedb80, 0x74c3ad8000
D/ViewRootImpl@4ba4055[MainActivity](12807): dispatchDetachedFromWindow
D/ViewRootImpl@4ba4055[MainActivity](12807): Surface release. android.view.ViewRootImpl.doDie:7931 android.view.ViewRootImpl.die:7899 android.view.WindowManagerGlobal.removeViewLocked:497 android.view.WindowManagerGlobal.removeView:435 android.view.WindowManagerImpl.removeViewImmediate:124 android.app.Dialog.dismissDialog:518 android.app.Dialog.dismiss:501 android.app.Dialog.cancel:1462
D/InputTransport(12807): Input channel destroyed: fd=207
V/InputMethodManager(12807): Not IME target window, ignoring
D/ViewRootImpl@9528d35[MainActivity](12807): dispatchAttachedToWindow
D/ViewRootImpl@9528d35[MainActivity](12807): Relayout returned: old=[0,0][499,281] new=[0,0][499,281] result=0x7 surface={valid=true 501499133952} changed=true
D/OpenGLRenderer(12807): eglCreateWindowSurface = 0x74c3bedc80, 0x74c3ad8010
D/ViewRootImpl@9528d35[MainActivity](12807): Relayout returned: old=[0,0][499,281] new=[0,0][499,281] result=0x1 surface={valid=true 501499133952} changed=false
D/ViewRootImpl@9528d35[MainActivity](12807): MSG_RESIZED: frame=Rect(0, 0 - 499, 281) ci=Rect(0, 0 - 0, 0) vi=Rect(0, 0 - 0, 0) or=2
I/flutter (12807): PlaybackQualityChange large
D/        (12807): PlayerBase::PlayerBase()
D/        (12807): TrackPlayerBase::TrackPlayerBase()
I/libOpenSLES(12807): Emulating old channel mask behavior (ignoring positional mask 0x3, using default mask 0x3 based on channel count of 2)
I/cr_MediaCodecBridge(12807): create MediaCodec video decoder, mime video/x-vnd.on2.vp9
I/ACodec  (12807):  [] Now uninitialized
I/ACodec  (12807): [] onAllocateComponent
I/OMXClient(12807): IOmx service obtained
I/ACodec  (12807): [OMX.qcom.video.decoder.vp9] Now Loaded
I/MediaCodec(12807): MediaCodec will operate in async mode
D/SurfaceUtils(12807): connecting to surface 0x74b9e5e010, reason connectToSurface
I/MediaCodec(12807): [OMX.qcom.video.decoder.vp9] setting surface generation to 13114379
D/SurfaceUtils(12807): disconnecting from surface 0x74b9e5e010, reason connectToSurface(reconnect)
D/SurfaceUtils(12807): connecting to surface 0x74b9e5e010, reason connectToSurface(reconnect)
I/ACodec  (12807): [HW_HDR] app-pid : 12807
W/DirectStreamingProxy(12807): app-pid not found. use getpid(). pid = 12807
D/DirectStreamingProxy(12807): pid = 12807
I/ACodec  (12807): [OMX.qcom.video.decoder.vp9] OMX_QCOM_FramePacking_OnlyOneCompleteFrame is setting
I/ACodec  (12807): Success to set FramePackingMode
I/SmartFittingClass(12807): Create SmartFitting Version 2.0
I/SmartFittingClass(12807): Init, [State:UNINITIALIZED] pid: 12807
I/ACodec  (12807): [OMX.qcom.video.decoder.vp9] Now Loaded->Idle
I/SmartFittingClass(12807): InitialCheck()
I/SmartFittingClass(12807): Create SmartFittingManagerServiceProxy!!
I/SmartFittingClass(12807): SmartFittingManagerServiceProxy::init
I/SmartFittingClass(12807): Create SmartFittingManagerServiceProxy::EventHandler
I/SmartFittingClass(12807): SmartFittingManagerServiceProxy::onAddSmartFittingListener pid: 12807
I/SmartFittingClass(12807): Create SmartFittingListener
I/SmartFittingClass(12807): InitialCheck, WhiteListStatus returned from CodecSolution : 0
I/SmartFittingClass(12807): InitialCheck, [State:FINISHED] SmartFitting has not been activated by App. Shut Down SmartFitting.
D/SurfaceUtils(12807): set up nativeWindow 0x74b9e5e010 for 854x450, color 0x7fa30c06, rotation 0, usage 0x20402900
I/ACodec  (12807): [OMX.qcom.video.decoder.vp9] configureOutputBuffersFromNativeWindow setBufferCount : 20, minUndequeuedBuffers : 5
I/MediaCodec(12807): setCodecState state : 0
I/ACodec  (12807): [OMX.qcom.video.decoder.vp9] Now Idle->Executing
I/ACodec  (12807): [OMX.qcom.video.decoder.vp9] Now Executing
I/ACodec  (12807): [OMX.qcom.video.decoder.vp9] Now handling output port settings change
D/SurfaceUtils(12807): set up nativeWindow 0x74b9e5e010 for 856x456, color 0x7fa30c06, rotation 0, usage 0x20402900
I/ACodec  (12807): [OMX.qcom.video.decoder.vp9] configureOutputBuffersFromNativeWindow setBufferCount : 20, minUndequeuedBuffers : 5
I/ACodec  (12807): [OMX.qcom.video.decoder.vp9] Now Executing
I/ACodec  (12807): [OMX.qcom.video.decoder.vp9] OMX_EventPortSettingsChanged 0x7f000062
I/MediaCodec(12807): setCodecState state : 1
D/        (12807): TrackPlayerBase::~TrackPlayerBase()
D/        (12807): PlayerBase::~PlayerBase()
I/MediaCodec(12807): setCodecState state : 0
D/        (12807): PlayerBase::stop() from IPlayer
D/AudioTrack(12807): stop() called with 482924 frames delivered
I/MediaCodec(12807): setCodecState state : 1
W/cr_MediaCodecBridge(12807): Releasing: OMX.qcom.video.decoder.vp9
I/ACodec  (12807): [OMX.qcom.video.decoder.vp9] Now Executing->Idle
I/ACodec  (12807): [OMX.qcom.video.decoder.vp9] Now Idle->Loaded
I/ACodec  (12807): [OMX.qcom.video.decoder.vp9] Now Loaded
I/SmartFittingClass(12807): ShutDownSmartFitting!!
I/SmartFittingClass(12807): SmartFittingManagerServiceProxy::Deinit
I/SmartFittingClass(12807): Destroy SmartFittingListener
I/SmartFittingClass(12807): Destroy ~SmartFittingManagerServiceProxy::EventHandler
I/SmartFittingClass(12807): Destroy SmartFitting!!
I/SmartFittingClass(12807): Destroy SmartFittingManagerServiceProxy!!
I/ACodec  (12807):  [OMX.qcom.video.decoder.vp9] Now uninitialized
I/ACodec  (12807):  [] Now kWhatShutdownCompleted event : 8522
D/SurfaceUtils(12807): disconnecting from surface 0x74b9e5e010, reason disconnectFromSurface
I/MediaCodec(12807): Codec shutdown complete
W/cr_MediaCodecBridge(12807): Codec released
D/        (12807): TrackPlayerBase::~TrackPlayerBase()
D/        (12807): PlayerBase::~PlayerBase()

No play next song when Screen off

No play next song when Screen off (Screen on is normal), because setState not run when screen off, after screen on then setState run and next song play.
Code:
void listener() {
if (_youtubePlayerController.value.playerState == PlayerState.ENDED) {
setState(() {
if (_repeat == 0) {
if (_shuffle) {
int random;
if(global_posts.length>1){
do {
random = Random().nextInt(global_posts.length);
} while (global_post_index == random);
global_post_index = random;
}
} else {
if (global_post_index >= global_posts.length - 1) {
_showDialogEndedPlaylist();
} else {
global_post_index++;
}
}
} else if (_repeat == 1) {
if (_shuffle) {
int random;
if(global_posts.length>1){
do {
random = Random().nextInt(global_posts.length);
} while (global_post_index == random);
global_post_index = random;
}
else{
}
} else {
if (global_post_index >= global_posts.length - 1) {
global_post_index = 0;
} else {
global_post_index++;
}
}
} else {
}
});
}

YoutubePlayer(
context: context,
width: 50,
videoId:
global_posts[global_post_index].youtube_link,
flags: YoutubePlayerFlags(
autoPlay: true,
showVideoProgressIndicator: false,
hideFullScreenButton: true,
hideControls: true),
onPlayerInitialized: (controller) {
_youtubePlayerController = controller;
_youtubePlayerController.addListener(listener);
},
)

Experiments on introducing newer approach

The current approach is based on playing videos on top of webview, which is using PlatformViews (Android & iOS). And PlatformViews are known to have issues and are resource hungry too. (See here and here).

Some of the issues in current approach:

  • Memory Intensive #21
  • Not working for iOS as expected(rarely works in 3/4 builds) #2
  • Problem while resizing or refreshing screens.
  • Couldn't adapt aspect ratios. #6
  • Crashes the app when rapidly navigating through screens. #8

I intend to address all these issues with a new approach. If I succeed with this new approach then:

  • Player will be lot more faster.
  • Will have more controls over the player.
  • Addresses all the issues listed above.
  • Will also support Android KitKat devices (API Level 19).

So, I will be working on this from today and won't be replying to newer issues in this repo until something is decided regarding the newer approach.

Thank you for love and support folks. ❤️
Your feedbacks will be appreciated.

gradle error when i add your plugin to dependencies

hello
when i just add your plugin to dependencies i got this error with gradle without even import or use this plugin in any page or dart code

`
FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.

com.android.build.api.transform.TransformException: Error while generating the main dex list.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 4s
Finished with error: Gradle task assembleDebug failed with exit code 1

`

thank you

Video Player Hangs at UNKNOWN State

originally thought this was related to issue #17, but I am using version 2.0.0 and am still having this problem.

It seems that videos will randomly fail to load. The video player will never reach the QUED state. It just stays at the UNKNOWN state.

The screenshot below from the demo app modified to display the player state shows this.

scrnshot1

When I tap on the video, it shows the controls but pressing play does nothing.

scrnshot2

Devices I've tested with:

  • Samsung Galaxy S9: occurs about 15% of the time
  • Samsung Galaxy S6: occurs about 10% of the time
  • Simulated Nexus 10: occurs about 10% of the time

Introducing beta version of the player.

Improvements:

  • Faster full screen toggling.
  • Toggles full screen on orientation change.
  • Option to add own custom thumbnail.
  • Memory efficient than previous versions.
  • Fixes for some videos being stuck at Unknown state forever.

Issues:

  • Some devices from vendor like (Xiaomi, Huawei, Vivo, Pixel devices, etc.) crashes frequently while toggling full screen. There is a recent PR regarding the issue in Flutter Engine repo . Hope this gets fixed soon. 🤞
    Related #8 .

Pub Link: https://pub.dev/packages/youtube_player_flutter/versions/3.0.0-beta.4

conflict with webview_flutter

when I include both webview_flutter and youtube_player_flutter, application would crash upon starts with the following warning and error

objc[44664]: Class FLTCookieManager is implemented in both /Users/ace/Library/Developer/CoreSimulator/Devices/B18AEF78-2279-4A87-AF9C-EC10E395036D/data/Containers/Bundle/Application/7210DA0C-0DBD-40B3-82E4-83D52BA8ADF7/Runner.app/Frameworks/ytview.framework/ytview (0x10c3d8400) and /Users/ace/Library/Developer/CoreSimulator/Devices/B18AEF78-2279-4A87-AF9C-EC10E395036D/data/Containers/Bundle/Application/7210DA0C-0DBD-40B3-82E4-83D52BA8ADF7/Runner.app/Frameworks/webview_flutter.framework/webview_flutter (0x10c3bb250). One of the two will be used. Which one is undefined.
objc[44664]: Class FLTWKNavigationDelegate is implemented in both /Users/ace/Library/Developer/CoreSimulator/Devices/B18AEF78-2279-4A87-AF9C-EC10E395036D/data/Containers/Bundle/Application/7210DA0C-0DBD-40B3-82E4-83D52BA8ADF7/Runner.app/Frameworks/ytview.framework/ytview (0x10c3d8450) and /Users/ace/Library/Developer/CoreSimulator/Devices/B18AEF78-2279-4A87-AF9C-EC10E395036D/data/Containers/Bundle/Application/7210DA0C-0DBD-40B3-82E4-83D52BA8ADF7/Runner.app/Frameworks/webview_flutter.framework/webview_flutter (0x10c3bb2a0). One of the two will be used. Which one is undefined.
objc[44664]: Class FLTWebViewFactory is implemented in both /Users/ace/Library/Developer/CoreSimulator/Devices/B18AEF78-2279-4A87-AF9C-EC10E395036D/data/Containers/Bundle/Application/7210DA0C-0DBD-40B3-82E4-83D52BA8ADF7/Runner.app/Frameworks/ytview.framework/ytview (0x10c3d84a0) and /Users/ace/Library/Developer/CoreSimulator/Devices/B18AEF78-2279-4A87-AF9C-EC10E395036D/data/Containers/Bundle/Application/7210DA0C-0DBD-40B3-82E4-83D52BA8ADF7/Runner.app/Frameworks/webview_flutter.framework/webview_flutter (0x10c3bb2f0). One of the two will be used. Which one is undefined.
objc[44664]: Class FLTWebViewController is implemented in both /Users/ace/Library/Developer/CoreSimulator/Devices/B18AEF78-2279-4A87-AF9C-EC10E395036D/data/Containers/Bundle/Application/7210DA0C-0DBD-40B3-82E4-83D52BA8ADF7/Runner.app/Frameworks/ytview.framework/ytview (0x10c3d84c8) and /Users/ace/Library/Developer/CoreSimulator/Devices/B18AEF78-2279-4A87-AF9C-EC10E395036D/data/Containers/Bundle/Application/7210DA0C-0DBD-40B3-82E4-83D52BA8ADF7/Runner.app/Frameworks/webview_flutter.framework/webview_flutter (0x10c3bb318). One of the two will be used. Which one is undefined.
objc[44664]: Class FLTJavaScriptChannel is implemented in both /Users/ace/Library/Developer/CoreSimulator/Devices/B18AEF78-2279-4A87-AF9C-EC10E395036D/data/Containers/Bundle/Application/7210DA0C-0DBD-40B3-82E4-83D52BA8ADF7/Runner.app/Frameworks/ytview.framework/ytview (0x10c3d8540) and /Users/ace/Library/Developer/CoreSimulator/Devices/B18AEF78-2279-4A87-AF9C-EC10E395036D/data/Containers/Bundle/Application/7210DA0C-0DBD-40B3-82E4-83D52BA8ADF7/Runner.app/Frameworks/webview_flutter.framework/webview_flutter (0x10c3bb390). One of the two will be used. Which one is undefined.
objc[44664]: Class FLTWebViewFlutterPlugin is implemented in both /Users/ace/Library/Developer/CoreSimulator/Devices/B18AEF78-2279-4A87-AF9C-EC10E395036D/data/Containers/Bundle/Application/7210DA0C-0DBD-40B3-82E4-83D52BA8ADF7/Runner.app/Frameworks/ytview.framework/ytview (0x10c3d85b8) and /Users/ace/Library/Developer/CoreSimulator/Devices/B18AEF78-2279-4A87-AF9C-EC10E395036D/data/Containers/Bundle/Application/7210DA0C-0DBD-40B3-82E4-83D52BA8ADF7/Runner.app/Frameworks/webview_flutter.framework/webview_flutter (0x10c3bb458). One of the two will be used. Which one is undefined.
2019-05-04 09:20:00.568482+0700 Runner[44664:362412] libMobileGestalt MobileGestalt.c:890: MGIsDeviceOneOfType is not supported on this platform.
2019-05-04 09:20:00.844000+0700 Runner[44664:362412] You've implemented -[<UIApplicationDelegate> application:performFetchWithCompletionHandler:], but you still need to add "fetch" to the list of your supported UIBackgroundModes in your Info.plist.
2019-05-04 09:20:00.844196+0700 Runner[44664:362412] You've implemented -[<UIApplicationDelegate> application:didReceiveRemoteNotification:fetchCompletionHandler:], but you still need to add "remote-notification" to the list of your supported UIBackgroundModes in your Info.plist.
2019-05-04 09:20:00.845692+0700 Runner[44664:362412] *** Assertion failure in -[FlutterEngine registrarForPlugin:], ../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm:560
2019-05-04 09:20:00.917563+0700 Runner[44664:362412] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Duplicate plugin key: FLTWebViewFlutterPlugin'
*** First throw call stack:
(
	0   CoreFoundation                      0x000000010d4296fb __exceptionPreprocess + 331
	1   libobjc.A.dylib                     0x000000010c9cdac5 objc_exception_throw + 48
	2   CoreFoundation                      0x000000010d429482 +[NSException raise:format:arguments:] + 98
	3   Foundation                          0x000000010c41b927 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 194
	4   Flutter                             0x000000010a5a3d6b -[FlutterEngine registrarForPlugin:] + 269
	5   Runner                              0x000000010a29be1e +[GeneratedPluginRegistrant registerWithRegistry:] + 174
	6   Runner                              0x000000010a29bf18 $s6Runner11AppDelegateC11application_29didFinishLaunchingWithOptionsSbSo13UIApplicationC_SDySo0j6LaunchI3KeyaypGSgtF + 168
	7   Runner                              0x000000010a29c254 $s6Runner11AppDelegateC11application_29didFinishLaunchingWithOptionsSbSo13UIApplicationC_SDySo0j6LaunchI3KeyaypGSgtFTo + 196
	8   UIKitCore                           0x0000000116d3b311 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 280
	9   UIKitCore                           0x0000000116d3ccad -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 3932
	10  UIKitCore                           0x0000000116d420c6 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1617
	11  UIKitCore                           0x00000001165876d6 __111-[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:]_block_invoke + 904
	12  UIKitCore                           0x000000011658ffce +[_UICanvas _enqueuePostSettingUpdateTransactionBlock:] + 153
	13  UIKitCore                           0x00000001165872ec -[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:] + 236
	14  UIKitCore                           0x0000000116587c48 -[__UICanvasLifecycleMonitor_Compatability activateEventsOnly:withContext:completion:] + 1091
	15  UIKitCore                           0x0000000116585fba __82-[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:]_block_invoke + 782
	16  UIKitCore                           0x0000000116585c71 -[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:] + 433
	17  UIKitCore                           0x000000011658a9b6 __125-[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:]_block_invoke + 576
	18  UIKitCore                           0x000000011658b610 _performActionsWithDelayForTransitionContext + 100
	19  UIKitCore                           0x000000011658a71d -[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:] + 223
	20  UIKitCore                           0x000000011658f6d0 -[_UICanvas scene:didUpdateWithDiff:transitionContext:completion:] + 392
	21  UIKitCore                           0x0000000116d409a8 -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 514
	22  UIKitCore                           0x00000001168f7dfa -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 361
	23  FrontBoardServices                  0x0000000118d71125 -[FBSSceneImpl _didCreateWithTransitionContext:completion:] + 448
	24  FrontBoardServices                  0x0000000118d7aed6 __56-[FBSWorkspace client:handleCreateScene:withCompletion:]_block_invoke_2 + 283
	25  FrontBoardServices                  0x0000000118d7a700 __40-[FBSWorkspace _performDelegateCallOut:]_block_invoke + 53
	26  libdispatch.dylib                   0x0000000110db5db5 _dispatch_client_callout + 8
	27  libdispatch.dylib                   0x0000000110db92ba _dispatch_block_invoke_direct + 300
	28  FrontBoardServices                  0x0000000118dac146 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 30
	29  FrontBoardServices                  0x0000000118dabdfe -[FBSSerialQueue _performNext] + 451
	30  FrontBoardServices                  0x0000000118dac393 -[FBSSerialQueue _performNextFromRunLoopSource] + 42
	31  CoreFoundation                      0x000000010d390be1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
	32  CoreFoundation                      0x000000010d390463 __CFRunLoopDoSources0 + 243
	33  CoreFoundation                      0x000000010d38ab1f __CFRunLoopRun + 1231
	34  CoreFoundation                      0x000000010d38a302 CFRunLoopRunSpecific + 626
	35  GraphicsServices                    0x0000000111ba92fe GSEventRunModal + 65
	36  UIKitCore                           0x0000000116d43ba2 UIApplicationMain + 140
	37  Runner                              0x000000010a29c3f8 main + 72
	38  libdyld.dylib                       0x0000000110e2a541 start + 1
	39  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

I had to remove webview_flutter to be able to run the application.

I only tested this problem on iOS using simulator.

No implementation found for method evaluateJavascript on channel plugins.flutter.io/webview_6

E/flutter ( 4383): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: MissingPluginException(No implementation found for method evaluateJavascript on channel plugins.flutter.io/webview_6)
E/flutter ( 4383): #0 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:300:7)
E/flutter ( 4383):
E/flutter ( 4383): #1 MethodChannelWebViewPlatform.evaluateJavascript (package:ytview/src/webview_method_channel.dart:90:21)
E/flutter ( 4383): #2 WebViewController.evaluateJavascript (package:ytview/ytview.dart:579:39)
E/flutter ( 4383): #3 YoutubePlayerController._evaluateJS (package:youtube_player_flutter/src/youtube_player.dart:608:30)
E/flutter ( 4383): #4 YoutubePlayerController.forceHideAnnotation (package:youtube_player_flutter/src/youtube_player.dart:612:33)
E/flutter ( 4383): #5 __PlayerState.build. (package:youtube_player_flutter/src/youtube_player.dart:486:31)
E/flutter ( 4383): #6 _PlatformCallbacksHandler.onPageFinished (package:ytview/ytview.dart:406:15)
E/flutter ( 4383): #7 MethodChannelWebViewPlatform._onMethodCall (package:ytview/src/webview_method_channel.dart:39:35)
E/flutter ( 4383):
E/flutter ( 4383): #8 MethodChannel._handleAsMethodCall (package:flutter/src/services/platform_channel.dart:383:55)
E/flutter ( 4383):
E/flutter ( 4383): #9 MethodChannel.setMethodCallHandler. (package:flutter/src/services/platform_channel.dart:351:54)
E/flutter ( 4383): #10 BinaryMessages.handlePlatformMessage (package:flutter/src/services/platform_messages.dart:76:33)
E/flutter ( 4383):
E/flutter ( 4383): #11 _invoke3. (dart:ui/hooks.dart:263:15)
E/flutter ( 4383): #12 _rootRun (dart:async/zone.dart:1124:13)
E/flutter ( 4383): #13 _CustomZone.run (dart:async/zone.dart:1021:19)
E/flutter ( 4383): #14 _CustomZone.runGuarded (dart:async/zone.dart:923:7)
E/flutter ( 4383): #15 _invoke3 (dart:ui/hooks.dart:262:10)
E/flutter ( 4383): #16 _dispatchPlatformMessage (dart:ui/hooks.dart:136:5)
E/flutter ( 4383):

When and where should I add my own controller?

Very good package but I'm a kind of confused about how to add my own player controller.

I declear YoutubePlayer as final inside of parent widget's build() and set hideControls to true. But I don't know when and where to init my own controller. Now my code is something like

final YoutubePlayer youtubePlayer = YoutubePlayer(
...
onPlayerInitialized: (controller) {
_player = PlayerPage(controller, true);
setState(() {
_stackList.add(_player);
});
},
};

_stackList.add(youtubePlayer);

return Stack(
children: _stackList,
);

However, I get error for using setState() inside onPlayerInitialized().

I/flutter (13939): setState() or markNeedsBuild() called during build.
I/flutter (13939): This VideoPage widget cannot be marked as needing to build because the framework is already in the
I/flutter (13939): process of building widgets. A widget can be marked as needing to be built during the build phase
I/flutter (13939): only if one of its ancestors is currently building. This exception is allowed because the framework
I/flutter (13939): builds parent widgets before children, which means a dirty descendant will always be built.
I/flutter (13939): Otherwise, the framework might not visit this widget during this build phase.
I/flutter (13939): The widget on which setState() or markNeedsBuild() was called was:
I/flutter (13939): VideoPage(state: _VideoPageState#af93c)
I/flutter (13939): The widget which was currently being built when the offending call was made was:
I/flutter (13939): NotificationListener
I/flutter (13939):
I/flutter (13939): When the exception was thrown, this was the stack:
...

Seems the onPlayerInitialized run before parent build done. But I can't refer to _controller either inside the parent build() because it's null at that time.

Could you tell me how to do that correctly? Or even better if you've got a example about adding a custom controller. Thank you.

Cannot run the example project on Android

I downloaded and run the project on my android emulator. I could see the thumbnail of the youtube link showing on the YoutubePlayer, however, i could not play the video.

Here are the logs appears when I pressed the play button of the YoutubePlayer

W/System.err( 4071): java.lang.RuntimeException: Methods marked with @UiThread must be executed on the main thread. Current thread: JavaBridge
W/System.err( 4071): at io.flutter.embedding.engine.FlutterJNI.ensureRunningOnMainThread(FlutterJNI.java:605)
W/System.err( 4071): at io.flutter.embedding.engine.FlutterJNI.dispatchPlatformMessage(FlutterJNI.java:515)
W/System.err( 4071): at io.flutter.embedding.engine.dart.DartMessenger.send(DartMessenger.java:74)
W/System.err( 4071): at io.flutter.embedding.engine.dart.DartExecutor.send(DartExecutor.java:163)
W/System.err( 4071): at io.flutter.view.FlutterNativeView.send(FlutterNativeView.java:152)
W/System.err( 4071): at io.flutter.plugin.common.MethodChannel.invokeMethod(MethodChannel.java:95)
W/System.err( 4071): at io.flutter.plugin.common.MethodChannel.invokeMethod(MethodChannel.java:82)
W/System.err( 4071): at io.flutter.plugins.webviewflutter.JavaScriptChannel$1.run(JavaScriptChannel.java:49)
W/System.err( 4071): at io.flutter.plugins.webviewflutter.JavaScriptChannel.postMessage(JavaScriptChannel.java:53)
W/System.err( 4071): at android.os.MessageQueue.nativePollOnce(Native Method)
W/System.err( 4071): at android.os.MessageQueue.next(MessageQueue.java:323)
W/System.err( 4071): at android.os.Looper.loop(Looper.java:136)
W/System.err( 4071): at android.os.HandlerThread.run(HandlerThread.java:61)
I/chromium( 4071): [INFO:CONSOLE(24)] "Uncaught Error: Java exception was raised during method invocation", source: https://sarbagyadhaubanjar.github.io/youtube_player/player.js (24)
W/System.err( 4071): java.lang.RuntimeException: Methods marked with @UiThread must be executed on the main thread. Current thread: JavaBridge
W/System.err( 4071): at io.flutter.embedding.engine.FlutterJNI.ensureRunningOnMainThread(FlutterJNI.java:605)
W/System.err( 4071): at io.flutter.embedding.engine.FlutterJNI.dispatchPlatformMessage(FlutterJNI.java:515)
W/System.err( 4071): at io.flutter.embedding.engine.dart.DartMessenger.send(DartMessenger.java:74)
W/System.err( 4071): at io.flutter.embedding.engine.dart.DartExecutor.send(DartExecutor.java:163)
W/System.err( 4071): at io.flutter.view.FlutterNativeView.send(FlutterNativeView.java:152)
W/System.err( 4071): at io.flutter.plugin.common.MethodChannel.invokeMethod(MethodChannel.java:95)
W/System.err( 4071): at io.flutter.plugin.common.MethodChannel.invokeMethod(MethodChannel.java:82)
W/System.err( 4071): at io.flutter.plugins.webviewflutter.JavaScriptChannel$1.run(JavaScriptChannel.java:49)
W/System.err( 4071): at io.flutter.plugins.webviewflutter.JavaScriptChannel.postMessage(JavaScriptChannel.java:53)
W/System.err( 4071): at android.os.MessageQueue.nativePollOnce(Native Method)
W/System.err( 4071): at android.os.MessageQueue.next(MessageQueue.java:323)
W/System.err( 4071): at android.os.Looper.loop(Looper.java:136)
W/System.err( 4071): at android.os.HandlerThread.run(HandlerThread.java:61)
I/chromium( 4071): [INFO:CONSOLE(31)] "Uncaught Error: Java exception was raised during method invocation", source: https://sarbagyadhaubanjar.github.io/youtube_player/player.js (31)
W/System.err( 4071): java.lang.RuntimeException: Methods marked with @UiThread must be executed on the main thread. Current thread: JavaBridge
W/System.err( 4071): at io.flutter.embedding.engine.FlutterJNI.ensureRunningOnMainThread(FlutterJNI.java:605)
W/System.err( 4071): at io.flutter.embedding.engine.FlutterJNI.dispatchPlatformMessage(FlutterJNI.java:515)
W/System.err( 4071): at io.flutter.embedding.engine.dart.DartMessenger.send(DartMessenger.java:74)
W/System.err( 4071): at io.flutter.embedding.engine.dart.DartExecutor.send(DartExecutor.java:163)
W/System.err( 4071): at io.flutter.view.FlutterNativeView.send(FlutterNativeView.java:152)
W/System.err( 4071): at io.flutter.plugin.common.MethodChannel.invokeMethod(MethodChannel.java:95)
W/System.err( 4071): at io.flutter.plugin.common.MethodChannel.invokeMethod(MethodChannel.java:82)
W/System.err( 4071): at io.flutter.plugins.webviewflutter.JavaScriptChannel$1.run(JavaScriptChannel.java:49)
W/System.err( 4071): at io.flutter.plugins.webviewflutter.JavaScriptChannel.postMessage(JavaScriptChannel.java:53)
W/System.err( 4071): at android.os.MessageQueue.nativePollOnce(Native Method)
W/System.err( 4071): at android.os.MessageQueue.next(MessageQueue.java:323)
W/System.err( 4071): at android.os.Looper.loop(Looper.java:136)
W/System.err( 4071): at android.os.HandlerThread.run(HandlerThread.java:61)
I/chromium( 4071): [INFO:CONSOLE(24)] "Uncaught Error: Java exception was raised during method invocation", source: https://sarbagyadhaubanjar.github.io/youtube_player/player.js (24)
E/eglCodecCommon( 4071): glUtilsParamSize: unknow param 0x000085b5
E/eglCodecCommon( 4071): glUtilsParamSize: unknow param 0x000085b5
E/eglCodecCommon( 4071): glUtilsParamSize: unknow param 0x000085b5

Is there any initial setup that i have missed?

Version 3 unusable

Hi there,

I was so happy to find out there is a new version.

I updated my app and everything exploded.

I tried the example on git and it is the same behavior - see this recording https://www.dropbox.com/s/ju6mu21gqocl8o5/20190623_161111.mp4?dl=0

From video:

  1. fullscreen square button does not work
  2. changing to landscape does not make the video fullscreen
  3. returning to non fullscreen mode somehow destroys the playing.

I have to revert to version 2, this new version is just not working.

I hope you can fix it soon,

Wish you good luck.

Device is Samsung Galaxy S8

Does not play the video on iOS

Sadly, i cannot get it to work on iOS. In Android it works fine. In iOS it just does not play the video and sometimes I experienced freezes.

I tested it with two iOS devices (iPad 2017 with iOS 12 and iPad Air with iOS 10). There is no error message in the Debug Console, it just loads forever.

I used your example project with the most up to date plugin version (but also tried 1.0.0 with the same result). And also tried it with my real world project.

I added this to Info.plist:
<key>io.flutter.embedded_views_preview</key> <true/>

Have you tried the plugin on iOS devices? Any suggestions?

Why is it so memory intensive?

Thanks for this player, it's awesome!

Is there a way to limit how much ram this player uses? I cloned the example app and it keeps crashing my emulator.

Playing -> fullscreen > small screen -> Pause

I have this scenario, even using your example (only tested on Android):

  1. Play video in small/usual size
  2. Press fullscreen icon
  3. Video now plays in fullscreen
  4. Press back button to go to small/usual screen
  5. On small/usual screen the status says: BUFFERING and then PAUSED.

Expected behavior:
5. On small/usual screen the status says: BUFFERING and then PLAYING.

In other words, resume playing after fullscreen, do not pause when coming back from fullscreen.

App crash on when pop a screen with youtube_player_flutter

First of all thanks for the plugin.

I'm having problems when I pop a screen that has the player view, here is a code example that has the issue:

Here is the error log when I pop the Screen: https://github.com/davidgalarza/youtube

D/AudioTrack(30978): stop() called with 938884 frames delivered
D/AndroidRuntime(30978): Shutting down VM
D/ (30978): PlayerBase::stop() from IPlayer
E/AndroidRuntime(30978): FATAL EXCEPTION: main
E/AndroidRuntime(30978): Process: com.example.youtube, PID: 30978
E/AndroidRuntime(30978): java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.DisplayAdjustments android.view.Display.getDisplayAdjustments()' on a null object reference
E/AndroidRuntime(30978): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1746)
E/AndroidRuntime(30978): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1515)
E/AndroidRuntime(30978): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7266)
E/AndroidRuntime(30978): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:981)
E/AndroidRuntime(30978): at android.view.Choreographer.doCallbacks(Choreographer.java:790)
E/AndroidRuntime(30978): at android.view.Choreographer.doFrame(Choreographer.java:721)
E/AndroidRuntime(30978): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:967)
E/AndroidRuntime(30978): at android.os.Handler.handleCallback(Handler.java:808)
E/AndroidRuntime(30978): at android.os.Handler.dispatchMessage(Handler.java:101)
E/AndroidRuntime(30978): at android.os.Looper.loop(Looper.java:166)
E/AndroidRuntime(30978): at android.app.ActivityThread.main(ActivityThread.java:7529)
E/AndroidRuntime(30978): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(30978): at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
E/AndroidRuntime(30978): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
I/zygote64(30978): Do full code cache collection, code=248KB, data=170KB
I/zygote64(30978): After code cache collection, code=225KB, data=142KB
I/Process (30978): Sending signal. PID: 30978 SIG: 9
Lost connection to device.
Exited (sigterm)

My flutter doctor:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.2.1, on Mac OS X 10.13.5 17F77, locale es-EC)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] iOS toolchain - develop for iOS devices (Xcode 9.4.1)
[✓] Android Studio (version 3.2)
[✓] VS Code (version 1.33.1)
[✓] Connected device (1 available)

My device is a Huawei P20 Lite

Some enhancements needed

Thank you for that great plugin I really love it, But there is some enhancements needed:
1- It's not working on iPhone, You already talked about that in another issue.
2- When there's more than two videos in a list it's kinda getting weird a video stops and another one starts and vice versa. so there must be away to tell which video is on the center of the screen.
3- Adding something like autoPlay: true, for the mute at start would be great like mute: true,

Again thank you for this great plugin

Failed evaluating JavaScript, JavaScript string was: 'play()'

Using youtube_player_flutter: ^3.0.0+1.
Platform: iOS | No issues on Android.

Stack trace:

[VERBOSE-2:ui_dart_state.cc(148)] Unhandled Exception: PlatformException(evaluateJavaScript_failed, Failed evaluating JavaScript, JavaScript string was: 'play()'
Error Domain=WKErrorDomain Code=1 "An unknown error occurred" UserInfo={NSLocalizedDescription=An unknown error occurred})
#0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:564:7)
#1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:302:33)
<asynchronous suspension>
#2      MethodChannelWebViewPlatform.evaluateJavascript (package:ytview/src/webview_method_channel.dart:90:21)
#3      WebViewController.evaluateJavascript (package:ytview/ytview.dart:579:39)
#4      YoutubePlayerController._evaluateJS (package:youtube_player_flutter/src/youtube_player.dart:580:30)
#5      YoutubePlayerController.play (package:youtube_player_flutter/src/youtube_player.dart:587:18)
#6      _PlayPauseButtonState.build.<anonymous closure> (package:youtube_player_flutter/src/controls.dart:80:64)
#7      _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:511:14)
#8      _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:566:30)
#9      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:166:24)
#10     TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:240:9)
#11     TapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:211:7)
#12     GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156:27)
#13     _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:225:20)
#14     _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:199:22)
#15     _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7)
#16     _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)
#17     _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
#18     _rootRunUnary (dart:async/zone.dart:1136:13)
#19     _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#20     _CustomZone.runUnaryGuarded (dart:async/zone.dart:931:7)
#21     _invoke1 (dart:ui/hooks.dart:233:10)
#22     _dispatchPointerDataPacket (dart:ui/hooks.dart:154:5)

flutter --version:

Flutter 1.5.4-hotfix.2 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 7a4c33425d (8 weeks ago) • 2019-04-29 11:05:24 -0700
Engine • revision 52c7a1e849
Tools • Dart 2.3.0 (build 2.3.0-dev.0.5 a1668566e5)

Unhandled Exception: PlatformException(evaluateJavaScript_failed, Failed evaluating JavaScript ... )

Hey there!

This package seemed to look pretty cool so I gave it a shot.
Unfortunately I get this error under iOS (haven't tested Android yet) when I hit the play button.

19:22:03.079 282 info flutter.tools [VERBOSE-2:ui_dart_state.cc(148)] Unhandled Exception: PlatformException(evaluateJavaScript_failed, Failed evaluating JavaScript, JavaScript string was: 'player.cueVideoById("secret-but-correct-video-id", 0)'

19:22:03.079 283 info flutter.tools Error Domain=WKErrorDomain Code=5 "JavaScript execution returned a result of an unsupported type" UserInfo={NSLocalizedDescription=JavaScript execution returned a result of an unsupported type})

I did run pod install and also flutter clean. The video thumbnail is showing up in my view so I guess thats at least a partial success.

Warning message when installing package

got this warning message when installing the package

[ios/.symlinks/plugins/ytview] flutter packages get
Warning! This package referenced a Flutter repository via the .packages file that is no longer available. The repository from which the 'flutter' tool is currently executing will be used instead.
  running Flutter tool: /Users/ace/dev/lib/flutterSDK/flutter_dev
  previous reference  : /E:/Flutter
This can happen if you deleted or moved your copy of the Flutter repository, or if it was on a volume that is no longer mounted or has been mounted at a different location. Please check your system path to verify that you are running the expected version (run 'flutter --version' to see which flutter is on your path).

It didn't cause any problem, but i think it would be better if this doesn't appears

Video is not displaying

First thank you for this library. I just tried the sample code provided audio is working but video is not displaying.
image

typo in readme

UPDATE: So I found out that you can also use YES, closing the issue

Hey,
not a big deal but in your readme is written :

Opt-in to the embedded views preview by adding a boolean property to the app's Info.plist file with the key io.flutter.embedded_views_preview and the value YES.

obviously, the value should be true. If you want to make it even more easy for users, I recommend to change the text above to:

Opt-in to the embedded views preview by adding these lines to the app's Info.plist file:
<key>io.flutter.embedded_views_preview</key> <true/>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.