帖子
帖子
用户
博客
课程
12下一页
返回列表 发新帖
显示全部楼层
27
帖子
0
勋章
245
Y币

[问题求助] TCSuperPlayer.seekToTime跳转到指定位置没效果

[复制链接]
发表于 2023-8-15 16:03:50

        this.data.TCSuperPlayer.seekToTime({
            toTime: 30
        });




在外面定义var that = this, 把里面的this换成这个that,
27
帖子
0
勋章
245
Y币
chyd · 2023-8-15 16:19在外面定义var that = this, 把里面的this换成这个that,

                let that = this
                that.data.TCSuperPlayer.seekToTime({
                        toTime: 20
                })
这样没用
加油~! · 2023-8-16 11:25let that = this
                that.data.TCSuperPlayer.seekToTime({
                        toTime: 20

建议贴源码,这样看不出什么,这个位置很重要。
27
帖子
0
勋章
245
Y币
chyd · 2023-8-15 16:19在外面定义var that = this, 把里面的this换成这个that,

        this.data.TCSuperPlayer = api.require('TCSuperPlayer');
        // 设置授权
        this.data.TCSuperPlayer.setLicence({
            licenceURL: 'xxx',
            licenceKey: 'xxxx'
        })
        let userAgent = navigator.userAgent
        if (userAgent.includes('iPhone') || userAgent.includes('iPad')) {
            console.log('苹果手机')
            // 苹果先配置播放器视图再初始化
            this.data.iphoneShow = true
            // 配置播放器视图
            this.data.TCSuperPlayer.configPlayerView({
                rect: {
                    x: 0,
                    y: 0,
                    w: api.winWidth,
                    h: 250
                },
                fixedOn: 'video',
                fixed: true, // 必须是true,否则不能触发全屏
                isShowDanmu: false, // 全屏状态下是否显示弹幕开关按钮,仅Android支持
                isShowSnapshot: false, // 全屏状态下是否显示截屏按钮
                isShowMoreButton: true, // 全屏状态下是否显示更多按钮
                isShowPipBtn: false, // 描述:(可选项)非全屏状态下是否显示画中画按钮,仅支持iOS端
                isShowWindowLayoutTop: true, // 半屏状态下是否显示播放区域顶部导航条
                isShowBackBtn: true, // 半屏状态下是否显示播放区域顶部返回按钮,返回按钮在顶部导航条内的布局中
            });

            // 初始化
            this.data.TCSuperPlayer.initPlayer();

        } else if (userAgent.includes('Android')) {
            console.log('安卓手机')
            this.data.iphoneShow = false
            // 安卓先初始化再配置播放器视图
            // 初始化
            this.data.TCSuperPlayer.initPlayer();
            // 配置播放器视图
            this.data.TCSuperPlayer.configPlayerView({
                rect: {
                    x: 0,
                    y: 0,
                    w: api.winWidth,
                    h: 250
                },
                fixedOn: 'video',
                fixed: true, // 必须是true,否则不能触发全屏
                isShowDanmu: false, // 全屏状态下是否显示弹幕开关按钮,仅Android支持
                isShowSnapshot: false, // 全屏状态下是否显示截屏按钮
                isShowMoreButton: true, // 全屏状态下是否显示更多按钮
                isShowPipBtn: false, // 描述:(可选项)非全屏状态下是否显示画中画按钮,仅支持iOS端
                isShowWindowLayoutTop: true, // 半屏状态下是否显示播放区域顶部导航条
                isShowBackBtn: true, // 半屏状态下是否显示播放区域顶部返回按钮,返回按钮在顶部导航条内的布局中
            });
        }

        // 设置封面图!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        var url = ''
        api.imageCache({
            url: api.pageParam.classlist.course_play_img
        }, function (ret, err) {
            url = ret.url;
        });
        setTimeout(() => {
            if (url != 'undefined' && url != undefined) {
                this.data.TCSuperPlayer.setCoverImage({
                    coverImage: url, // 封面图本地路径
                    thumbnail: false
                })
            }
        }, 500);

        // 关闭小窗(浮动窗)播放模式
        this.data.TCSuperPlayer.closeFenestrulePlay();
        this.data.TCSuperPlayer.addFenestruleListener(function (ret) {
            console.log('小窗:' + JSON.stringify(ret));
        });

        this.data.TCSuperPlayer.addPlayerListener(function (ret) {
            console.log('播放器事件:' + JSON.stringify(ret))

            if (ret.eventType == 'fullScreenChanged') {

                let userAgent = navigator.userAgent
                if (userAgent.includes('Android')) {
                    console.log('安卓手机')
                    this.data.is_full = !this.data.is_full;
                }
                console.log('是否全屏:' + JSON.stringify(this.data.is_full));
                if (this.data.is_full) {
                    api.setScreenOrientation({ orientation: "landscape_left" }); // 设置横屏
                    // 设置进入全屏
                    api.setFullScreen({
                        fullScreen: true
                    });
                    this.data.video_height = api.winWidth; // 把屏幕宽度赋值给视频的高度
                    console.log(this.data.video_height + 'this.data.video_height');
                    this.data.safe_top = 0; // 安全区域设置为0px
                } else {
                    api.setScreenOrientation({ orientation: "portrait_up" }); //竖屏时,屏幕在home键的上面
                    this.data.safe_top = api.safeArea.top; // 设置区域
                    this.data.video_height = 250; // 设置视频高度
                    console.log(this.data.video_height + 'this.data.video_height123');
                }

            } else if (ret.eventType == 'back') { // 触发返回事件
                if (this.data.winHeight == api.winHeight) {
                    // 竖屏,调用返回上一页函数
                    this.back();
                }
            } else if (ret.eventType == 'didStart') { // didStart:播放开始通知
                console.log('播放开始通知');
                if (1 == this.data.is_start_play) {
                    this.data.is_start_play = 0;
                    // 暂停播放
                    this.data.TCSuperPlayer.pausePlayer();
                }
            }

        }.bind(this));
        var that = this
        that.data.TCSuperPlayer.seekToTime({
                toTime: 20
        })
this.data.TCSuperPlayer = api.require('TCSuperPlayer');  定义到他前面,然后里面的所有this换成that
27
帖子
0
勋章
245
Y币
chyd · 2023-8-16 14:34this.data.TCSuperPlayer = api.require('TCSuperPlayer');  定义到他前面,然后里面的所有this换成that

跟this没关系  已经都换成that了还是不行
380
帖子
4
勋章
6
Y币
加油~! · 2023-8-16 18:55跟this没关系  已经都换成that了还是不行

android  还是 iOS?
27
帖子
0
勋章
245
Y币
技术咨询-F · 2023-8-17 09:55android  还是 iOS?

两个都是这样  只不过安卓会动2秒的距离 苹果一点不动
380
帖子
4
勋章
6
Y币
加油~! · 2023-8-17 10:46两个都是这样  只不过安卓会动2秒的距离 苹果一点不动

那是不是你的代码写的有问题啊,可以新建个HTML页面,写几个function ,写几个按钮点击调用,单独测试这个模块看看。
12下一页
您需要登录后才可以回帖 登录

本版积分规则