|
@@ -1,13 +1,12 @@
|
|
|
-import { defineComponent, onMounted, onUnmounted, reactive, watch } from 'vue'
|
|
|
+import { defineComponent, onMounted, onUnmounted, reactive, watch, ref } from 'vue'
|
|
|
// import WaveSurfer from 'wavesurfer.js';
|
|
|
import styles from './index.module.less'
|
|
|
import MSticky from '@/components/col-sticky'
|
|
|
import MHeader from '@/components/col-header'
|
|
|
-import { Button, Cell, Dialog, Image, List, Popup, Slider, Toast } from 'vant'
|
|
|
+import { Button, Cell, Dialog, Image, List, Popup, Slider, Toast, Sticky, NoticeBar } from 'vant'
|
|
|
import iconDownload from './images/icon-download.png'
|
|
|
import iconShare from './images/icon-share.png'
|
|
|
import iconDelete from './images/icon-delete.png'
|
|
|
-// import iconMember from './images/icon-member.png'
|
|
|
import iconVip from './images/icon-vip.png'
|
|
|
import iconSVip from './images/icon-svip.png'
|
|
|
import iconZan from './images/icon-zan.png'
|
|
@@ -28,28 +27,34 @@ import dayjs from 'dayjs'
|
|
|
import { nextTick } from 'process'
|
|
|
import MVideo from '@/components/col-video-tcplayer'
|
|
|
import ShareModel from './share-model'
|
|
|
-import { usePageVisibility } from '@vant/use'
|
|
|
+import { usePageVisibility, useEventListener } from '@vant/use'
|
|
|
+import "plyr/dist/plyr.css";
|
|
|
+import Plyr from "plyr";
|
|
|
+import { generateMixedData } from "./audioVisualDraw"
|
|
|
+import backImg from "./images/back.png";
|
|
|
+import back1Img from "./images/back1.png";
|
|
|
+import musicBg from "./images/music_bg.png";
|
|
|
+import videobg from "./images/videobg.png";
|
|
|
+import iconUpward from './images/upward.png';
|
|
|
+import iconEdit from './images/edit.png';
|
|
|
+import iconMember from './images/icon-member.png';
|
|
|
+import TextEllipsis from './text-ellipsis/index';
|
|
|
|
|
|
export default defineComponent({
|
|
|
name: 'creation-detail',
|
|
|
setup() {
|
|
|
+ const {isApp, isTablet} = browser()
|
|
|
const route = useRoute()
|
|
|
const router = useRouter()
|
|
|
- const audioId = 'a' + +Date.now() + Math.floor(Math.random() * 100)
|
|
|
-
|
|
|
+ const isScreenScroll = ref(false)
|
|
|
+ const mStickyBottom = ref()
|
|
|
+ const mStickyUpward = ref()
|
|
|
const state = reactive({
|
|
|
id: route.query.id,
|
|
|
deleteStatus: false,
|
|
|
shareStatus: false,
|
|
|
playType: '' as 'Audio' | 'Video' | '', // 播放类型
|
|
|
musicDetail: {} as any,
|
|
|
- timer: null as any,
|
|
|
- audioWidth: 0,
|
|
|
- paused: true,
|
|
|
- currentTime: 0,
|
|
|
- duration: 0.1,
|
|
|
- loop: false,
|
|
|
- dragStatus: false, // 是否开始拖动
|
|
|
isClick: false,
|
|
|
list: [] as any,
|
|
|
listState: {
|
|
@@ -60,35 +65,30 @@ export default defineComponent({
|
|
|
params: {
|
|
|
page: 1,
|
|
|
rows: 20
|
|
|
- }
|
|
|
- })
|
|
|
- const audioDom = new Audio()
|
|
|
- audioDom.controls = true
|
|
|
- audioDom.style.width = '100%'
|
|
|
- audioDom.className = styles.audio
|
|
|
-
|
|
|
- /** 改变播放时间 */
|
|
|
- const handleChangeTime = (val: number) => {
|
|
|
- state.currentTime = val
|
|
|
- clearTimeout(state.timer)
|
|
|
- state.timer = setTimeout(() => {
|
|
|
- // audioRef.value.currentTime = val;
|
|
|
- audioDom.currentTime = val
|
|
|
- state.timer = null
|
|
|
- }, 60)
|
|
|
- }
|
|
|
-
|
|
|
- // 切换音频播放
|
|
|
- const onToggleAudio = (e: any) => {
|
|
|
- e.stopPropagation()
|
|
|
- if (audioDom.paused) {
|
|
|
- audioDom.play()
|
|
|
- } else {
|
|
|
- audioDom.pause()
|
|
|
- }
|
|
|
+ },
|
|
|
+ _plrl: null as any,
|
|
|
+ heightV:0,
|
|
|
+ heightB:0
|
|
|
+ });
|
|
|
|
|
|
- state.paused = audioDom.paused
|
|
|
- }
|
|
|
+ const plyrState = reactive({
|
|
|
+ duration: 0,
|
|
|
+ currentTime: 0,
|
|
|
+ mediaTimeShow: false,
|
|
|
+ playIngShow: true
|
|
|
+ })
|
|
|
+ // 谱面
|
|
|
+ const staffState = reactive({
|
|
|
+ staffSrc: "",
|
|
|
+ isShow: false,
|
|
|
+ height:"initial",
|
|
|
+ speedRate:1,
|
|
|
+ musicRenderType:"staff",
|
|
|
+ partIndex: 0
|
|
|
+ })
|
|
|
+ const isLandscapeScreen = ref(false)
|
|
|
+ const staffDom= ref<HTMLIFrameElement>()
|
|
|
+ const {playStaff, pauseStaff, updateProgressStaff} = staffMoveInstance()
|
|
|
|
|
|
// 获取列表
|
|
|
const getStarList = async () => {
|
|
@@ -117,87 +117,29 @@ export default defineComponent({
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- const initAudio = () => {
|
|
|
- audioDom.src = state.musicDetail.videoUrl
|
|
|
- audioDom.load()
|
|
|
- audioDom.oncanplaythrough = () => {
|
|
|
- state.paused = audioDom.paused
|
|
|
- state.duration = audioDom.duration
|
|
|
- }
|
|
|
- // 播放时监听
|
|
|
- audioDom.addEventListener('timeupdate', () => {
|
|
|
- state.duration = audioDom.duration
|
|
|
- state.currentTime = audioDom.currentTime
|
|
|
- const rate = (state.currentTime / state.duration) * 100
|
|
|
- state.audioWidth = rate > 100 ? 100 : rate
|
|
|
- })
|
|
|
- audioDom.addEventListener('ended', () => {
|
|
|
- state.paused = audioDom.paused
|
|
|
- })
|
|
|
- // const wavesurfer = WaveSurfer.create({
|
|
|
- // container: document.querySelector(`#${audioId}`) as HTMLElement,
|
|
|
- // waveColor: '#fff',
|
|
|
- // progressColor: '#2FA1FD',
|
|
|
- // url: state.musicDetail.videoUrl,
|
|
|
- // cursorWidth: 0,
|
|
|
- // height: 35,
|
|
|
- // width: 'auto',
|
|
|
- // normalize: true,
|
|
|
- // // Set a bar width
|
|
|
- // barWidth: 2,
|
|
|
- // // Optionally, specify the spacing between bars
|
|
|
- // barGap: 2,
|
|
|
- // // And the bar radius
|
|
|
- // barRadius: 4,
|
|
|
- // barHeight: 0.6,
|
|
|
- // autoScroll: true,
|
|
|
- // /** If autoScroll is enabled, keep the cursor in the center of the waveform during playback */
|
|
|
- // autoCenter: true,
|
|
|
- // hideScrollbar: false,
|
|
|
- // media: audioDom
|
|
|
- // });
|
|
|
-
|
|
|
- // wavesurfer.once('interaction', () => {
|
|
|
- // // wavesurfer.play();
|
|
|
- // });
|
|
|
- // wavesurfer.once('ready', () => {
|
|
|
- // state.paused = audioDom.paused;
|
|
|
- // state.duration = audioDom.duration;
|
|
|
- // });
|
|
|
-
|
|
|
- // wavesurfer.on('finish', () => {
|
|
|
- // state.paused = true;
|
|
|
- // });
|
|
|
-
|
|
|
- // // 播放时监听
|
|
|
- // audioDom.addEventListener('timeupdate', () => {
|
|
|
- // state.currentTime = audioDom.currentTime;
|
|
|
- // });
|
|
|
- }
|
|
|
|
|
|
// 删除作品
|
|
|
const onDelete = async () => {
|
|
|
try {
|
|
|
- await api_userMusicRemove({ id: state.id })
|
|
|
-
|
|
|
+ await api_userMusicRemove({ id: state.id });
|
|
|
setTimeout(() => {
|
|
|
- state.deleteStatus = false
|
|
|
- Toast('删除成功')
|
|
|
- }, 100)
|
|
|
+ state.deleteStatus = false;
|
|
|
+ Toast('删除成功');
|
|
|
+ }, 100);
|
|
|
|
|
|
setTimeout(() => {
|
|
|
- if (browser().isApp) {
|
|
|
+ if (isApp) {
|
|
|
postMessage({
|
|
|
api: 'goBack'
|
|
|
- })
|
|
|
+ });
|
|
|
} else {
|
|
|
- router.back()
|
|
|
+ router.back();
|
|
|
}
|
|
|
- }, 1200)
|
|
|
+ }, 1200);
|
|
|
} catch {
|
|
|
//
|
|
|
}
|
|
|
- }
|
|
|
+ };
|
|
|
|
|
|
// 下载
|
|
|
const onDownload = async () => {
|
|
@@ -206,19 +148,356 @@ export default defineComponent({
|
|
|
content: {
|
|
|
url: state.musicDetail.videoUrl
|
|
|
}
|
|
|
+ });
|
|
|
+ };
|
|
|
+ // 滚动事件
|
|
|
+ const cleanScrollEvent: any = useEventListener('scroll', () => {
|
|
|
+ const height =
|
|
|
+ window.scrollY ||
|
|
|
+ document.documentElement.scrollTop
|
|
|
+ // 防止多次调用
|
|
|
+ if(height > 0 && isScreenScroll.value === false){
|
|
|
+ isScreenScroll.value = true
|
|
|
+ setStatusBarTextColor(false)
|
|
|
+ }
|
|
|
+ if(height <= 0){
|
|
|
+ isScreenScroll.value = false
|
|
|
+ setStatusBarTextColor(true)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // 设置导航栏颜色
|
|
|
+ function setStatusBarTextColor(isWhite:boolean){
|
|
|
+ postMessage({
|
|
|
+ api: 'setStatusBarTextColor',
|
|
|
+ content: { statusBarTextColor: isWhite }
|
|
|
})
|
|
|
}
|
|
|
-
|
|
|
- const pageVisibility = usePageVisibility()
|
|
|
+ const pageVisibility = usePageVisibility();
|
|
|
watch(pageVisibility, value => {
|
|
|
if (value === 'hidden') {
|
|
|
- if (audioDom) {
|
|
|
- audioDom.pause()
|
|
|
- state.paused = audioDom.paused
|
|
|
+ state._plrl?.pause();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // 初始化 媒体播放
|
|
|
+ function initMediaPlay(){
|
|
|
+ const id = state.playType === "Audio" ? "#audioMediaSrc" : "#videoMediaSrc";
|
|
|
+ state._plrl = new Plyr(id, {
|
|
|
+ controls: ["play", "progress", "current-time", "duration"],
|
|
|
+ fullscreen: {
|
|
|
+ enabled: false,
|
|
|
+ fallback: false
|
|
|
}
|
|
|
+ });
|
|
|
+ const player = state._plrl
|
|
|
+ // 创建音波数据
|
|
|
+ if(state.playType === "Audio"){
|
|
|
+ const audioDom = document.querySelector("#audioMediaSrc") as HTMLAudioElement
|
|
|
+ const canvasDom = document.querySelector("#audioVisualizer") as HTMLCanvasElement
|
|
|
+ const { pauseVisualDraw, playVisualDraw } = audioVisualDraw(audioDom, canvasDom)
|
|
|
+ player.on('play', () => {
|
|
|
+ playVisualDraw()
|
|
|
+ });
|
|
|
+ player.on('pause', () => {
|
|
|
+ pauseVisualDraw()
|
|
|
+ });
|
|
|
}
|
|
|
- })
|
|
|
+ // player.on('loadedmetadata', () => {
|
|
|
+ // player.currentTime = playProgressData.playProgress
|
|
|
+ // });
|
|
|
+ player.on("timeupdate", ()=>{
|
|
|
+ plyrState.currentTime = player.currentTime
|
|
|
+ })
|
|
|
+ player.on('play', () => {
|
|
|
+ plyrState.playIngShow = false
|
|
|
+ playStaff()
|
|
|
+ });
|
|
|
+ player.on('pause', () => {
|
|
|
+ plyrState.playIngShow = true
|
|
|
+ pauseStaff()
|
|
|
+ });
|
|
|
+ player.on('ended', () => {
|
|
|
+ player.currentTime = 0
|
|
|
+ if(!player.playing){
|
|
|
+ setTimeout(() => {
|
|
|
+ updateProgressStaff(player.currentTime)
|
|
|
+ }, 100);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // 处理按压事件
|
|
|
+ const handleStart = () => {
|
|
|
+ if(isLandscapeScreen.value){
|
|
|
+ return
|
|
|
+ }
|
|
|
+ plyrState.duration = player.duration
|
|
|
+ plyrState.mediaTimeShow = true
|
|
|
+ };
|
|
|
+ // 处理松开事件
|
|
|
+ const handleEnd = () => {
|
|
|
+ plyrState.mediaTimeShow = false
|
|
|
+ // 暂停的时候调用
|
|
|
+ if(!player.playing){
|
|
|
+ updateProgressStaff(player.currentTime)
|
|
|
+ }
|
|
|
+ };
|
|
|
+ const progressDom = document.querySelector("#playMediaSection .plyr__controls .plyr__progress__container") as HTMLElement
|
|
|
+ progressDom.addEventListener('mousedown', handleStart);
|
|
|
+ progressDom.addEventListener('touchstart', handleStart);
|
|
|
+ progressDom.addEventListener('mouseup', handleEnd);
|
|
|
+ progressDom.addEventListener('touchend', handleEnd);
|
|
|
+ }
|
|
|
+ //点击改变播放状态
|
|
|
+ function handlerClickPlay(event?:MouseEvent){
|
|
|
+ // 原生 播放暂停按钮 点击的时候 不触发
|
|
|
+ // @ts-ignore
|
|
|
+ if(event?.target?.matches('button.plyr__control')){
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (state._plrl.playing) {
|
|
|
+ state._plrl.pause();
|
|
|
+ } else {
|
|
|
+ state._plrl.play();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 音频可视化
|
|
|
+ * @param audioDom
|
|
|
+ * @param canvasDom
|
|
|
+ * @param fftSize 2的幂数,最小为32
|
|
|
+ */
|
|
|
+ function audioVisualDraw(audioDom: HTMLAudioElement, canvasDom: HTMLCanvasElement, fftSize = 128) {
|
|
|
+ type propsType = { canvWidth: number; canvHeight: number; canvFillColor: string; lineColor: string; lineGap: number }
|
|
|
+ // canvas
|
|
|
+ const canvasCtx = canvasDom.getContext("2d")!
|
|
|
+ let { width, height } = canvasDom.getBoundingClientRect()
|
|
|
+ width = Math.ceil(width)
|
|
|
+ height = Math.ceil(height)
|
|
|
+ canvasDom.width = width
|
|
|
+ canvasDom.height = height
|
|
|
+ // audio
|
|
|
+ // let audioCtx : AudioContext | null = null
|
|
|
+ // let analyser : AnalyserNode | null = null
|
|
|
+ // let source : MediaElementAudioSourceNode | null = null
|
|
|
+ // const dataArray = new Uint8Array(fftSize / 2)
|
|
|
+ const draw = (data: Uint8Array, ctx: CanvasRenderingContext2D, { lineGap, canvWidth, canvHeight, canvFillColor, lineColor }: propsType) => {
|
|
|
+ if (!ctx) return
|
|
|
+ const w = canvWidth
|
|
|
+ const h = canvHeight
|
|
|
+ fillCanvasBackground(ctx, w, h, canvFillColor)
|
|
|
+ // 可视化
|
|
|
+ const dataLen = data.length
|
|
|
+ let step = (w / 2 - lineGap * dataLen) / dataLen
|
|
|
+ step < 1 && (step = 1)
|
|
|
+ const midX = w / 2
|
|
|
+ const midY = h / 2
|
|
|
+ let xLeft = midX
|
|
|
+ for (let i = 0; i < dataLen; i++) {
|
|
|
+ const value = data[i]
|
|
|
+ const percent = value / 255 // 最大值为255
|
|
|
+ const barHeight = percent * midY
|
|
|
+ canvasCtx.fillStyle = lineColor
|
|
|
+ // 中间加间隙
|
|
|
+ if (i === 0) {
|
|
|
+ xLeft -= lineGap / 2
|
|
|
+ }
|
|
|
+ canvasCtx.fillRect(xLeft - step, midY - barHeight, step, barHeight)
|
|
|
+ canvasCtx.fillRect(xLeft - step, midY, step, barHeight)
|
|
|
+ xLeft -= step + lineGap
|
|
|
+ }
|
|
|
+ let xRight = midX
|
|
|
+ for (let i = 0; i < dataLen; i++) {
|
|
|
+ const value = data[i]
|
|
|
+ const percent = value / 255 // 最大值为255
|
|
|
+ const barHeight = percent * midY
|
|
|
+ canvasCtx.fillStyle = lineColor
|
|
|
+ if (i === 0) {
|
|
|
+ xRight += lineGap / 2
|
|
|
+ }
|
|
|
+ canvasCtx.fillRect(xRight, midY - barHeight, step, barHeight)
|
|
|
+ canvasCtx.fillRect(xRight, midY, step, barHeight)
|
|
|
+ xRight += step + lineGap
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const fillCanvasBackground = (ctx: CanvasRenderingContext2D, w: number, h: number, colors: string) => {
|
|
|
+ ctx.clearRect(0, 0, w, h)
|
|
|
+ ctx.fillStyle = colors
|
|
|
+ ctx.fillRect(0, 0, w, h)
|
|
|
+ }
|
|
|
+ const requestAnimationFrameFun = () => {
|
|
|
+ // requestAnimationFrame(() => {
|
|
|
+ // //analyser?.getByteFrequencyData(dataArray)
|
|
|
+ // draw(generateMixedData(48), canvasCtx, {
|
|
|
+ // lineGap: 2,
|
|
|
+ // canvWidth: width,
|
|
|
+ // canvHeight: height,
|
|
|
+ // canvFillColor: "transparent",
|
|
|
+ // lineColor: "rgba(255, 255, 255, 0.7)"
|
|
|
+ // })
|
|
|
+ // if (!isPause) {
|
|
|
+ // requestAnimationFrameFun()
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ const _time = setInterval(() => {
|
|
|
+ if (isPause) {
|
|
|
+ clearInterval(_time)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //analyser?.getByteFrequencyData(dataArray)
|
|
|
+ draw(generateMixedData(48), canvasCtx, {
|
|
|
+ lineGap: 2,
|
|
|
+ canvWidth: width,
|
|
|
+ canvHeight: height,
|
|
|
+ canvFillColor: "transparent",
|
|
|
+ lineColor: "rgba(255, 255, 255, 0.7)"
|
|
|
+ })
|
|
|
+ }, 300);
|
|
|
+ }
|
|
|
+ let isPause = true
|
|
|
+ const playVisualDraw = () => {
|
|
|
+ // if (!audioCtx) {
|
|
|
+ // audioCtx = new AudioContext()
|
|
|
+ // source = audioCtx.createMediaElementSource(audioDom)
|
|
|
+ // analyser = audioCtx.createAnalyser()
|
|
|
+ // analyser.fftSize = fftSize
|
|
|
+ // source?.connect(analyser)
|
|
|
+ // analyser.connect(audioCtx.destination)
|
|
|
+ // }
|
|
|
+ //audioCtx.resume() // 重新更新状态 加了暂停和恢复音频音质发生了变化 所以这里取消了
|
|
|
+ isPause = false
|
|
|
+ requestAnimationFrameFun()
|
|
|
+ }
|
|
|
+ const pauseVisualDraw = () => {
|
|
|
+ isPause = true
|
|
|
+ requestAnimationFrame(()=>{
|
|
|
+ canvasCtx.clearRect(0, 0, width, height);
|
|
|
+ })
|
|
|
+ //audioCtx?.suspend() // 暂停 加了暂停和恢复音频音质发生了变化 所以这里取消了
|
|
|
+ // source?.disconnect()
|
|
|
+ // analyser?.disconnect()
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ playVisualDraw,
|
|
|
+ pauseVisualDraw
|
|
|
+ }
|
|
|
+ }
|
|
|
+ function handlerBack(event:any){
|
|
|
+ event.stopPropagation()
|
|
|
+ verticalScreen()
|
|
|
+ }
|
|
|
+ function landscapeScreen(){
|
|
|
+ postMessage({
|
|
|
+ api: "setRequestedOrientation",
|
|
|
+ content: {
|
|
|
+ orientation: 0,
|
|
|
+ },
|
|
|
+ });
|
|
|
+ isLandscapeScreen.value = true
|
|
|
+ }
|
|
|
+ function verticalScreen(){
|
|
|
+ postMessage({
|
|
|
+ api: "setRequestedOrientation",
|
|
|
+ content: {
|
|
|
+ orientation: 1,
|
|
|
+ },
|
|
|
+ });
|
|
|
+ isLandscapeScreen.value = false
|
|
|
+ }
|
|
|
+ function handlerLandscapeScreen(event:any){
|
|
|
+ event.stopPropagation()
|
|
|
+ if(!isLandscapeScreen.value){
|
|
|
+ landscapeScreen()
|
|
|
+ }
|
|
|
+ // playProgressData.playState = !!state._plrl?.playing
|
|
|
+ // playProgressData.playProgress = state._plrl?.currentTime || 0
|
|
|
+ // router.push({
|
|
|
+ // path:"/playCreation",
|
|
|
+ // query:{
|
|
|
+ // resourceUrl:encodeURIComponent(state.musicDetail?.videoUrl),
|
|
|
+ // videoBgUrl:encodeURIComponent(state.musicDetail?.videoImg || ""),
|
|
|
+ // musicSheetName:encodeURIComponent(state.musicDetail?.musicSheetName),
|
|
|
+ // username:encodeURIComponent(state.musicDetail?.username),
|
|
|
+ // musicSheetId:encodeURIComponent(state.musicDetail?.musicSheetId),
|
|
|
+ // speedRate:encodeURIComponent(staffState.speedRate),
|
|
|
+ // musicRenderType:encodeURIComponent(staffState.musicRenderType),
|
|
|
+ // partIndex:encodeURIComponent(staffState.partIndex),
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ }
|
|
|
+ // 初始化五线谱
|
|
|
+ function initStaff(){
|
|
|
+ // const src = `/klx-music-score/#/simple-detail?id=${state.musicDetail.musicSheetId}&musicRenderType=${staffState.musicRenderType}&part-index=${staffState.partIndex}`;
|
|
|
+ const src = `http://192.168.3.68:3000/instrument.html#/simple-detail?id=${state.musicDetail.musicSheetId}&musicRenderType=${staffState.musicRenderType}&part-index=${staffState.partIndex}`;
|
|
|
+ staffState.staffSrc = src
|
|
|
+ window.addEventListener('message', (event) => {
|
|
|
+ const { api, height } = event.data;
|
|
|
+ if (api === 'api_musicPage') {
|
|
|
+ staffState.isShow = true
|
|
|
+ staffState.height = height + "px"
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ function staffMoveInstance(){
|
|
|
+ let isPause = true
|
|
|
+ const requestAnimationFrameFun = () => {
|
|
|
+ requestAnimationFrame(() => {
|
|
|
+ staffDom.value?.contentWindow?.postMessage(
|
|
|
+ {
|
|
|
+ api: 'api_playProgress',
|
|
|
+ content: {
|
|
|
+ currentTime: state._plrl.currentTime * staffState.speedRate
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "*"
|
|
|
+ )
|
|
|
+ if (!isPause) {
|
|
|
+ requestAnimationFrameFun()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ const playStaff = () => {
|
|
|
+ // 没渲染不执行
|
|
|
+ if(!staffState.isShow) return
|
|
|
+ isPause = false
|
|
|
+ staffDom.value?.contentWindow?.postMessage(
|
|
|
+ {
|
|
|
+ api: 'api_play'
|
|
|
+ },
|
|
|
+ "*"
|
|
|
+ )
|
|
|
+ requestAnimationFrameFun()
|
|
|
+ }
|
|
|
+ const pauseStaff = () => {
|
|
|
+ // 没渲染不执行
|
|
|
+ if(!staffState.isShow) return
|
|
|
+ isPause = true
|
|
|
+ staffDom.value?.contentWindow?.postMessage(
|
|
|
+ {
|
|
|
+ api: 'api_paused'
|
|
|
+ },
|
|
|
+ "*"
|
|
|
+ )
|
|
|
+ }
|
|
|
+ const updateProgressStaff = (currentTime: number) => {
|
|
|
+ // 没渲染不执行
|
|
|
+ if(!staffState.isShow) return
|
|
|
+ staffDom.value?.contentWindow?.postMessage(
|
|
|
+ {
|
|
|
+ api: 'api_updateProgress',
|
|
|
+ content: {
|
|
|
+ currentTime: currentTime * staffState.speedRate
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "*"
|
|
|
+ )
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ playStaff,
|
|
|
+ pauseStaff,
|
|
|
+ updateProgressStaff
|
|
|
+ }
|
|
|
+ }
|
|
|
onMounted(async () => {
|
|
|
+ setStatusBarTextColor(true)
|
|
|
try {
|
|
|
const res = await api_userMusicDetail(state.id)
|
|
|
// console.log(res);
|
|
@@ -228,7 +507,7 @@ export default defineComponent({
|
|
|
theme: 'round-button',
|
|
|
confirmButtonColor: '#2DC7AA'
|
|
|
}).then(() => {
|
|
|
- if (browser().isApp) {
|
|
|
+ if (isApp) {
|
|
|
postMessage({
|
|
|
api: 'goBack'
|
|
|
})
|
|
@@ -239,182 +518,194 @@ export default defineComponent({
|
|
|
return
|
|
|
}
|
|
|
state.musicDetail = res.data || {}
|
|
|
+ try{
|
|
|
+ const jsonConfig = JSON.parse(res.data.jsonConfig)
|
|
|
+ jsonConfig.speedRate && (staffState.speedRate = jsonConfig.speedRate)
|
|
|
+ jsonConfig.musicRenderType && (staffState.musicRenderType = jsonConfig.musicRenderType)
|
|
|
+ jsonConfig["part-index"] && (staffState.partIndex = jsonConfig["part-index"])
|
|
|
+ }catch{
|
|
|
+ }
|
|
|
+ // 五线谱
|
|
|
+ initStaff()
|
|
|
getStarList()
|
|
|
// 判断是视频还是音频
|
|
|
if (res.data.videoUrl.lastIndexOf('mp4') !== -1) {
|
|
|
state.playType = 'Video'
|
|
|
} else {
|
|
|
state.playType = 'Audio'
|
|
|
- // 初始化
|
|
|
- nextTick(() => {
|
|
|
- initAudio()
|
|
|
- })
|
|
|
}
|
|
|
+ // 初始化
|
|
|
+ nextTick(() => {
|
|
|
+ initMediaPlay()
|
|
|
+ })
|
|
|
} catch {
|
|
|
//
|
|
|
}
|
|
|
})
|
|
|
|
|
|
onUnmounted(() => {
|
|
|
- if (audioDom) {
|
|
|
- audioDom.pause()
|
|
|
- state.paused = audioDom.paused
|
|
|
- }
|
|
|
+ cleanScrollEvent()
|
|
|
+ state._plrl?.destroy()
|
|
|
})
|
|
|
return () => (
|
|
|
- <div class={styles.creation}>
|
|
|
- <MSticky position="top">
|
|
|
+ <div
|
|
|
+ style={
|
|
|
+ {
|
|
|
+ '--barheight':state.heightV + "px"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ class={[
|
|
|
+ styles.creation,
|
|
|
+ isTablet && styles.creationTablet,
|
|
|
+ isScreenScroll.value && styles.isScreenScroll
|
|
|
+ ]}>
|
|
|
+ <div class={styles.creationBg}></div>
|
|
|
+ <MSticky position="top"
|
|
|
+ onGetHeight={(height: any) => {
|
|
|
+ console.log(height, 'height', height)
|
|
|
+ state.heightV = height
|
|
|
+ }}
|
|
|
+ >
|
|
|
<MHeader
|
|
|
+ color={isScreenScroll.value ? "#333333" : "#ffffff"}
|
|
|
+ background={isScreenScroll.value ? `rgb(255,255,255` : "transparent"}
|
|
|
+ title={state.musicDetail?.musicSheetName}
|
|
|
border={false}
|
|
|
isBack={route.query.platformType != 'ANALYSIS'}
|
|
|
+ onLeftClick={()=>{ setStatusBarTextColor(false) }}
|
|
|
/>
|
|
|
</MSticky>
|
|
|
- <div class={styles.playSection}>
|
|
|
- {state.playType === 'Video' && (
|
|
|
- <MVideo
|
|
|
- src={state.musicDetail?.videoUrl}
|
|
|
- poster={state.musicDetail?.videoImg || videoBg}
|
|
|
- />
|
|
|
- )}
|
|
|
- {state.playType === 'Audio' && (
|
|
|
- <div class={styles.audioSection}>
|
|
|
- <div class={styles.audioContainer}>
|
|
|
- {/* <div
|
|
|
- id={audioId}
|
|
|
- onClick={(e: MouseEvent) => {
|
|
|
- e.stopPropagation();
|
|
|
- }}></div> */}
|
|
|
- <div
|
|
|
- class={styles.waveActive}
|
|
|
- style={{
|
|
|
- width: state.audioWidth + '%'
|
|
|
- }}
|
|
|
- ></div>
|
|
|
- <div class={styles.waveDefault}></div>
|
|
|
- </div>
|
|
|
-
|
|
|
- <div class={styles.audioBox}>
|
|
|
- <div
|
|
|
- class={[styles.audioPan, state.paused && styles.imgRotate]}
|
|
|
- >
|
|
|
- <Image class={styles.audioImg} src={state.musicDetail?.img} />
|
|
|
- </div>
|
|
|
- <i class={styles.audioPoint}></i>
|
|
|
- <i
|
|
|
- class={[styles.audioZhen, state.paused && styles.active]}
|
|
|
- ></i>
|
|
|
- </div>
|
|
|
- <div
|
|
|
- class={[styles.controls]}
|
|
|
- onClick={(e: Event) => {
|
|
|
- e.stopPropagation()
|
|
|
- }}
|
|
|
- onTouchmove={(e: TouchEvent) => {
|
|
|
- // emit('close');
|
|
|
- }}
|
|
|
- >
|
|
|
- <div class={styles.actions}>
|
|
|
- <div class={styles.actionBtn} onClick={onToggleAudio}>
|
|
|
- <img src={state.paused ? iconPlay : iconPause} />
|
|
|
+ <div class={styles.singer}>
|
|
|
+ 演奏:{state.musicDetail?.username}
|
|
|
+ </div>
|
|
|
+ <Sticky zIndex={1000} offsetTop={state.heightV - 1 + "px"}>
|
|
|
+ <div class={[styles.playSection, plyrState.mediaTimeShow && styles.mediaTimeShow, isLandscapeScreen.value&&styles.isLandscapeScreen]} id="playMediaSection" onClick={handlerClickPlay}>
|
|
|
+ {
|
|
|
+ isLandscapeScreen.value &&
|
|
|
+ <div class={styles.backBox}>
|
|
|
+ <img class={[styles.backImg, state.playType === 'Video' && styles.back1Img]} src={state.playType === 'Video' ? back1Img : backImg} onClick={handlerBack}/>
|
|
|
+ <div class={styles.musicDetail}>
|
|
|
+ <div class={styles.musicSheetName}>
|
|
|
+ <NoticeBar
|
|
|
+ text={state.musicDetail?.musicSheetName}
|
|
|
+ background="none"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <div class={styles.username}>演奏:{state.musicDetail?.username}</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div class={[styles.slider]}>
|
|
|
- <Slider
|
|
|
- step={0.01}
|
|
|
- class={styles.timeProgress}
|
|
|
- v-model={state.currentTime}
|
|
|
- max={state.duration}
|
|
|
- onUpdate:modelValue={val => {
|
|
|
- handleChangeTime(val)
|
|
|
- }}
|
|
|
- onDrag-start={() => {
|
|
|
- state.dragStatus = true
|
|
|
- console.log('onDragStart')
|
|
|
- }}
|
|
|
- onDrag-end={() => {
|
|
|
- state.dragStatus = false
|
|
|
- console.log('onDragEnd')
|
|
|
- }}
|
|
|
- />
|
|
|
+ }
|
|
|
+ {
|
|
|
+ state.playType === 'Audio' &&
|
|
|
+ <div class={styles.audioBox}>
|
|
|
+ <canvas class={styles.audioVisualizer} id="audioVisualizer"></canvas>
|
|
|
+ <audio
|
|
|
+ crossorigin="anonymous"
|
|
|
+ id="audioMediaSrc"
|
|
|
+ src={state.musicDetail?.videoUrl}
|
|
|
+ controls="false"
|
|
|
+ preload="metadata"
|
|
|
+ playsinline
|
|
|
+ webkit-playsinline
|
|
|
+ />
|
|
|
+ <img src="./img/ty.png" class={styles.tyBg} />
|
|
|
+ <div class="audioBoxBg">
|
|
|
+ <div class={[styles.audioPan, plyrState.playIngShow && styles.imgRotate]}>
|
|
|
+ <img class={styles.audioImg} src={state.musicDetail.img || musicBg} />
|
|
|
+ </div>
|
|
|
+ <i class={styles.audioPoint}></i>
|
|
|
+ <i class={[styles.audioZhen, plyrState.playIngShow && styles.active]}></i>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ }
|
|
|
+ {
|
|
|
+ state.playType === 'Video' &&
|
|
|
+ <video
|
|
|
+ id="videoMediaSrc"
|
|
|
+ class={styles.videoBox}
|
|
|
+ src={state.musicDetail?.videoUrl}
|
|
|
+ data-poster={ state.musicDetail?.videoImg || videobg}
|
|
|
+ poster={ state.musicDetail?.videoImg || videobg}
|
|
|
+ preload="metadata"
|
|
|
+ playsinline
|
|
|
+ webkit-playsinline
|
|
|
+ x5-playsinline
|
|
|
+ />
|
|
|
+ }
|
|
|
+ <div class={[styles.playLarge, !plyrState.mediaTimeShow && plyrState.playIngShow && styles.playIngShow]}></div>
|
|
|
+ <div class={styles.mediaTimeCon}>
|
|
|
+ <div class={styles.mediaTime}>
|
|
|
+ <div>
|
|
|
+ {getSecondRPM(plyrState.currentTime)}
|
|
|
</div>
|
|
|
- <div class={styles.time}>
|
|
|
- <div>{getSecondRPM(state.currentTime)}</div>
|
|
|
- <span>/</span>
|
|
|
- <div>{getSecondRPM(state.duration)}</div>
|
|
|
+ <div class={styles.note}>/</div>
|
|
|
+ <div class={styles.duration}>
|
|
|
+ {getSecondRPM(plyrState.duration)}
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
- )}
|
|
|
- </div>
|
|
|
-
|
|
|
- <Cell class={styles.userSection} center border={false}>
|
|
|
- {{
|
|
|
- icon: () => (
|
|
|
- <div
|
|
|
- class={[
|
|
|
- styles.userLogoSection,
|
|
|
- (state.musicDetail.vipType === 'SVIP' ||
|
|
|
- state.musicDetail.vipType === 'PERMANENT_SVIP') &&
|
|
|
- styles.userSVip,
|
|
|
- state.musicDetail.vipType === 'VIP' && styles.userVip
|
|
|
- ]}
|
|
|
- >
|
|
|
- <Image class={styles.userLogo} src={state.musicDetail.avatar} />
|
|
|
- <i class={styles.showMemeber}></i>
|
|
|
+ <div class={styles.landscapeScreen} onClick={handlerLandscapeScreen}></div>
|
|
|
+ {/* 谱面 */}
|
|
|
+ {
|
|
|
+ staffState.staffSrc &&
|
|
|
+ <div class={[styles.staffBoxCon, staffState.isShow && styles.staffBoxShow]}>
|
|
|
+ <div
|
|
|
+ class={styles.staffBox}
|
|
|
+ style={
|
|
|
+ {
|
|
|
+ '--staffBoxHeight':staffState.height
|
|
|
+ }
|
|
|
+ }
|
|
|
+ >
|
|
|
+ <div class={styles.mask}></div>
|
|
|
+ <iframe
|
|
|
+ ref={staffDom}
|
|
|
+ class={styles.staff}
|
|
|
+ frameborder="0"
|
|
|
+ src={staffState.staffSrc}>
|
|
|
+ </iframe>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- ),
|
|
|
- title: () => (
|
|
|
- <div class={styles.userInfo}>
|
|
|
- <p class={styles.name}>
|
|
|
- <span>{state.musicDetail?.username}</span>
|
|
|
- {/* {state.musicDetail.vipType === 'VIP' && (
|
|
|
- <img src={iconVip} class={styles.iconMember} />
|
|
|
+ }
|
|
|
+ </div>
|
|
|
+ </Sticky>
|
|
|
+
|
|
|
+ <div class={styles.musicSection}>
|
|
|
+ <div class={styles.avatarInfoBox}>
|
|
|
+ <div class={styles.avatar}>
|
|
|
+ <Image class={styles.userLogo} src={state.musicDetail.avatar} />
|
|
|
+ <div class={styles.infoCon}>
|
|
|
+ <div class={styles.info}>
|
|
|
+ <span class={styles.userName}>{state.musicDetail?.username}</span>
|
|
|
+ {state.musicDetail.vipFlag && (
|
|
|
+ <img src={iconMember} class={styles.iconMember} />
|
|
|
)}
|
|
|
- {(state.musicDetail.vipType === 'SVIP' ||
|
|
|
- state.musicDetail.vipType === 'PERMANENT_SVIP') && (
|
|
|
- <img src={iconSVip} class={styles.iconMember} />
|
|
|
- )} */}
|
|
|
- </p>
|
|
|
- <p class={styles.sub}>
|
|
|
+ </div>
|
|
|
+ <div class={styles.sub}>
|
|
|
{state.musicDetail.subjectName}{' '}
|
|
|
{getGradeCh(state.musicDetail.currentGradeNum - 1)}
|
|
|
- </p>
|
|
|
- </div>
|
|
|
- ),
|
|
|
- value: () => (
|
|
|
- <div class={[styles.zan, styles.zanActive]}>
|
|
|
- <img src={iconZanActive} class={styles.iconZan} />
|
|
|
- {state.musicDetail.likeNum}
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- )
|
|
|
- }}
|
|
|
- </Cell>
|
|
|
-
|
|
|
- <div class={styles.musicSection}>
|
|
|
- <div class={styles.musicName}>
|
|
|
- <span class={styles.musicTag}>曲目名称</span>
|
|
|
- {state.musicDetail?.musicSheetName}
|
|
|
+ </div>
|
|
|
+ <div class={styles.linkes}>
|
|
|
+ <img src={iconZan} class={styles.iconZan} />
|
|
|
+ <span>{state.musicDetail.likeNum}</span>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- {state.musicDetail.desc && (
|
|
|
- <div class={styles.musicDesc}>{state.musicDetail.desc}</div>
|
|
|
- )}
|
|
|
+ <TextEllipsis class={styles.textEllipsis} text={state.musicDetail.desc || ''} />
|
|
|
</div>
|
|
|
-
|
|
|
<div class={styles.likeSection}>
|
|
|
<div class={styles.likeTitle}>点赞记录</div>
|
|
|
-
|
|
|
{state.listState.dataShow ? (
|
|
|
<List
|
|
|
finished={state.listState.finished}
|
|
|
finishedText=" "
|
|
|
- class={[styles.container, styles.containerInformation]}
|
|
|
onLoad={getStarList}
|
|
|
- immediateCheck={false}
|
|
|
- >
|
|
|
+ immediateCheck={false}>
|
|
|
{state.list.map((item: any, index: number) => (
|
|
|
<Cell
|
|
|
- class={styles.likeItem}
|
|
|
- border={state.list.length - 1 == index ? false : true}
|
|
|
+ class={[styles.likeItem, index===state.list.length-1&&styles.likeItemLast]}
|
|
|
+ border={false}
|
|
|
>
|
|
|
{{
|
|
|
icon: () => (
|
|
@@ -439,11 +730,21 @@ export default defineComponent({
|
|
|
))}
|
|
|
</List>
|
|
|
) : (
|
|
|
- <MEmpty btnStatus={false} tips="暂无数据" />
|
|
|
+ <MEmpty class={styles.mEmpty} tips="暂无点赞记录~" btnStatus={false} />
|
|
|
)}
|
|
|
</div>
|
|
|
-
|
|
|
- <MSticky position="bottom">
|
|
|
+ {
|
|
|
+ !isScreenScroll.value &&
|
|
|
+ <MSticky ref={mStickyUpward} position="bottom" offsetBottom={state.heightB - 1 + "px"} >
|
|
|
+ <div class={styles.upward}>
|
|
|
+ <img src={iconUpward} />
|
|
|
+ </div>
|
|
|
+ </MSticky>
|
|
|
+ }
|
|
|
+ <MSticky ref={mStickyBottom} position="bottom" onGetHeight={(height: any) => {
|
|
|
+ console.log(height, 'height', height)
|
|
|
+ state.heightB = height
|
|
|
+ }}>
|
|
|
<div class={styles.bottomSection}>
|
|
|
<div class={styles.bottomShare}>
|
|
|
<p onClick={onDownload}>
|
|
@@ -459,21 +760,17 @@ export default defineComponent({
|
|
|
<span>删除</span>
|
|
|
</p>
|
|
|
</div>
|
|
|
- <Button
|
|
|
- round
|
|
|
+ <img src={iconEdit}
|
|
|
class={styles.btnEdit}
|
|
|
- type="primary"
|
|
|
onClick={() => {
|
|
|
router.push({
|
|
|
path: '/creation-edit',
|
|
|
query: {
|
|
|
id: state.id
|
|
|
}
|
|
|
- })
|
|
|
+ });
|
|
|
}}
|
|
|
- >
|
|
|
- 编辑
|
|
|
- </Button>
|
|
|
+ />
|
|
|
</div>
|
|
|
</MSticky>
|
|
|
|
|
@@ -482,13 +779,14 @@ export default defineComponent({
|
|
|
round
|
|
|
class={styles.popupContainer}
|
|
|
>
|
|
|
- <p class={styles.popupContent}>确定删除吗?</p>
|
|
|
+ <p class={styles.popupTit}>温馨提示</p>
|
|
|
+ <p class={styles.popupContent}>确认删除作品吗?</p>
|
|
|
<div class={styles.popupBtnGroup}>
|
|
|
<Button round onClick={() => (state.deleteStatus = false)}>
|
|
|
取消
|
|
|
</Button>
|
|
|
<Button round type="primary" onClick={onDelete}>
|
|
|
- 确定
|
|
|
+ 确认
|
|
|
</Button>
|
|
|
</div>
|
|
|
</Popup>
|