Skip to content
This repository has been archived by the owner on Apr 29, 2021. It is now read-only.

如何实现显示视频进度条,并带有拖动功能 #412

Open
LSG-6 opened this issue Mar 12, 2020 · 4 comments
Open

如何实现显示视频进度条,并带有拖动功能 #412

LSG-6 opened this issue Mar 12, 2020 · 4 comments
Labels
question Further information is requested

Comments

@LSG-6
Copy link

LSG-6 commented Mar 12, 2020

我曾尝试使用LinearProcessIndicator 去表示进度条,但发现其value并不会在runtime进行更新,同时我也不太清楚如何能实现拖动功能。
希望有dalao能解答一下我的问题,万分感谢

@zhuxingwei
Copy link
Contributor

zhuxingwei commented Mar 12, 2020

Hi,按照我的理解,您这边已经实现了一个视频播放器,现在想用UIWidgets来实现一个可以左右拖动当前播放进度的播放进度条对吧?如果是的话,那么首先LinearProcessIndicator确实是不能完成类似功能的,因为它仅仅是一个拥有“只读”功能的组件。
目前UIWidgets暂时没有提供专门的视频播放相关组件。不过您可以参考https://github.com/brianegan/chewie/blob/master/lib/src/cupertino_progress_bar.dart
这个flutter的实现方案。另外
https://api.flutter.dev/flutter/material/Slider-class.html
这个组件UIWidgets是有实现的,它应该也可以实现类似的功能;希望能够帮助到你。如有疑问请回复我们。多谢!

@zhuxingwei zhuxingwei added the question Further information is requested label Mar 12, 2020
@LSG-6
Copy link
Author

LSG-6 commented Mar 15, 2020

感谢您的帮助,
之后我在一个unity UI 的 panel上用UI widgets写了一个脚本,前面都可以正常显示与交互,但在编写slider的时候,报了下述错误:(抱歉以这种粗暴的方式求助orz,但我并未找到可以借鉴的unity脚本)

AssertionError: Error caught by widgets library, thrown building

UIWidgetsSpace.MainPageWidgets(state:UIWidgetsSpace._MainPageWidgetState#CCC00).at

Unity.UIWidgets.material.Slider..ctor (Unity.UIWidgets.foundation.Key key, System.Nullable1[T] value, Unity.UIWidgets.foundation.ValueChanged1[T] onChanged,

Unity.UIWidgets.foundation.ValueChanged`1[T] onChangeStart,

Unity.UIWidgets.foundation.ValueChanged`1[T] onChangeEnd, System.Single min, System.Single max,

System.Nullable`1[T] divisions, System.String label, Unity.UIWidgets.ui.Color activeColor,

Unity.UIWidgets.ui.Color inactiveColor)

。。。。。。

Assertion Error in different scripts

。。。。。。

AssertionError

Unity.UIWidgets.widgets.BuildOwner+<>c__DisplayClass18_2.b__4 () (at

Packages/com.unity.uiwidgets/Runtime/widgets/framework.cs:978)

Unity.UIWidgets.foundation.D.assert (System.Func1[TResult] result, System.Func1[TResult] message)

(at Packages/com.unity.uiwidgets/Runtime/foundation/debug.cs:30)

我把我slider部分的脚本也附在了下面:

                             new SizedBox(
                                 width: 400f,
                                 height: 30f,
                                 child: new Slider(
                                     value: _value,
                                     min: 0f,
                                     max: 1f,
                                     divisions: 10,
                                     activeColor: Colors.red,
                                     inactiveColor: Colors.black,
                                     label: "Set a value",
                                     onChanged: (float newValue) =>
                                     {
                                         _value = newValue;
                                     }
                                     
                                 )

@zhuxingwei
Copy link
Contributor

Hi,抱歉回复比较晚。您方便提供一个完整的error log吗?你上面提供的log并不能定位到具体的exception

@ShiinaManatsu
Copy link

完全可以用slider代替或者stack上套一个slider,另外onChanged赋值的时候需要在setStatus域里赋值以通知state刷新

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants