mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-26 00:31:20 -08:00
refactor(core): CORE-10 type playback properties and add compatible controls view
This commit is contained in:
1 parent
44f4e083a9
commit
5e31274f1d
48 files changed
+3846
-248
No files matched your search
@@ -0,0 +1,26 @@
|
||||
import type { MediaHost } from '../media/hosts'
|
||||
import type { PlaybackNotice } from '../media/playback'
|
||||
import { def } from '../utils'
|
||||
|
||||
type RateHost = MediaHost<Pick<HTMLMediaElement, 'playbackRate'>> & PlaybackNotice
|
||||
|
||||
export default function playbackRateMix(art: RateHost): asserts art is RateHost & { playbackRate: number } {
|
||||
const { template: { $video }, i18n, notice } = art
|
||||
const target = art as RateHost & { playbackRate: number }
|
||||
def(art, 'playbackRate', {
|
||||
get() {
|
||||
return $video.playbackRate
|
||||
},
|
||||
set(rate: number) {
|
||||
if (rate) {
|
||||
if (rate === $video.playbackRate)
|
||||
return
|
||||
$video.playbackRate = rate
|
||||
notice.show = `${i18n.get('Rate')}: ${rate === 1.0 ? i18n.get('Normal') : `${rate}x`}`
|
||||
}
|
||||
else {
|
||||
target.playbackRate = 1
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user