mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-04-21 00:04:42 +01:00
Finished changes for audio selection
This commit is contained in:
@@ -2,7 +2,7 @@ import React, { useEffect } from "react";
|
|||||||
import { View, StyleSheet } from "react-native";
|
import { View, StyleSheet } from "react-native";
|
||||||
import { useSharedValue } from "react-native-reanimated";
|
import { useSharedValue } from "react-native-reanimated";
|
||||||
import { Slider } from "react-native-awesome-slider";
|
import { Slider } from "react-native-awesome-slider";
|
||||||
import VolumeManager from "react-native-volume-manager";
|
import { VolumeManager } from "react-native-volume-manager";
|
||||||
import { Ionicons } from "@expo/vector-icons";
|
import { Ionicons } from "@expo/vector-icons";
|
||||||
|
|
||||||
const AudioSlider = () => {
|
const AudioSlider = () => {
|
||||||
@@ -13,7 +13,7 @@ const AudioSlider = () => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchInitialVolume = async () => {
|
const fetchInitialVolume = async () => {
|
||||||
try {
|
try {
|
||||||
const initialVolume = await VolumeManager.getVolume();
|
const { volume: initialVolume } = await VolumeManager.getVolume();
|
||||||
console.log("initialVolume", initialVolume);
|
console.log("initialVolume", initialVolume);
|
||||||
volume.value = initialVolume * 100;
|
volume.value = initialVolume * 100;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -21,14 +21,36 @@ const AudioSlider = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
fetchInitialVolume();
|
fetchInitialVolume();
|
||||||
|
|
||||||
|
// Disable the native volume UI when the component mounts
|
||||||
|
VolumeManager.showNativeVolumeUI({ enabled: false });
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
// Re-enable the native volume UI when the component unmounts
|
||||||
|
VolumeManager.showNativeVolumeUI({ enabled: true });
|
||||||
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleValueChange = async (value: number) => {
|
const handleValueChange = async (value: number) => {
|
||||||
volume.value = value;
|
volume.value = value;
|
||||||
console.log("volume", value);
|
console.log("volume", value);
|
||||||
await VolumeManager.setVolume(value / 100);
|
await VolumeManager.setVolume(value / 100);
|
||||||
|
|
||||||
|
// Re-call showNativeVolumeUI to ensure the setting is applied on iOS
|
||||||
|
VolumeManager.showNativeVolumeUI({ enabled: false });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const volumeListener = VolumeManager.addVolumeListener((result) => {
|
||||||
|
console.log("Volume changed:", result.volume);
|
||||||
|
volume.value = result.volume * 100;
|
||||||
|
});
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
volumeListener.remove();
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.sliderContainer}>
|
<View style={styles.sliderContainer}>
|
||||||
<Slider
|
<Slider
|
||||||
|
|||||||
@@ -71,7 +71,7 @@
|
|||||||
"react-dom": "18.2.0",
|
"react-dom": "18.2.0",
|
||||||
"react-native": "0.74.5",
|
"react-native": "0.74.5",
|
||||||
"react-native-awesome-slider": "^2.5.6",
|
"react-native-awesome-slider": "^2.5.6",
|
||||||
"react-native-bottom-tabs": "^0.7.1",
|
"react-native-bottom-tabs": "0.7.1",
|
||||||
"react-native-circular-progress": "^1.4.1",
|
"react-native-circular-progress": "^1.4.1",
|
||||||
"react-native-compressor": "^1.9.0",
|
"react-native-compressor": "^1.9.0",
|
||||||
"react-native-device-info": "^14.0.1",
|
"react-native-device-info": "^14.0.1",
|
||||||
|
|||||||
Reference in New Issue
Block a user