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

获取此问题视频更改 vdos #42

Closed
gautamenbake opened this issue Feb 15, 2022 · 16 comments
Closed

获取此问题视频更改 vdos #42

gautamenbake opened this issue Feb 15, 2022 · 16 comments

Comments

@gautamenbake
Copy link

[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: PlatformException(VideoError, Video player had error com.google.android.exoplayer2.ExoPlaybackException: MediaCodecVideoRenderer error, index=0, format=Format(1, null, null, video/avc, avc1.64001F, -1, null, [540, 960, 30.0], [-1, -1]), format_supported=YES, null, null)

@mjl0602
Copy link
Owner

mjl0602 commented Feb 15, 2022

Try to play your url in video_player example first.

@gautamenbake
Copy link
Author

gautamenbake commented Feb 15, 2022

thanks for reply @mjl0602

actually, I have pushed your HomePage screen inside another screen, and it gives me these errors and crashes the app.

Long monitor contention with owner Okio Watchdog (22718) at boolean com.android.org.conscrypt.ConscryptEngine.isInboundDone()(ConscryptEngine.java:658) waiters=0 in javax.net.ssl.SSLEngineResult$HandshakeStatus com.android.org.conscrypt.ConscryptEngine.getHandshakeStatus() for 951ms

Skipped 3137 frames!  The application may be doing too much work on its main thread.
W[/Looper]()  (22271): PerfMonitor doFrame : time=51ms vsyncFrame=0 latency=52290ms procState=2 historyMsgCount=1
I[/vibgyorweb.the]()(22271): Clamp target GC heap from 531MB to 512MB

WaitForGcToComplete blocked Alloc on HeapTrim for 42.942ms
I[/vibgyorweb.the]()(22271): Starting a blocking GC Alloc
2
D[/MediaCodecInfo]()(22271): NoSupport [codec.profileLevel, avc1.640034, video[/avc]()] [OMX.qcom.video.decoder.avc, video[/avc]()] [ginkgo, Redmi Note 8, Xiaomi, 30]

Background young concurrent copying GC freed 1454(48KB) AllocSpace objects, 0(0B) LOS objects, 0% free, 511MB[/512MB](), paused 46.077ms total 6.588s

could you pls tell me how to make it efficient, crash free or should i have to explicitly dispose controller after coming back to prev screen, anything!

@mjl0602
Copy link
Owner

mjl0602 commented Feb 15, 2022

You should try to load less video when init video page view by set TikTokVideoListController.loadMoreCount, TikTokVideoListController.preloadCount and TikTokVideoListController.disposeCount. And dispose all video when you exit video page view.

@gautamenbake
Copy link
Author

I have used these values

 this.loadMoreCount = 1,
    this.preloadCount = 3,
    this.disposeCount = 5,

and disposed using this when falling back to initial screen

 void dispose() {
    // 销毁全部
    for (var player in playerList) {
      debugPrint('##### dispose called');
      player.showPauseIcon.dispose();
      player.dispose();
    }
    playerList = [];
    super.dispose();
  }

and still this issue persist

@mjl0602
Copy link
Owner

mjl0602 commented Feb 15, 2022

It seems that you did not provide the correct log. So, I suggest you try to reduce the count of your video to only ONE. And if the crash still happend, you can try video_player directly to see whether the crash is from video_player plugin, or not.

@mjl0602
Copy link
Owner

mjl0602 commented Mar 1, 2022

If you want to pause video after some duration, you should use your custom timer and use video controller to pause the video when timer done.

Use setstate here because every time our state changed, we should call setState(markNeedsBuild).
setState just call markNeedsBuild so you can call it multiple times, it won't cause problem about render performance. If not, you should check the layout progress of your widget tree to make sure flutter can layout in one frame successfully.

@gautamenbake
Copy link
Author

thanks @mjl0602 ur prev comment helped me

@gautamenbake
Copy link
Author

sry prev comment got deleted
_videoListController.addListener(() {
if (mounted) setState(() {});
});

why we use setstate here, bcs of this pageview itembuilder called multiple times.
i want to pause video after some duration until we changed the variable value.

But cant do bcs of pageview builder called multiple times, can't run timer or store instance value to be executed after duration.

@mjl0602
Copy link
Owner

mjl0602 commented Mar 1, 2022

If you want to pause video after some duration, you should use your custom timer and use video controller to pause the video when timer done.

Use setstate here because every time our state changed, we should call setState(markNeedsBuild). setState just call markNeedsBuild so you can call it multiple times, it won't cause problem about render performance. If not, you should check the layout progress of your widget tree to make sure flutter can layout in one frame successfully.

See this.

@gautamenbake
Copy link
Author

gautamenbake commented Mar 1, 2022

look code below //------$$$$$ after every this block
I have used isLocked property in TikTokVideoPage to change icon over video player and user can't tap on gesture after this var false

itemBuilder: (context, i) {
//Put together a video component
bool isF = SafeMap(favoriteMap)[i].boolean;
var player = _videoListController.playerOfIndex(i)!;
var data = player.videoInfo!;
//------$$$$$
bool isVideoCompletedDuration = false;
//---Condition to saved video

        if (widget.screenNameContinousVdoPlayer ==
            ScreenNameContinousVdoPlayer.SavedVideo) {
          //---Timer for 10sec
          Future.delayed(Duration(seconds: 10)).then((value) async {
            //---Pause & show lock icon over video page
            //------$$$$$
            isVideoCompletedDuration = true;
            await player.pause();
          });
        }

        //Right button bar
        Widget buttons = TikTokButtonColumn(
          isFavorite: isF,
          onSave: () {
            VideoService.saveVideo(videoModel: data);
          },
          onFavorite: () {
            // setState(() {
            //   favoriteMap[i] = !isF;
            // });
            // showAboutDialog(context: context);
          },
          onLinks: () {
            CustomBottomSheet.showModalBottomSheet(
              backgroundColor: Colors.white.withOpacity(0),
              context: context,
              builder: (BuildContext context) => VideoLinksBottomSheet(
                bsVideoModel: data,
              ),
            );
          },
          onShare: () {
            Share.share(data.video ?? '');
          },
        );
        // video
        Widget currentVideo = Center(
          child: AspectRatio(
            aspectRatio: player.controller.value.aspectRatio,
            child: VideoPlayer(player.controller),
          ),
        );

        currentVideo = TikTokVideoPage(
          //------$$$$$
          isLocked: widget.screenNameContinousVdoPlayer ==
                  ScreenNameContinousVdoPlayer.SavedVideo &&
              isVideoCompletedDuration,
          // Both gesture playback and natural playback will cause a change in the state of the pause button, pending processing
          hidePauseIcon: !player.showPauseIcon.value,
          aspectRatio: 9 / 16.0,
          key: Key(data.video! + '$i'),
          tag: data.video!,
          bottomPadding: hasBottomPadding ? 16.0 : 16.0,
          userInfoWidget: VideoUserInfo(
            videoModel: data,
            bottomPadding: hasBottomPadding ? 16.0 : 50.0,
          ),
          onSingleTap: () async {
            //------$$$$$
            //---If vdo completed its 10sec duration (subscription expired)
            if (widget.screenNameContinousVdoPlayer ==
                    ScreenNameContinousVdoPlayer.SavedVideo &&
                isVideoCompletedDuration) return;

            if (player.controller.value.isPlaying) {
              await player.pause();
            } else {
              await player.play();
            }
            WatchNowNotifier notifier =
                Provider.of<WatchNowNotifier>(context, listen: false);
            notifier.isRender = !notifier.isRender;
            // setState(() {});
          },
          onAddFavorite: () {
            // setState(() {
            //   favoriteMap[i] = true;
            // });
          },
          rightButtonColumn: buttons,
          video: currentVideo,
        );
        return currentVideo;
      },

@mjl0602
Copy link
Owner

mjl0602 commented Mar 1, 2022

You should not create timer in you build function. Create your timer when some event happed or in initState.
'build' function was designed to call multiple times in any time, so you must make sure it won't cause other effect and just build your widget.

@gautamenbake
Copy link
Author

ok if i want to execute something only once in every page inside pageview how can i do that. Currently if i execute it in itembuilder its called multiple times.

@mjl0602
Copy link
Owner

mjl0602 commented Mar 1, 2022

Create timer in initState and it will be called only once.

@gautamenbake
Copy link
Author

yes you are right but i want it to execute on every video starting == on every new video scroll (once)

@mjl0602
Copy link
Owner

mjl0602 commented Mar 1, 2022

Add listener to TikTokVideoListController.index(is a ValueNotifier), add timer when index.value changed.

@gautamenbake
Copy link
Author

very very thanks @mjl0602 u helped me alot thanks again

@mjl0602 mjl0602 closed this as completed Mar 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants