mirror of
https://github.com/zoriya/react-native-omni.git
synced 2026-08-16 02:44:51 +00:00
Handle rendition selection
This commit is contained in:
+12
-12
@@ -1,4 +1,4 @@
|
||||
import { memo, useCallback, useEffect, useMemo, useState } from "react";
|
||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import type React from "react";
|
||||
import { Pressable, ScrollView, StyleSheet, Text, View } from "react-native";
|
||||
import {
|
||||
@@ -10,6 +10,12 @@ import {
|
||||
} from "react-native-omni";
|
||||
|
||||
const PLAYLIST = [
|
||||
{
|
||||
title: "elephants dram",
|
||||
artist: "multi audio",
|
||||
album: "Adaptive",
|
||||
uri: "https://playertest.longtailvideo.com/adaptive/elephants_dream_v4/index.m3u8",
|
||||
},
|
||||
{
|
||||
title: "Big Buck Bunny (HLS)",
|
||||
artist: "Blender Foundation",
|
||||
@@ -60,6 +66,7 @@ function PlayerExample({
|
||||
|
||||
const muted = usePlayerState("muted");
|
||||
const volume = usePlayerState("volume");
|
||||
const isAutoQuality = usePlayerState("isAutoQuality");
|
||||
const [logs, setLogs] = useState<string[]>([]);
|
||||
const [tracks, setTracks] = useState(() => ({
|
||||
videos: [...player.videos],
|
||||
@@ -205,11 +212,6 @@ function PlayerExample({
|
||||
refreshTracks();
|
||||
};
|
||||
|
||||
const selectRendition = (rendition?: (typeof tracks.renditions)[number]) => {
|
||||
player.selectRendition(rendition);
|
||||
refreshTracks();
|
||||
};
|
||||
|
||||
return (
|
||||
<ScrollView style={styles.container}>
|
||||
<Text style={styles.heading}>react-native-omni</Text>
|
||||
@@ -369,16 +371,14 @@ function PlayerExample({
|
||||
<Pressable
|
||||
style={[
|
||||
styles.trackButton,
|
||||
!tracks.renditions.some((rendition) => rendition.selected) &&
|
||||
styles.selectedTrackButton,
|
||||
isAutoQuality && styles.selectedTrackButton,
|
||||
]}
|
||||
onPress={() => selectRendition(undefined)}
|
||||
onPress={() => player.selectRendition(undefined)}
|
||||
>
|
||||
<Text
|
||||
style={[
|
||||
styles.trackButtonText,
|
||||
!tracks.renditions.some((rendition) => rendition.selected) &&
|
||||
styles.selectedTrackButtonText,
|
||||
isAutoQuality && styles.selectedTrackButtonText,
|
||||
]}
|
||||
>
|
||||
Auto
|
||||
@@ -394,7 +394,7 @@ function PlayerExample({
|
||||
styles.trackButton,
|
||||
rendition.selected && styles.selectedTrackButton,
|
||||
]}
|
||||
onPress={() => selectRendition(rendition)}
|
||||
onPress={() => player.selectRendition(rendition)}
|
||||
>
|
||||
<Text
|
||||
style={[
|
||||
|
||||
Reference in New Issue
Block a user