Youtube_player_flutter: Video Pauses on Resize

Created on 7 Aug 2019  ·  5Comments  ·  Source: sarbagyastha/youtube_player_flutter

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()

bug wontfix

Most helpful comment

try adding the key "forceHD: true", it solved the problem on Android for me, I haven't checked it yet on ios

_controller = YoutubePlayerController(
      initialVideoId: state.video.url,
      flags: const YoutubePlayerFlags(
        autoPlay: false,
        controlsVisibleAtStart: false,
        disableDragSeek: false,
        enableCaption: false,
        forceHD: true,
        hideControls: false,
        hideThumbnail: false,
        isLive: false,
        loop: false,
        mute: false,
     ),
)..addListener(listener);

All 5 comments

@kulture-rob I couldn't figure out why it's pausing. May be it's caused by the webview itself.

I also had this problem. It looked like resizing caused the change of the
playback quality change and then it paused. I still couldn't figure out how
to fix it.

On Sun, Aug 11, 2019 at 11:36 PM Sarbagya Dhaubanjar <
[email protected]> wrote:

@kulture-rob https://github.com/kulture-rob I couldn't figure out why
it's pausing. May be it's caused by the webview itself.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/sarbagyastha/youtube_player_flutter/issues/50?email_source=notifications&email_token=ACX6QVKG7SC4C2MQBU7RQATQEDSDDA5CNFSM4IKAWCP2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4BRTII#issuecomment-520296865,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACX6QVJGNIZZAJCSGHO7ZW3QEDSDDANCNFSM4IKAWCPQ
.

I've noticed also that when you change orientation this behavior also happens (probably due to the resizing).

Any update on this issue?

try adding the key "forceHD: true", it solved the problem on Android for me, I haven't checked it yet on ios

_controller = YoutubePlayerController(
      initialVideoId: state.video.url,
      flags: const YoutubePlayerFlags(
        autoPlay: false,
        controlsVisibleAtStart: false,
        disableDragSeek: false,
        enableCaption: false,
        forceHD: true,
        hideControls: false,
        hideThumbnail: false,
        isLive: false,
        loop: false,
        mute: false,
     ),
)..addListener(listener);
Was this page helpful?
0 / 5 - 0 ratings