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 Oct 25, 2024
1 parent 6859be8 commit a50a6c2
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 @@ -287,6 +293,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 @@ -382,6 +395,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 a50a6c2

Please sign in to comment.