Skip to content

Commit

Permalink
feat: video resolution choose
Browse files Browse the repository at this point in the history
  • Loading branch information
omg-xtao authored Nov 28, 2024
1 parent ad191d9 commit 2034317
Showing 1 changed file with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import React, {useCallback, useEffect, useRef, useState} from 'react'
import React, {
ChangeEvent,
useCallback,
useEffect,
useRef,
useState,
} from 'react'
import {Pressable, View} from 'react-native'
import {msg, Trans} from '@lingui/macro'
import {useLingui} from '@lingui/react'
Expand Down Expand Up @@ -284,6 +290,13 @@ export function Controls({
[onEndHover],
)

const onChangeBitrate = (event: ChangeEvent<HTMLSelectElement>) => {
if (!hlsRef.current) {
return
}
hlsRef.current.currentLevel = parseInt(event.target.value)
}

const showControls =
((focused || autoplayDisabled) && !playing) ||
(interactingViaKeypress ? hasFocus : hovered)
Expand Down Expand Up @@ -380,6 +393,15 @@ export function Controls({
]}>
{formatTime(currentTime)} / {formatTime(duration)}
</Text>
{hlsRef.current && (
<select onChange={onChangeBitrate}>
{hlsRef.current.levels.map((level, id) => (
<option key={id} value={id}>
<Text>{level.height}p</Text>
</option>
))}
</select>
)}
{hasSubtitleTrack && (
<ControlButton
active={subtitlesEnabled}
Expand Down

0 comments on commit 2034317

Please sign in to comment.