evaluating.tsx 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677
  1. import { Button, Toast } from 'vant'
  2. import { defineComponent, onBeforeUnmount, onMounted, Ref, ref, Teleport, Transition } from 'vue'
  3. import '@dotlottie/player-component'
  4. import detailState from '/src/pages/detail/state'
  5. import SettingState from '/src/pages/detail/setting-state'
  6. import {
  7. IPostMessage,
  8. listenerMessage,
  9. postMessage,
  10. promisefiyPostMessage,
  11. removeListenerMessage,
  12. CallBack
  13. } from '/src/helpers/native-message'
  14. import { browser } from '/src/helpers/utils'
  15. import runtime, * as RuntimeUtils from '/src/pages/detail/runtime'
  16. import { getBoundingBoxByverticalNote, getNoteByMeasuresSlursStart, getParentNote } from '/src/pages/detail/helpers'
  17. import { handleCheckEvaluatStatus, useClientType, useOriginSearch } from '../uses'
  18. import { startButtonShow } from './index'
  19. import { getLeveByScoreMeasure } from '/src/pages/detail/evaluating/helper'
  20. import Evaluating, { evaluatingShow } from '../popups/evaluating'
  21. // @ts-ignore
  22. import styles from './index.module.less'
  23. import { Vue3Lottie } from 'vue3-lottie'
  24. import startData from './data/start.json'
  25. import startingData from './data/starting.json'
  26. import { unitTestData } from '../unitTest'
  27. import iconEvaluatingStart from './icons/icon-evaluatingStart.png'
  28. /**
  29. * 节拍器时长
  30. * 评测模式时,应该传节拍器时长
  31. * 阶段评测时,判断是否从第一小节开始,并且曲子本身含有节拍器,需要传节拍器时长,否则传0
  32. */
  33. let actualBeatLength = 0
  34. let backtime = 0
  35. const initBehaviorId = '' + new Date().valueOf()
  36. const evaluating = ref(false)
  37. const playStatus: Ref<'connecting' | 'play' | 'stop'> = ref('stop')
  38. const endloading = ref(false)
  39. const connentLoading = ref(false)
  40. const playUrl: Ref<string> = ref('')
  41. const endResult = ref(null)
  42. const browserInfo = browser()
  43. const scoreList: any[] = []
  44. /**
  45. * 默认按照442计算的音符频率,此处转化为按照设置进行调整
  46. * @param num 频率
  47. * @returns 转化后频率
  48. */
  49. const formatPitch = (num?: number): number => {
  50. if (!num) {
  51. return -1
  52. }
  53. if (SettingState.sett.hertz && SettingState.sett.hertz !== 442) {
  54. return (num / 442) * SettingState.sett.hertz
  55. }
  56. return num
  57. }
  58. let starTime = 0
  59. const formatTimes = () => {
  60. const rate = runtime.speed / detailState.baseSpeed //1
  61. actualBeatLength = Math.round(detailState.times[0].fixtime * 1000 / rate)
  62. const difftime = detailState.times?.[0]?.difftime || 0
  63. let ListenMode = false
  64. let dontEvaluatingMode = false
  65. let skip = false
  66. const datas = []
  67. let times = detailState.times
  68. // 阶段评测前一个节拍的标示
  69. let preLyricsContent = ''
  70. let preTimes = []
  71. if (unitTestData.isSelectMeasureMode) {
  72. const startIndex = detailState.times.findIndex(
  73. (n: any) => n.NoteToGraphicalNoteObjectId == detailState.section[0].NoteToGraphicalNoteObjectId
  74. )
  75. const endIndex = detailState.times.findIndex(
  76. (n: any) => n.NoteToGraphicalNoteObjectId == detailState.section[1].NoteToGraphicalNoteObjectId
  77. )
  78. times = detailState.times.filter((n: any, index: number) => {
  79. return index >= startIndex && index <= endIndex
  80. })
  81. preTimes = detailState.times.filter((n: any, index: number) => {
  82. return index < startIndex
  83. })
  84. starTime = times[0].sourceRelativeTime || times[0].relativeTime
  85. actualBeatLength = startIndex == 0 && !detailState.needTick ? actualBeatLength : 0
  86. // console.log("🚀 ~ times", times, '开始小节', startIndex, actualBeatLength)
  87. }
  88. // 找到阶段评测,开始小节前面最近的是play或者listen的小节
  89. if (preTimes.length) {
  90. for (let index = preTimes.length-1; index >= 0; index--) {
  91. const item = preTimes[index]
  92. const note = getNoteByMeasuresSlursStart(item)
  93. if (note.formatLyricsEntries.contains('Play') || note.formatLyricsEntries.contains('Play...')) {
  94. preLyricsContent = 'Play'
  95. break
  96. }
  97. if (note.formatLyricsEntries.contains('Listen')) {
  98. preLyricsContent = 'Listen'
  99. break
  100. }
  101. }
  102. preLyricsContent = preLyricsContent ? preLyricsContent : 'Play'
  103. }
  104. let measureIndex = -1
  105. let recordMeasure = -1
  106. for (let index = 0; index < times.length; index++) {
  107. const item = times[index]
  108. const note = getNoteByMeasuresSlursStart(item)
  109. const rate = runtime.speed / detailState.baseSpeed //1
  110. const start = difftime + (item.sourceRelativeTime || item.relativeTime) - starTime
  111. const end = difftime + (item.sourceRelaEndtime || item.relaEndtime) - starTime
  112. // console.log(start, end, starTime)
  113. const isStaccato =
  114. typeof note.voiceEntry.isStaccato === 'function' ? note.voiceEntry.isStaccato() : note.voiceEntry.isStaccato
  115. const noteRate = isStaccato ? 0.5 : 1
  116. // console.log('注脚', note.formatLyricsEntries)
  117. // 如果阶段评测,开始小节没有注脚,则取前面最近的小节的注脚
  118. if (index == 0 && !note.formatLyricsEntries.length) {
  119. ListenMode = preLyricsContent === 'Play' ? false : preLyricsContent === 'Listen' ? true : false
  120. }
  121. if (note.formatLyricsEntries.contains('Play') || note.formatLyricsEntries.contains('Play...')) {
  122. ListenMode = false
  123. }
  124. if (note.formatLyricsEntries.contains('Listen')) {
  125. ListenMode = true
  126. }
  127. if (note.formatLyricsEntries.contains('纯律结束')) {
  128. dontEvaluatingMode = false
  129. }
  130. if (note.formatLyricsEntries.contains('纯律')) {
  131. dontEvaluatingMode = true
  132. }
  133. const nextNote = detailState.times[index + 1]
  134. if (skip && (note.stave || !note.noteElement.isRestFlag || (nextNote && !nextNote.noteElement.isRestFlag))) {
  135. skip = false
  136. }
  137. if (note.noteElement.isRestFlag && !!note.stave && !!nextNote && nextNote.noteElement.isRestFlag) {
  138. skip = true
  139. }
  140. if (note.measureOpenIndex != recordMeasure) {
  141. measureIndex++
  142. recordMeasure = note.measureOpenIndex
  143. }
  144. // console.log(note.measureOpenIndex , measureIndex, note.noteElement.sourceMeasure.measureListIndex)
  145. const data = {
  146. timeStamp: (start * 1000) / rate,
  147. duration: ((end * 1000) / rate - (start * 1000) / rate) * noteRate,
  148. frequency: formatPitch(item.noteElement?.pitch?.frequency),
  149. nextFrequency: formatPitch(item.noteElement?.pitch?.nextFrequency),
  150. prevFrequency: formatPitch(item.noteElement?.pitch?.prevFrequency),
  151. measureIndex: measureIndex, //note.measureOpenIndex,
  152. measureRenderIndex: note.noteElement.sourceMeasure.measureListIndex,
  153. dontEvaluating: ListenMode || dontEvaluatingMode || item.skipMode,
  154. musicalNotesIndex: index, //item.i,
  155. denominator: note.noteElement?.Length.denominator,
  156. isOrnament: !!note?.voiceEntry?.ornamentContainer,
  157. }
  158. datas.push(data)
  159. }
  160. return datas
  161. }
  162. const connect = async () => {
  163. const search = useOriginSearch()
  164. connentLoading.value = true
  165. const behaviorId = sessionStorage.getItem('behaviorId') || search.behaviorId || initBehaviorId
  166. const rate = runtime.speed / detailState.baseSpeed //1
  167. const content = {
  168. musicXmlInfos: formatTimes(),
  169. subjectId: detailState.subjectId,
  170. detailId: detailState.activeDetail?.id,
  171. examSongId: search.id,
  172. xmlUrl: detailState?.activeDetail?.xmlUrl,
  173. partIndex: detailState.partIndex,
  174. behaviorId,
  175. platform: 'WEB',
  176. clientId: 'STUDENT',
  177. hertz: SettingState.sett.hertz,
  178. feature: 'EVALUATION',
  179. practiceSource: search.unitId ? 'UNIT_TEST' : 'PRACTICE',
  180. // 这里定义的是数字但是因为是通过input输入所以强制转化一次
  181. reactionTimeMs: parseFloat('' + SettingState.eva.reactionTimeMs) || 0,
  182. speed: runtime.speed,
  183. heardLevel: SettingState.eva.difficulty,
  184. // beatLength: Math.round((RuntimeUtils.getFixTime(detailState.times[0].beatSpeed) * 1000) / rate),
  185. beatLength: actualBeatLength,
  186. }
  187. // console.log("🚀 ~ content:", content, rate)
  188. const clientType = useClientType()
  189. if (clientType === 'student') {
  190. content.clientId = 'STUDENT'
  191. } else if (clientType === 'teacher') {
  192. content.clientId = 'TEACHER'
  193. } else {
  194. content.clientId = 'BACKEND'
  195. }
  196. if (browserInfo.android) {
  197. content.platform = 'ANDROID'
  198. }
  199. if (browserInfo.ios) {
  200. content.platform = 'IOS'
  201. }
  202. const evt = await promisefiyPostMessage({
  203. api: 'startEvaluating',
  204. content: content,
  205. })
  206. if (evt?.content?.reson) {
  207. Toast.fail({
  208. message: evt?.content?.reson,
  209. })
  210. connentLoading.value = false
  211. throw evt
  212. }
  213. connentLoading.value = false
  214. }
  215. const sendOffsetTime = (offsetTime: number) => {
  216. postMessage(
  217. {
  218. api: 'proxyServiceMessage',
  219. content: {
  220. header: {
  221. commond: 'audioPlayStart',
  222. type: 'SOUND_COMPARE',
  223. },
  224. body: {
  225. offsetTime,
  226. },
  227. },
  228. },
  229. () => {
  230. backtime = 0
  231. }
  232. )
  233. }
  234. const cancelTheEvaluation = () => {
  235. const search = useOriginSearch()
  236. postMessage({ api: 'endEvaluating', content: { musicScoreId: search.id } })
  237. playStatus.value = 'stop'
  238. RuntimeUtils.pause()
  239. RuntimeUtils.resetPlayStatus()
  240. RuntimeUtils.clearIntervalTimeline()
  241. RuntimeUtils.setCurrentTime(0)
  242. Toast.clear()
  243. }
  244. const stopPlay = () => {
  245. console.log('调用stopPlay')
  246. if (!connentLoading.value) {
  247. cancelTheEvaluation()
  248. }
  249. startButtonShow.value = true
  250. connentLoading.value = false
  251. evaluating.value = false
  252. }
  253. export const evaluatStopPlay = stopPlay
  254. const startPlay = () => {
  255. console.log('连接服务成功,开始播放', new Date().getTime() - runtime.clickTime)
  256. if (!SettingState.eva.mute) {
  257. RuntimeUtils.changeAllMode()
  258. } else {
  259. RuntimeUtils.changeMode('background')
  260. }
  261. startButtonShow.value = false
  262. RuntimeUtils.setPlayState()
  263. }
  264. const setPlayer = async () => {
  265. // 连接中,禁止重复连接
  266. if (connentLoading.value) return
  267. runtime.clickTime = new Date().getTime()
  268. RuntimeUtils.resetPlayStatus()
  269. if (detailState.isPauseRecording) {
  270. evaluating.value = false
  271. startPlay()
  272. return
  273. }
  274. detailState.evaluatings = {}
  275. const hint = Toast({
  276. duration: 0,
  277. message: '服务连接中...',
  278. type: 'loading',
  279. })
  280. try {
  281. await connect()
  282. startPlay()
  283. setTimeout(() => {
  284. console.log('关闭弹窗')
  285. Toast.clear()
  286. hint.close()
  287. }, 100)
  288. } catch (error) {
  289. runtime.evaluatingStatus = false
  290. Toast.clear()
  291. }
  292. }
  293. const togglePlay = () => {
  294. if (detailState.isPauseRecording) {
  295. evaluating.value = false
  296. startPlay()
  297. return
  298. }
  299. if (evaluating.value) {
  300. stopPlay()
  301. } else {
  302. setPlayer()
  303. }
  304. }
  305. const timeupdate = () => {
  306. console.log('播放事件被触发', playUrl.value, evaluating.value)
  307. if (playUrl.value) {
  308. const nowTime = new Date().getTime()
  309. // console.log('播放开始的时间', nowTime)
  310. // synced = true
  311. let time = runtime.audiosInstance?.audios[playUrl.value].currentTime
  312. // 只有选段模式,并且开始小节非第一小节时,才执行以下计算
  313. const sectionIdx = detailState.section.length ? detailState.section[0].i : 0
  314. if (unitTestData.isSelectMeasureMode && sectionIdx > 0 ) {
  315. time = time - detailState.section[0].time
  316. }
  317. console.log('已播放时长: ', time * 1000)
  318. console.log('不减掉已播放时间: ', nowTime - backtime)
  319. const delayTime = nowTime - backtime - time * 1000
  320. console.log('真正播放延迟', delayTime, time, unitTestData.isSelectMeasureMode, sectionIdx)
  321. // 蓝牙耳机延迟一点发送消息确保在录音后面
  322. setTimeout(() => {
  323. sendOffsetTime(delayTime)
  324. }, 220)
  325. }
  326. }
  327. /**
  328. * 播放器停止事件
  329. */
  330. const playerStop = () => {
  331. // alert('stop' + this.endloading)
  332. console.log('playerStop播放器停止事件', endloading.value)
  333. if (endloading.value) {
  334. return
  335. }
  336. playStatus.value = 'stop'
  337. endloading.value = true
  338. startButtonShow.value = true
  339. RuntimeUtils.resetPlayStatus()
  340. RuntimeUtils.clearIntervalTimeline()
  341. RuntimeUtils.setCurrentTime(0)
  342. Toast({
  343. duration: 0,
  344. message: '评分中...',
  345. type: 'loading',
  346. })
  347. postMessage(
  348. {
  349. api: 'endEvaluating',
  350. content: {
  351. musicScoreId: useOriginSearch().id,
  352. },
  353. },
  354. (evt) => {
  355. console.log('调用endEvaluating结束', evt)
  356. endloading.value = false
  357. evaluating.value = false
  358. // RuntimeUtils.setCaptureMode()
  359. }
  360. )
  361. RuntimeUtils.endCapture()
  362. }
  363. export const evaluatPlayerStop = playerStop
  364. const endevent = (evt: Event) => {
  365. // 如果是单元测验和课后训练 播放结束
  366. if (unitTestData.isSelectMeasureMode && playStatus.value === 'play') {
  367. playerStop()
  368. canSubmit.value = true
  369. return
  370. }
  371. if ((evt.target as HTMLAudioElement)?.src === playUrl.value && playStatus.value === 'play') {
  372. playerStop()
  373. canSubmit.value = true
  374. }
  375. if (detailState.isAppPlay) {
  376. playerStop()
  377. canSubmit.value = true
  378. }
  379. }
  380. /**正式开始评测 */
  381. const evaluatStart = () => {
  382. playStatus.value = 'play'
  383. if (detailState.isPauseRecording) {
  384. postMessage(
  385. {
  386. api: 'resumeRecording',
  387. },
  388. () => {
  389. evaluating.value = true
  390. detailState.isPauseRecording = false
  391. RuntimeUtils.setCaptureMode()
  392. }
  393. )
  394. return
  395. } else {
  396. RuntimeUtils.setCaptureMode()
  397. }
  398. console.log('开始录音', new Date().getTime())
  399. postMessage(
  400. {
  401. api: 'startRecording',
  402. },
  403. () => {
  404. // console.log('开始录音app回调时间', Date.now())
  405. backtime = Date.now()
  406. evaluating.value = true
  407. if (detailState.activeDetail?.midiUrl) {
  408. console.log('midiUrl', detailState.activeDetail?.midiUrl)
  409. setTimeout(() => {
  410. sendOffsetTime(0)
  411. }, 220)
  412. }
  413. }
  414. )
  415. RuntimeUtils.startCapture()
  416. }
  417. /**
  418. * 酷乐秀活动接口,Url中有设置并且仅在学生端提评分交数据
  419. * 管乐团单元测验, url中有单元测验ID仅在学生端提评分交数据
  420. */
  421. const submitEvaluationScore = async (data: any) => {
  422. const search = useOriginSearch()
  423. if (search.unitId) {
  424. if (!canSubmit.value) {
  425. Toast('完整演奏结束才算测验分数!')
  426. return
  427. }
  428. (endResult.value as any)?.score && scoreList.push((endResult.value as any)?.score)
  429. /** 有单元测验时,存储分数缓存 */
  430. postMessage({
  431. api: 'setCache',
  432. content: {
  433. key: 'h5-orchestra-unit',
  434. value: JSON.stringify({
  435. musicId: search.id || '',
  436. unitId: search.unitId || '',
  437. questionId: search.questionId || '',
  438. score: canSubmit.value ? (endResult.value as any)?.score || 0 : 0,
  439. }),
  440. },
  441. })
  442. canSubmit.value = false
  443. }
  444. }
  445. /** 活动使用,只有在全部评测完成后才能提交,避免只是一小节就高分的情况 */
  446. const canSubmit = ref(false)
  447. /**接受websocket返回的信息 */
  448. const sendResult = (evt?: IPostMessage) => {
  449. const { body, header } = evt?.content || {}
  450. console.log('评测返回', body)
  451. if (body && header) {
  452. const data = evt?.content?.body
  453. if (evt?.content.header.commond === 'overall') {
  454. // console.log(evt)
  455. detailState.isHideEvaluatReportSaveBtn = false;
  456. Toast.clear()
  457. endResult.value = data
  458. evaluatingShow.value = true
  459. submitEvaluationScore(data)
  460. } else if (evt?.content.header.commond === 'checkDone') {
  461. // 此处已经在校音中单独监听不做处理
  462. } else if (evt?.content.header.commond === 'checking') {
  463. // 此处已经在校音中单独监听不做处理
  464. } else {
  465. const getBeforeNote = (index: number) => {
  466. while (index >= 0) {
  467. const item = detailState.times[index]
  468. if (item.stave) {
  469. return item
  470. }
  471. index--
  472. }
  473. }
  474. const setEvaluatings = (note: any, data: any, dontTransition = false) => {
  475. const startNote = getBoundingBoxByverticalNote(note)
  476. // console.log(detailState.evaluatings, startNote)
  477. detailState.evaluatings = {
  478. ...detailState.evaluatings,
  479. [startNote.measureIndex]: {
  480. ...startNote,
  481. ...getLeveByScoreMeasure(data.score),
  482. score: data.score,
  483. dontTransition,
  484. },
  485. }
  486. }
  487. for (let index = 0; index < detailState.times.length; index++) {
  488. let time = detailState.times[index]
  489. if (data.measureRenderIndex == time.noteElement.sourceMeasure.measureListIndex) {
  490. if (!time.stave) {
  491. const ntime = getBeforeNote(index)
  492. // console.log('ntime', ntime)
  493. if (ntime) {
  494. time = ntime
  495. }
  496. }
  497. if (!time.noteElement.tie) {
  498. setEvaluatings(time, data)
  499. } else {
  500. for (const item of time.noteElement.tie.notes) {
  501. const note = getParentNote(item)
  502. if (!note) continue
  503. setEvaluatings(
  504. note,
  505. data,
  506. item.NoteToGraphicalNoteObjectId !== time.noteElement.tie.StartNote?.NoteToGraphicalNoteObjectId
  507. )
  508. }
  509. }
  510. break
  511. }
  512. }
  513. }
  514. }
  515. }
  516. const onProgress = () => {
  517. // console.log(runtime.currentTimeNum, detailState.times[detailState.times.length - 1]?.time - 2, detailState.times)
  518. if (runtime.currentTimeNum >= detailState.times[detailState.times.length - 1]?.time - 2) {
  519. canSubmit.value = true
  520. }
  521. }
  522. const cloudMetronome = (evt: any) => {
  523. startButtonShow.value = true
  524. }
  525. /** 监听评测弹窗是否隐藏保存演奏按钮 */
  526. const hideComplexButton = (callback: CallBack, listen?: boolean) => {
  527. if (listen) {
  528. listenerMessage("hideComplexButton", callback);
  529. } else {
  530. removeListenerMessage("hideComplexButton", callback);
  531. }
  532. };
  533. // 隐藏存演奏按钮
  534. const handleComplexButton = (res?: IPostMessage) => {
  535. console.log('监听是否隐藏保存按钮', res)
  536. if (res?.content) {
  537. const { header, body } = res.content;
  538. detailState.isHideEvaluatReportSaveBtn = true
  539. }
  540. };
  541. // 离开之前再提交一次最高分数
  542. export const submitMaxScore = () => {
  543. const search = useOriginSearch()
  544. if (search.unitId && scoreList.length) {
  545. console.log('最高分',scoreList,Math.max(...scoreList))
  546. postMessage({
  547. api: 'setCache',
  548. content: {
  549. key: 'h5-orchestra-unit',
  550. value: JSON.stringify({
  551. musicId: search.id || '',
  552. unitId: search.unitId || '',
  553. questionId: search.questionId || '',
  554. score: Math.max(...scoreList),
  555. }),
  556. },
  557. })
  558. }
  559. }
  560. export default defineComponent({
  561. name: 'ColexiuButtonEvaluating',
  562. setup(props, { expose }) {
  563. onMounted(async () => {
  564. console.log('进入评测模块')
  565. handleCheckEvaluatStatus()
  566. // 如果为单元测验和课后训练,不清楚选段数据
  567. if (!unitTestData.isSelectMeasureMode) {
  568. detailState.section = []
  569. detailState.sectionStatus = false
  570. }
  571. RuntimeUtils.changeAllMode()
  572. playUrl.value = runtime.songs.background || (runtime.songs.music as string)
  573. runtime.audiosInstance?.audios[playUrl.value]?.addEventListener('play', timeupdate)
  574. runtime.audiosInstance?.audios[playUrl.value]?.addEventListener('timeupdate', onProgress)
  575. // RuntimeUtils.event.on('next-click', playerStop)
  576. RuntimeUtils.event.on('ended', endevent)
  577. listenerMessage('sendResult', sendResult)
  578. // listenerMessage('cancelEvaluating', cancelTheEvaluation)
  579. listenerMessage('cloudTimeUpdae', onProgress)
  580. RuntimeUtils.event.on('tickDestroy', cloudMetronome)
  581. RuntimeUtils.event.on('tickEnd', evaluatStart)
  582. hideComplexButton(handleComplexButton, true);
  583. })
  584. onBeforeUnmount(() => {
  585. runtime.audiosInstance?.audios[playUrl.value]?.removeEventListener('play', timeupdate)
  586. runtime.audiosInstance?.audios[playUrl.value]?.removeEventListener('timeupdate', onProgress)
  587. // RuntimeUtils.event.off('next-click', playerStop)
  588. RuntimeUtils.event.off('ended', endevent)
  589. RuntimeUtils.event.off('tickDestroy', cloudMetronome)
  590. removeListenerMessage('sendResult', sendResult)
  591. // removeListenerMessage('cancelEvaluating', cancelTheEvaluation)
  592. removeListenerMessage('cloudTimeUpdae', onProgress)
  593. hideComplexButton(() => {}, false);
  594. RuntimeUtils.event.off('tickEnd', evaluatStart)
  595. submitMaxScore()
  596. })
  597. expose({
  598. setPlayer,
  599. startPlay,
  600. stopPlay,
  601. togglePlay,
  602. playerStop,
  603. evaluating,
  604. connentLoading,
  605. playStatus,
  606. cancelTheEvaluation,
  607. })
  608. return () => {
  609. return (
  610. <Teleport to="body" key="StartEvaluating">
  611. {/* 评测完成结果显示 */}
  612. <Evaluating data={endResult.value} />
  613. <Transition name="finish">
  614. {startButtonShow.value && (
  615. <div
  616. style={{
  617. backgroundImage: `url(${iconEvaluatingStart})`,
  618. 'transform': detailState.isSpecialShapedScreen ? `translateX(${detailState.notchHeight / 4}px)` : '',
  619. }}
  620. class={[styles.evaluatStartBtn]}
  621. onClick={() => {
  622. setPlayer()
  623. }}
  624. ></div>
  625. )}
  626. </Transition>
  627. {!evaluating.value ? (
  628. <div class={styles.dialogueBox} key="start">
  629. <div class={styles.dialogue}>
  630. <div>
  631. 演奏前请调整好乐器,保证最佳演奏状态。<span class={styles.triangle}></span>
  632. </div>
  633. </div>
  634. <Vue3Lottie class={styles.dialogueIcon} animationData={startData}></Vue3Lottie>
  635. </div>
  636. ) : (
  637. <div class={styles.dialogueBox} key="starting">
  638. <div class={styles.inRadio}>收音中...</div>
  639. <Vue3Lottie class={styles.inRadioIcon} animationData={startingData}></Vue3Lottie>
  640. </div>
  641. )}
  642. </Teleport>
  643. )
  644. }
  645. },
  646. })