Comments (22)
你好,你可以监听播放完毕,然后去播放下一集的url
from flutter_tencentplayer.
腾讯的X5浏览器 播放视频好像内置网络加速,不知道作者这个插件是不同样支持
from flutter_tencentplayer.
不太清楚浏览器端,目前没有打算兼容web端
from flutter_tencentplayer.
如何监听当前播放结束?
from flutter_tencentplayer.
我通过判断时长是否等于播放位置,来确定是不是播放完。controller.value.position.inSeconds ==
controller.value.duration.inSeconds
有没有其他方法
from flutter_tencentplayer.
我这两天抽空把播放结束的事件传出来,可以监听bool isPlayEnd = controller.value.playEnd 。完事告诉你
from flutter_tencentplayer.
我这两天抽空把播放结束的事件传出来,可以监听bool isPlayEnd = controller.value.playEnd 。完事告诉你
好的,谢谢,我通过比较视频长度 和播放进度是否相等判断当前视频是否播放完成,貌似不行,还容易进死循环。
cachePath是不是必须设置才有效?
from flutter_tencentplayer.
已经解决!
配合path_provider 设置缓存路径 播放网络视频体验快很多
from flutter_tencentplayer.
厉害了👍,记得对你设置缓存目录清理哦,它会缓存到本地。不然app占的空间越来越大
from flutter_tencentplayer.
厉害了+1,记得对你设置缓存目录清理哦,它会缓存到本地。不然app占的空间越来越大
有两个方案:
一,在full_video_page dispose里清理,用户每次跳出页面自动清理
二,App设置页面单独设置个清理按钮
我比较倾向第一种。
另外建议,作者example里把cachePath设置好,这样体验快很多。也给想集成该插件的开发者良好的体验,增加集成欲望。
from flutter_tencentplayer.
谢谢提出宝贵意见,后续版本将改进
from flutter_tencentplayer.
缓存目录在cache/txvodcache下吧?
我退出播放界面后删除该文件夹,后面不管是重装 还是卸载重装,都不会重建这个目录怎么回事
from flutter_tencentplayer.
缓存目录你可以自己设置,当然该文件夹要存在哦
from flutter_tencentplayer.
`_initController() {
_getAppCachePath();
print('缓存目录' + appCachePath);
if (widget.controller != null) {
controller = widget.controller;
return;
}
switch (widget.playType) {
case PlayType.network:
controller = TencentPlayerController.network(widget.dataSource,
playerConfig: PlayerConfig(cachePath: appCachePath));
break;
case PlayType.asset:
controller = TencentPlayerController.asset(widget.dataSource);
break;
case PlayType.file:
controller = TencentPlayerController.file(widget.dataSource);
break;
case PlayType.fileId:
controller = TencentPlayerController.network(null,
playerConfig: PlayerConfig(
auth: {"appId": 1251203810, "fileId": widget.dataSource}));
break;
}
controller.initialize();
controller.addListener(listener);
setState(() {});
}
_getAppCachePath() async {
Directory appCacheDir = await getTemporaryDirectory();
setState(() {
appCachePath = appCacheDir.path;
});
}`
print('缓存目录' + appCachePath); 获取不到appCachePath的值 为空。这怎么解决
from flutter_tencentplayer.
你的写法看上去有问题,_getAppCachePath 和print()是同步,但_getAppCachePath是异步,你应该String cachePath = (await _getAppCachePath()).path;
from flutter_tencentplayer.
initController() async {
await getTemporaryDirectory().then((result) {
setState(() {
appCachePath = result.path;
});
}).then(() {
print('缓存目录:'+appCachePath);
if (widget.controller != null) {
controller = widget.controller;
return;
}
switch (widget.playType) {
case PlayType.network:
controller = TencentPlayerController.network(widget.dataSource,
playerConfig: PlayerConfig(cachePath: appCachePath));
break;
case PlayType.asset:
controller = TencentPlayerController.asset(widget.dataSource);
break;
case PlayType.file:
controller = TencentPlayerController.file(widget.dataSource);
break;
case PlayType.fileId:
controller = TencentPlayerController.network(null,
playerConfig: PlayerConfig(
auth: {"appId": 1251203810, "fileId": widget.dataSource}));
break;
}
controller.initialize();
controller.addListener(listener);
setState(() {});
});
}
这样写可以顺利创建缓存目录,但因为是_initController是异步,这样controller.initialize(); ontroller.addListener(listener);就有问题了。
/// 视频
controller.value.initialized
? AspectRatio(
aspectRatio: controller.value.aspectRatio,
child: TencentPlayer(controller),
)
: Image.asset('images/tencentplayer/place_nodata.png'),
这里controller在build的时候就为空了
from flutter_tencentplayer.
你可以,controller != null ? TencentView : SizedBox()或者进app就把getTemporaryDirectory()的返回值存下来,自己想想办法,这应该难不到你
from flutter_tencentplayer.
感谢点拨。在合适的地方,获取到缓存路径 配合preferences持久化,搞定
from flutter_tencentplayer.
关于播放完成的监听,我看了一下代码,之前就接入了,可以通过postion==duration来判断:
_FullVideoPageState() {
listener = () {
if (!mounted) {
return;
}
if (controller.value.position == controller.value.duration) {
print('playEnd');
}
setState(() {});
};
}
from flutter_tencentplayer.
关于播放完成的监听,我看了一下代码,之前就接入了,可以通过postion==duration来判断:
_FullVideoPageState() {
listener = () {
if (!mounted) {
return;
}
if (controller.value.position == controller.value.duration) {
print('playEnd');
}
setState(() {});
};
}
这个方法我试过,但有个bug 因为视频刚加载中获取不到时长,也没播放进度,进死循环了
from flutter_tencentplayer.
_FullVideoPageState() {
listener = () {
if (!mounted) {
return;
}
if (controller.value.position.inSeconds >= 10) {
if (controller.value.position.inSeconds ==
controller.value.duration.inSeconds) {
var hasData = widget.urlsList.indexWhere((item) {
return item.url == widget.dataSource;
});
if (hasData != -1) {
print('监听到了');
print(hasData);
setState(() {
widget.dataSource =
widget.urlsList[widget.currentClearIndex + 1].url;
});
}
}
}
//setState(() {});
};
}
我是将播放地址, 播放地址列表,播放地址在列表中的索引位置都传过来,然后通过索引+1去获取下一集的播放地址。
通过controller.value.position.inSeconds ==
controller.value.duration.inSeconds去判断是否播放完成 就死循环了。
print('监听到了'); 一直打印
from flutter_tencentplayer.
_FullVideoPageState() {
listener = () {
if (!mounted) {
return;
}
if (controller.value.position.inSeconds >= 10) {
if (controller.value.position.inSeconds ==
controller.value.duration.inSeconds) {
var hasData = widget.urlsList.indexWhere((item) {
return item.url == widget.dataSource;
});
if (hasData != -1) {
print('监听到了');
print(hasData);
setState(() {
widget.dataSource =
widget.urlsList[widget.currentClearIndex + 1].url;
});
}
}
}
//setState(() {});
};
}我是将播放地址, 播放地址列表,播放地址在列表中的索引位置都传过来,然后通过索引+1去获取下一集的播放地址。
通过controller.value.position.inSeconds ==
controller.value.duration.inSeconds去判断是否播放完成 就死循环了。print('监听到了'); 一直打印
老哥,你解决了吗,我用inMilliseconds就只有一次了
from flutter_tencentplayer.
Related Issues (20)
- 你好,这个播放器如何主动的去控制音量和屏幕亮度? HOT 2
- dispose无法销毁之前初始化资源自动播放逻辑。 HOT 1
- 在flutter2.5中use a deprecated version of the Android embedding. HOT 2
- 缓存问题:非mp4格式的视频文件不能缓存吗? HOT 1
- iOS在远程流有更改的情况下,无法继续请求流资源。IJKMediaCtrl_DidDnsResolve HOT 1
- IJKMPMoviePlayerVideoDecoderErrorNotification 3210 HOT 6
- ios播放网络视频黑屏 HOT 10
- Android手机播放视频部分视频出现沙沙声听不清声音,画面正常,使用浏览器可以正常播放 HOT 5
- seek 方法崩溃 HOT 1
- 能否支持在web使用? HOT 1
- 能否在flutter版本也添加静音播放的方法 HOT 1
- 播放斗鱼直播掉帧 HOT 9
- The plugin `flutter_tencentplayer` uses a deprecated version of the Android embedding.
- 2.0.1 最新版本打包报错 HOT 1
- 列表视频播放有问题
- 最新版本 Example 跑不起来
- 不支持arm64-v8a HOT 2
- 退出页面并且暂停播放器后还一直有日志输出
- 能够设置回调的时间吗
- The plugin `flutter_tencentplayer` uses a deprecated version of the Android embedding.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flutter_tencentplayer.