Commit fb0b06a1 authored by jyx's avatar jyx

代码优化

parent 4439fb98
...@@ -316,8 +316,7 @@ ...@@ -316,8 +316,7 @@
}, },
handleInfo(item) { handleInfo(item) {
// navigateTo(`/pagesC/video/newVideoDetail?data=` + encodeURIComponent(JSON.stringify(item))); // navigateTo(`/pagesC/video/newVideoDetail?data=` + encodeURIComponent(JSON.stringify(item)));
// navigateTo(`/pagesC/ttvideo/ttVideoDetail?data=` + encodeURIComponent(JSON.stringify(item))); navigateTo(`/pagesC/ttvideo/ttVideoDetail?data=` + encodeURIComponent(JSON.stringify(item)));
navigateTo(`/pagesC/test/test`);
}, },
handleTop(item) { handleTop(item) {
// navigateTo(`/pagesC/video/newVideoDetail?data=` + encodeURIComponent(JSON.stringify(item))); // navigateTo(`/pagesC/video/newVideoDetail?data=` + encodeURIComponent(JSON.stringify(item)));
......
...@@ -94,17 +94,6 @@ ...@@ -94,17 +94,6 @@
} }
} }
}, },
{
"path": "test/test",
"style": {
"navigationStyle": "default",
"navigationBarBackgroundColor": "#000000",
"navigationBarTextStyle": "#ffffff",
"usingComponents ": {
"video-player": "ext://industry/video-player"
}
}
},
{ {
"path": "video/newVideoDetail", "path": "video/newVideoDetail",
"style": { "style": {
......
<template>
<view class="content">
<view>
<text class="title">{{ title }}</text>
</view>
<video-player id="myPlayer" class="player-content" :album-id="aid" :episode-id="eid" :cloud-type="type" autoplay
show-playback-rate-btn show-mute-btn enable-play-in-background @play="playHandler" @pause="pauseHandler"
@error="error" @ended="endedHandler" @timeupdate="timeUpdateHandler" @progress="progressHandler"
@fullscreenchange="fullscreenchange" @controlstoggle="controlstoggle" @waiting="waitingHandler"
@loadedmetadata="loadedmetadataHandler" @seekcomplete="seekcomplete"
@playbackratechange="playbackratechange" @mutechange="mutechange" @controltap="controltap"
@enterbackground="enterbackground" @closebackground="closebackground" @getsource="getsource">
</video-player>
<text @click="testPlay">播放</text>
</view>
</template>
<script>
export default {
name: "test",
data() {
return {
title: "uniapp - video-player 组件demo",
aid: "7312718809956090368",
eid: "7312656326428262953",
type: 1,
version: "1",
src: ""
};
},
onLoad() {
console.log('tt.canIUse video-player', uni.canIUse('video-player'))
console.log('tt.canIUse bindleavebackground', uni.canIUse('bindleavebackground'))
},
methods: {
testPlay() {
let videoContext = tt.createVideoContext('myPlayer', this)
videoContext.play();
},
// bindplay
playHandler() {
console.log('bindplay:当开始播放时触发play事件')
},
// bindpause
pauseHandler() {
console.log("bindpause:当暂停播放时触发pause事件")
},
// // bindended todo
endedHandler() {
console.log("bindended:当播放到末尾时触发ended事件")
},
// binderror
error(e) {
console.log("binderror:视频播放出错时触发error事件", e.detail)
},
// bindtimeupdate
timeUpdateHandler(e) {
const {
currentTime,
duration
} = e.detail;
console.log("bindtimeupdate:播放进度变化时触发", "当前播放时间点:" + currentTime, "视频总时长:" + duration)
},
// bindprogress todo
progressHandler(e) {
const {
buffered
} = e.detail;
console.log("bindprogress:视频缓冲进度更新时触发", "当前视频缓冲了" + buffered + "%")
},
//bindfullscreenchange todo
fullscreenchange(e) {
const {
fullScreen,
direction
} = e.detail;
console.log("bindfullscreenchange:视频进入和退出全屏时触发", "fullScreen:" + fullScreen, "全屏时视频的方向:" + direction, )
},
//bindcontrolstoggle todo
controlstoggle(e) {
const {
show
} = e.detail;
console.log("bindcontrolstoggle:切换播放控件显示/隐藏时触发", "show" + show)
},
//bindwaiting todo
waitingHandler() {
console.log("bindwaiting:视频出现缓冲时触发")
},
//bindloadedmetadata todo
loadedmetadataHandler(e) {
const {
width,
height,
duration
} = e.detail;
console.log("bindloadedmetadata:视频元数据加载完成时触发", "width:" + width, "height:" + height, "duration:" +
duration)
},
// bindseekcomplete todo
seekcomplete(e) {
const {
position
} = e.detail;
console.log("bindseekcomplete:seek 完成时触发", "position:" + position)
},
// bindplaybackratechange todo
playbackratechange(e) {
const {
playbackRate
} = e.detail;
console.log("bindplaybackratechange:视频倍速改变完成时触发", "playbackRate:" + playbackRate)
},
// bindmutechange todo
mutechange(e) {
const {
isMuted
} = e.detail;
console.log("bindmutechange:静音状态改变完成时触发", "当前是否静音:" + isMuted)
},
// bindcontroltap todo
controltap(e) {
const {
controlType
} = e.detail;
console.log("bindcontroltap:点击控件时触发", "controlType" + controlType)
},
// bindenterbackground todo
enterbackground() {
console.log("bindenterbackground:进入小窗播放时触发")
},
// bindclosebackground todo
closebackground() {
console.log("bindclosebackground:关闭小窗播放时触发")
},
//bindgetsource
getsource() {
console.log("bindgetsource:获取资源完成后触发")
}
},
};
</script>
<style>
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.title {
font-size: 36rpx;
color: #8f8f94;
}
.player-content {
width: 370px;
height: 300px;
}
</style>
\ No newline at end of file
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<swiper class="swiper" circular @change="swiperChange" :current="current" :vertical="true" :duration="duration"> <swiper class="swiper" circular @change="swiperChange" :current="current" :vertical="true" :duration="duration">
<swiper-item v-for="(list, index) in displaySwiperList" :key="index"> <swiper-item v-for="(list, index) in displaySwiperList" :key="index">
<block> <block>
<video-player v-if="canUseTTPlayer && Math.abs(displayIndex-index)==0" :id="list.vedioIndex" <tt-video-player v-if="canUseTTPlayer && Math.abs(displayIndex-index)==0" :id="list.vedioIndex"
:album-id="list.douyinAlbumId" :episode-id="list.douyinEpisodeId" :cloud-type="1" version="1" :album-id="list.douyinAlbumId" :episode-id="list.douyinEpisodeId" :cloud-type="1" version="1"
object-fit="contain" :controls="controls" :poster="data.coverImage" :loop="!isplay" object-fit="contain" :controls="controls" :poster="data.coverImage" :loop="!isplay"
@getsource="getsource" :enable-progress-gesture="false" :show-loading="true" @getsource="getsource" :enable-progress-gesture="false" :show-loading="true"
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
@ended="ended" @click="tapVides()" @error="error"> @ended="ended" @click="tapVides()" @error="error">
<cover-view>{{list.douyinAlbumId}}</cover-view> <cover-view>{{list.douyinAlbumId}}</cover-view>
<cover-view>{{list.douyinEpisodeId}}</cover-view> <cover-view>{{list.douyinEpisodeId}}</cover-view>
</video-player> </tt-video-player>
<video v-if="!canUseTTPlayer && Math.abs(displayIndex-index)==0" :id="list.vedioIndex" <video v-if="!canUseTTPlayer && Math.abs(displayIndex-index)==0" :id="list.vedioIndex"
@ended="ended" :controls="controls" :loop="!isplay" :enable-progress-gesture="false" @ended="ended" :controls="controls" :loop="!isplay" :enable-progress-gesture="false"
...@@ -83,6 +83,8 @@ ...@@ -83,6 +83,8 @@
import coinPopup from '@/components/coin-popup/coin-popup.vue'; import coinPopup from '@/components/coin-popup/coin-popup.vue';
import episodePopup from '@/components/episode-popup/episode-popup.vue'; import episodePopup from '@/components/episode-popup/episode-popup.vue';
import ttVideoPlayer from '@/ttcomponents/tt-video-player'
import { import {
navigateTo, navigateTo,
} from '@/utils/fun.js'; } from '@/utils/fun.js';
...@@ -95,7 +97,8 @@ ...@@ -95,7 +97,8 @@
mixins: [common], mixins: [common],
components: { components: {
coinPopup, coinPopup,
episodePopup episodePopup,
ttVideoPlayer
}, },
data() { data() {
return { return {
...@@ -138,7 +141,7 @@ ...@@ -138,7 +141,7 @@
}) })
// #ifdef MP-TOUTIAO // #ifdef MP-TOUTIAO
// this.canUseTTPlayer = tt.canIUse('video-player') this.canUseTTPlayer = tt.canIUse('video-player')
if (this.canUseTTPlayer && tt.canIUse('preloadResourceVideo')) { if (this.canUseTTPlayer && tt.canIUse('preloadResourceVideo')) {
this.preloadplaylet() this.preloadplaylet()
} }
...@@ -167,20 +170,15 @@ ...@@ -167,20 +170,15 @@
preloadplaylet() { preloadplaylet() {
// 抖音预加载 // 抖音预加载
tt.preloadResourceVideo({ tt.preloadResourceVideo({
albumId: this.data.albumId, albumId: '7312714531850388019',
episodeId: this.data.episodeId, episodeId: '7312719321847529984',
cloudType: 1, cloudType: 1,
version: 1, version: 1,
success: () => { success: () => {
this.setData({ console.log("短剧预加载成功", );
playletshow: true,
});
}, },
fail: (error) => { fail: (error) => {
console.log("短剧预加载失败", error); console.log("短剧预加载失败", error);
this.setData({
playletshow: true,
});
}, },
}); });
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment