diff --git a/app.ts b/app.ts index 0c27c94..ad805b8 100644 --- a/app.ts +++ b/app.ts @@ -9,7 +9,7 @@ App({ loginPromise: null, statusBarHeight: 0, canUsePlayletExtension: tt.canIUse('PlayletExtension'), - useVideoByte: true, + useVideoByte: true,//是否使用官方播放器 }, onLaunch() { const loginPromise: any = new Promise((resolve: any) => { diff --git a/components/player/player.ts b/components/player/player.ts index 5010cb4..8f69629 100644 --- a/components/player/player.ts +++ b/components/player/player.ts @@ -17,13 +17,13 @@ Component({ console.log("触发开始播放onPlay回调,时间是:", new Date()); }); pm.onPause((e) => { - console.error('触发暂停播放onPause回调', e) + console.log('触发暂停播放onPause回调', e) }) pm.onEnded((e) => { - console.error('触发播放到末尾onEnded回调', e) + console.log('触发播放到末尾onEnded回调', e) }) pm.onError((e) => { - console.error('触发onError回调', e) + console.log('触发onError回调', e) }) // 播放进度变化时 @@ -47,6 +47,7 @@ Component({ }) pm.onClickUnlock((e) => { + console.log('aaa') this.adOpen() }) @@ -101,5 +102,15 @@ Component({ }) } }, + adOpen() { + let adBanner: any = this.data.adBanner; + tt.showToast({ + title: `广告加载中...`, + icon: 'none', + }); + adBanner.show().then(() => { + // res: any console.log("视频广告展示"); + }); + }, } }) \ No newline at end of file diff --git a/pages/collection/collection.ts b/pages/collection/collection.ts index 04df58f..abf0deb 100644 --- a/pages/collection/collection.ts +++ b/pages/collection/collection.ts @@ -5,7 +5,9 @@ Page({ data: { bookcase: [], bookcaseFlag: false, - bookId: '' + bookId: '', + canUsePlayletExtension: getApp().globalData.canUsePlayletExtension, + useVideoByte: getApp().globalData.useVideoByte, }, onLoad: function () { // options @@ -32,10 +34,19 @@ Page({ toPathVideo(ev: any) { const sid = ev.currentTarget.dataset.sid; const id = ev.currentTarget.dataset.id; - console.log(id, "chapteridchapteridchapterid") + const album_id = ev.currentTarget.dataset.item.album_id; + const episode_id = ev.currentTarget.dataset.item.episode_id; + let url = `/pages/videoDetail/videoDetail?sid=${sid}&id=${id || ''}`; + if(this.data.canUsePlayletExtension&&this.data.useVideoByte){ + url = `/pages/videoByte/videoByte?is_continue=0&tt_album_id=${album_id}&tt_episode_id=${episode_id}&sid=${sid}`; + } + console.log("url",url); tt.navigateTo({ - url: `/pages/videoDetail/videoDetail?sid=${sid}&id=${id || ''}`, + url: url, }); + // tt.navigateTo({ + // url: `/pages/videoDetail/videoDetail?sid=${sid}&id=${id || ''}`, + // }); }, myModalRef(ref: any) { this.myModal = ref diff --git a/pages/collection/collection.ttml b/pages/collection/collection.ttml index c148f8b..fd1a871 100644 --- a/pages/collection/collection.ttml +++ b/pages/collection/collection.ttml @@ -3,7 +3,7 @@ + tt:key="{{item.id}}" data-id="{{item.chapterid}}" data-item="{{item}}" > @@ -26,9 +26,9 @@ - - 继续观看 + + 继续观看 diff --git a/pages/history/history.ts b/pages/history/history.ts index ca61641..ecaf591 100644 --- a/pages/history/history.ts +++ b/pages/history/history.ts @@ -3,7 +3,9 @@ import { httpRequest } from "../../utils/httpReques"; Page({ data: { historyList: [], - historyFlag: false + historyFlag: false, + canUsePlayletExtension: getApp().globalData.canUsePlayletExtension, + useVideoByte: getApp().globalData.useVideoByte, }, onLoad: function () { // options @@ -24,8 +26,18 @@ Page({ toPathVideo(ev: any) { const sid = ev.currentTarget.dataset.sid; const chapterid = ev.currentTarget.dataset.chapterid; + const album_id = ev.currentTarget.dataset.item.album_id; + const episode_id = ev.currentTarget.dataset.item.episode_id; + let url = `/pages/videoDetail/videoDetail?sid=${sid}&id=${chapterid || ''}` + if(this.data.canUsePlayletExtension&&this.data.useVideoByte){ + url = `/pages/videoByte/videoByte?is_continue=0&tt_album_id=${album_id}&tt_episode_id=${episode_id}&sid=${sid}`; + } + console.log("url",url); tt.navigateTo({ - url: `/pages/videoDetail/videoDetail?sid=${sid}&id=${chapterid || ''}`, + url: url, }); + // tt.navigateTo({ + // url: `/pages/videoDetail/videoDetail?sid=${sid}&id=${chapterid || ''}`, + // }); }, }) \ No newline at end of file diff --git a/pages/history/history.ttml b/pages/history/history.ttml index d2be36b..bf059f8 100644 --- a/pages/history/history.ttml +++ b/pages/history/history.ttml @@ -3,7 +3,7 @@ - diff --git a/pages/my/my.ts b/pages/my/my.ts index 07c32d5..61635a1 100644 --- a/pages/my/my.ts +++ b/pages/my/my.ts @@ -6,7 +6,9 @@ Page({ data: { userInfo: {}, platform: '', - historyList: [] + historyList: [], + canUsePlayletExtension: getApp().globalData.canUsePlayletExtension, + useVideoByte: getApp().globalData.useVideoByte, }, onLoad() { tt.getSystemInfo({ @@ -48,9 +50,20 @@ Page({ toPathVideo(ev: any) { const sid = ev.currentTarget.dataset.sid; const chapterid = ev.currentTarget.dataset.chapterid; + const album_id = ev.currentTarget.dataset.item.album_id; + const episode_id = ev.currentTarget.dataset.item.episode_id; + let url = `/pages/videoDetail/videoDetail?sid=${sid}&id=${chapterid || ''}` + if(this.data.canUsePlayletExtension&&this.data.useVideoByte){ + url = `/pages/videoByte/videoByte?is_continue=0&tt_album_id=${album_id}&tt_episode_id=${episode_id}&sid=${sid}`; + } + console.log("url",url); tt.navigateTo({ - url: `/pages/videoDetail/videoDetail?sid=${sid}&id=${chapterid || ''}`, + url: url, }); + // + // tt.navigateTo({ + // url: `/pages/videoDetail/videoDetail?sid=${sid}&id=${chapterid || ''}`, + // }); }, toPathRechargeRecord() { tt.navigateTo({ diff --git a/pages/my/my.ttml b/pages/my/my.ttml index 53a9bfd..8e9e78e 100644 --- a/pages/my/my.ttml +++ b/pages/my/my.ttml @@ -109,7 +109,7 @@ - + diff --git a/pages/search/search.ts b/pages/search/search.ts index 3cccd37..316adda 100644 --- a/pages/search/search.ts +++ b/pages/search/search.ts @@ -5,7 +5,9 @@ Page({ searchValue: '', historySearchList: [], searchList: [], - searchFlag: false + searchFlag: false, + canUsePlayletExtension: getApp().globalData.canUsePlayletExtension, + useVideoByte: getApp().globalData.useVideoByte, }, onLoad: function () { // options @@ -84,8 +86,19 @@ Page({ }, toPathVideo(ev: any) { const sid = ev.currentTarget.dataset.sid; + const chapterid = ev.currentTarget.dataset.chapterid; + const album_id = ev.currentTarget.dataset.item.album_id; + const episode_id = ev.currentTarget.dataset.item.episode_id; + let url = `/pages/videoDetail/videoDetail?sid=${sid}&id=${chapterid || ''}` + if(this.data.canUsePlayletExtension&&this.data.useVideoByte){ + url = `/pages/videoByte/videoByte?is_continue=0&tt_album_id=${album_id}&tt_episode_id=${episode_id}&sid=${sid}`; + } + console.log("url",url); tt.navigateTo({ - url: `/pages/videoDetail/videoDetail?sid=${sid}`, + url: url, }); + // tt.navigateTo({ + // url: `/pages/videoDetail/videoDetail?sid=${sid}`, + // }); }, }) \ No newline at end of file diff --git a/pages/search/search.ttml b/pages/search/search.ttml index 83a595c..f93d3ba 100644 --- a/pages/search/search.ttml +++ b/pages/search/search.ttml @@ -35,7 +35,7 @@ - + diff --git a/pages/theater/theater.ts b/pages/theater/theater.ts index 02dc661..a89d5a1 100644 --- a/pages/theater/theater.ts +++ b/pages/theater/theater.ts @@ -6,7 +6,9 @@ Page({ categoryList: [], categoryid: '', module1: [], - module2: [] + module2: [], + canUsePlayletExtension: getApp().globalData.canUsePlayletExtension, + useVideoByte: getApp().globalData.useVideoByte, }, onLoad() { // options @@ -57,8 +59,18 @@ Page({ }, toPathVideo(ev: any) { const sid = ev.currentTarget.dataset.sid; + const album_id = ev.currentTarget.dataset.item.album_id; + const episode_id = ev.currentTarget.dataset.item.episode_id; + let url = `/pages/videoDetail/videoDetail?sid=${sid}`; + if(this.data.canUsePlayletExtension&&this.data.useVideoByte){ + url = `/pages/videoByte/videoByte?is_continue=0&tt_album_id=${album_id}&tt_episode_id=${episode_id}&sid=${sid}`; + } + console.log("url",url); tt.navigateTo({ - url: `/pages/videoDetail/videoDetail?sid=${sid}`, + url: url, }); + // tt.navigateTo({ + // url: `/pages/videoDetail/videoDetail?sid=${sid}`, + // }); }, }) \ No newline at end of file diff --git a/pages/theater/theater.ttml b/pages/theater/theater.ttml index 371531a..15d3dd5 100644 --- a/pages/theater/theater.ttml +++ b/pages/theater/theater.ttml @@ -36,7 +36,7 @@ - + @@ -83,7 +83,7 @@ + catchtap="toPathVideo" data-item="{{item}}" > diff --git a/pages/videoByte/videoByte.ts b/pages/videoByte/videoByte.ts index f712b33..9104c3d 100644 --- a/pages/videoByte/videoByte.ts +++ b/pages/videoByte/videoByte.ts @@ -12,6 +12,7 @@ PlayletExtension({ options: undefined, data: { watchInfo: null, + nextbatchList: [], }, methods: { emitInfoFromChildren(val,data) { @@ -91,7 +92,7 @@ PlayletExtension({ }); this.init(); - + // this.getNext(); }, async init(status?:string,data?:any) { console.log("data",data) @@ -123,8 +124,26 @@ PlayletExtension({ this.setData({ watchInfo: _watchinfo }) + }, + async getNext(){ + // let params = { + // ...this.options, + // album_id: !!data ? data.album_id : this.options.tt_album_id, + // episode_id: !!data ? data.episode_id : this.options.tt_episode_id, + // sid: null, + // id: null, + // tt_album_id: null, + // tt_episode_id: null, + // } + let nextbatchList = []; + const nextbatchRes: any = await httpRequest('/nextbatch', 'POST', this.options); + if (nextbatchRes.status == 1 && Array.isArray(nextbatchRes.data)) { + nextbatchList = nextbatchRes.data; + } + this.setData({ + nextbatchList + }) } - }, lifetimes: { diff --git a/pages/videoByte/videoByte.ttml b/pages/videoByte/videoByte.ttml index e69de29..ee4b5e1 100644 --- a/pages/videoByte/videoByte.ttml +++ b/pages/videoByte/videoByte.ttml @@ -0,0 +1,37 @@ + + + + + + + + + + 本剧已结束 + + + + 更多推荐 + 换一换 + + + + + + + + + + {{item.name}} + + + + + + + + + + \ No newline at end of file diff --git a/pages/videoDetail/videoDetail.ts b/pages/videoDetail/videoDetail.ts index 2724782..293e8c3 100644 --- a/pages/videoDetail/videoDetail.ts +++ b/pages/videoDetail/videoDetail.ts @@ -23,9 +23,11 @@ Page({ nextbatchList: [], selectedId: '', unlockFlag: true, - adBanner: null + adBanner: null, + canUsePlayletExtension: getApp().globalData.canUsePlayletExtension, + useVideoByte: getApp().globalData.useVideoByte, }, - onLoad(options: any) { + async onLoad(options: any) { const videoCanIUse = tt.canIUse('video-player'); tt.getSystemInfo({ success: (res: any) => { @@ -40,11 +42,75 @@ Page({ sid: options?.sid || '' }) const params = { - ...options + ...options, + album_id: options?.tt_album_id, + episode_id: options?.tt_episode_id, } - this.initFn(params); - this.adInit() + // 1:查询状态,下架了就拦截 + // let nextbatchList = []; + // const nextbatchRes: any = await httpRequest('/nextbatch', 'POST', params); + // if (nextbatchRes?.status == 1 && Array.isArray(nextbatchRes?.data)) { + // nextbatchList = nextbatchRes.data; + // this.setData({ + // nextbatchList, + // }) + // }else{ + // //1:新播放器 + // if(this.data.canUsePlayletExtension&&this.data.useVideoByte){ + // tt.navigateTo({ + // url: `/pages/videoByte/videoByte?is_continue=0&tt_album_id=${params.album_id}&tt_episode_id=${params.episode_id}` + // }); + // }else{ + // //2: 本页 + // this.initFn(params); + // this.adInit() + // } + // } + + //查询状态 + // let checkstatus: any = await httpRequest('/skitslibrarystate', 'POST', params); + // console.log(checkstatus) + // if (checkstatus.data.status != 1) { //下架了拉推荐 + // let nextbatchList = []; + // const nextbatchRes: any = await httpRequest('/nextbatch', 'POST', params); + // if (nextbatchRes?.status == 1 && Array.isArray(nextbatchRes?.data)) { + // nextbatchList = nextbatchRes.data; + // this.setData({ + // nextbatchList, + // }) + // } + // return + // }else{ + // //1:新播放器 + // if(this.data.canUsePlayletExtension&&this.data.useVideoByte){ + // tt.navigateTo({ + // url: `/pages/videoByte/videoByte?is_continue=0&tt_album_id=${params.album_id}&tt_episode_id=${params.episode_id}` + // }); + // return + // }else{ + // //2: 本页 + // this.initFn(params); + // this.adInit() + // } + // } + // this.initFn(params); + // this.adInit() + + //1:新播放器 + if(this.data.canUsePlayletExtension&&this.data.useVideoByte){ + let urlstr = this.objectToQueryString(params) + tt.redirectTo({ + url: `/pages/videoByte/videoByte?is_continue=0&${urlstr}` + }); + return + }else{ + //2: 本页 + this.initFn(params); + this.adInit() + } + + }, onShow() { }, async initFn(params: any) { @@ -492,7 +558,17 @@ Page({ sid } }) - this.initFn(params); + const album_id = ev.currentTarget.dataset.item.album_id; + const episode_id = ev.currentTarget.dataset.item.episode_id; + //1:新播放器 + if(this.data.canUsePlayletExtension&&this.data.useVideoByte){ + tt.redirectTo({ + url: `/pages/videoByte/videoByte?is_continue=0&tt_album_id=${album_id}&tt_episode_id=${episode_id||''}` + }); + }else{ + //2: 页面刷新 + this.initFn(params); + } }, async handelReplace() { const sid = this.data.sid; @@ -565,4 +641,17 @@ Page({ const context: any = tt.createVideoContext(`${videoInfo.id}`); context?.play?.(); }, + + objectToQueryString(obj) { + return Object.keys(obj).map(key => { + let value = obj[key]; + // 处理数组情况 + if (Array.isArray(value)) { + value = value.map(v => encodeURIComponent(v)).join(','); + } else { + value = encodeURIComponent(value); + } + return `${encodeURIComponent(key)}=${value}`; + }).join('&'); + } }) \ No newline at end of file diff --git a/pages/videoDetail/videoDetail.ttml b/pages/videoDetail/videoDetail.ttml index 1f34824..6084d04 100644 --- a/pages/videoDetail/videoDetail.ttml +++ b/pages/videoDetail/videoDetail.ttml @@ -177,12 +177,12 @@ 更多推荐 - 换一换 + 换一换 + catchtap="toPathVideoitself" data-item="{{item}}">