mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-04-30 12:44:51 +00:00
Add subtitle background toggle functionality in AndroidVideoPlayer and SubtitleModals, enhancing user control over subtitle appearance. Update CustomSubtitles to reflect background setting.
This commit is contained in:
parent
4ad6f37449
commit
897294fdfc
4 changed files with 71 additions and 2 deletions
|
|
@ -145,6 +145,7 @@ const AndroidVideoPlayer: React.FC = () => {
|
||||||
const [customSubtitles, setCustomSubtitles] = useState<SubtitleCue[]>([]);
|
const [customSubtitles, setCustomSubtitles] = useState<SubtitleCue[]>([]);
|
||||||
const [currentSubtitle, setCurrentSubtitle] = useState<string>('');
|
const [currentSubtitle, setCurrentSubtitle] = useState<string>('');
|
||||||
const [subtitleSize, setSubtitleSize] = useState<number>(DEFAULT_SUBTITLE_SIZE);
|
const [subtitleSize, setSubtitleSize] = useState<number>(DEFAULT_SUBTITLE_SIZE);
|
||||||
|
const [subtitleBackground, setSubtitleBackground] = useState<boolean>(true);
|
||||||
const [useCustomSubtitles, setUseCustomSubtitles] = useState<boolean>(false);
|
const [useCustomSubtitles, setUseCustomSubtitles] = useState<boolean>(false);
|
||||||
const [isLoadingSubtitles, setIsLoadingSubtitles] = useState<boolean>(false);
|
const [isLoadingSubtitles, setIsLoadingSubtitles] = useState<boolean>(false);
|
||||||
const [availableSubtitles, setAvailableSubtitles] = useState<WyzieSubtitle[]>([]);
|
const [availableSubtitles, setAvailableSubtitles] = useState<WyzieSubtitle[]>([]);
|
||||||
|
|
@ -895,6 +896,10 @@ const AndroidVideoPlayer: React.FC = () => {
|
||||||
saveSubtitleSize(newSize);
|
saveSubtitleSize(newSize);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const toggleSubtitleBackground = () => {
|
||||||
|
setSubtitleBackground(!subtitleBackground);
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (pendingSeek && isPlayerReady && isVideoLoaded && duration > 0) {
|
if (pendingSeek && isPlayerReady && isVideoLoaded && duration > 0) {
|
||||||
logger.log(`[AndroidVideoPlayer] Player ready after source change, seeking to position: ${pendingSeek.position}s out of ${duration}s total`);
|
logger.log(`[AndroidVideoPlayer] Player ready after source change, seeking to position: ${pendingSeek.position}s out of ${duration}s total`);
|
||||||
|
|
@ -1196,6 +1201,7 @@ const AndroidVideoPlayer: React.FC = () => {
|
||||||
useCustomSubtitles={useCustomSubtitles}
|
useCustomSubtitles={useCustomSubtitles}
|
||||||
currentSubtitle={currentSubtitle}
|
currentSubtitle={currentSubtitle}
|
||||||
subtitleSize={subtitleSize}
|
subtitleSize={subtitleSize}
|
||||||
|
subtitleBackground={subtitleBackground}
|
||||||
zoomScale={zoomScale}
|
zoomScale={zoomScale}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
@ -1232,11 +1238,13 @@ const AndroidVideoPlayer: React.FC = () => {
|
||||||
selectedTextTrack={selectedTextTrack}
|
selectedTextTrack={selectedTextTrack}
|
||||||
useCustomSubtitles={useCustomSubtitles}
|
useCustomSubtitles={useCustomSubtitles}
|
||||||
subtitleSize={subtitleSize}
|
subtitleSize={subtitleSize}
|
||||||
|
subtitleBackground={subtitleBackground}
|
||||||
fetchAvailableSubtitles={fetchAvailableSubtitles}
|
fetchAvailableSubtitles={fetchAvailableSubtitles}
|
||||||
loadWyzieSubtitle={loadWyzieSubtitle}
|
loadWyzieSubtitle={loadWyzieSubtitle}
|
||||||
selectTextTrack={selectTextTrack}
|
selectTextTrack={selectTextTrack}
|
||||||
increaseSubtitleSize={increaseSubtitleSize}
|
increaseSubtitleSize={increaseSubtitleSize}
|
||||||
decreaseSubtitleSize={decreaseSubtitleSize}
|
decreaseSubtitleSize={decreaseSubtitleSize}
|
||||||
|
toggleSubtitleBackground={toggleSubtitleBackground}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<SourcesModal
|
<SourcesModal
|
||||||
|
|
|
||||||
|
|
@ -24,11 +24,13 @@ interface SubtitleModalsProps {
|
||||||
selectedTextTrack: number;
|
selectedTextTrack: number;
|
||||||
useCustomSubtitles: boolean;
|
useCustomSubtitles: boolean;
|
||||||
subtitleSize: number;
|
subtitleSize: number;
|
||||||
|
subtitleBackground: boolean;
|
||||||
fetchAvailableSubtitles: () => void;
|
fetchAvailableSubtitles: () => void;
|
||||||
loadWyzieSubtitle: (subtitle: WyzieSubtitle) => void;
|
loadWyzieSubtitle: (subtitle: WyzieSubtitle) => void;
|
||||||
selectTextTrack: (trackId: number) => void;
|
selectTextTrack: (trackId: number) => void;
|
||||||
increaseSubtitleSize: () => void;
|
increaseSubtitleSize: () => void;
|
||||||
decreaseSubtitleSize: () => void;
|
decreaseSubtitleSize: () => void;
|
||||||
|
toggleSubtitleBackground: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { width, height } = Dimensions.get('window');
|
const { width, height } = Dimensions.get('window');
|
||||||
|
|
@ -47,11 +49,13 @@ export const SubtitleModals: React.FC<SubtitleModalsProps> = ({
|
||||||
selectedTextTrack,
|
selectedTextTrack,
|
||||||
useCustomSubtitles,
|
useCustomSubtitles,
|
||||||
subtitleSize,
|
subtitleSize,
|
||||||
|
subtitleBackground,
|
||||||
fetchAvailableSubtitles,
|
fetchAvailableSubtitles,
|
||||||
loadWyzieSubtitle,
|
loadWyzieSubtitle,
|
||||||
selectTextTrack,
|
selectTextTrack,
|
||||||
increaseSubtitleSize,
|
increaseSubtitleSize,
|
||||||
decreaseSubtitleSize,
|
decreaseSubtitleSize,
|
||||||
|
toggleSubtitleBackground,
|
||||||
}) => {
|
}) => {
|
||||||
// Track which specific online subtitle is currently loaded
|
// Track which specific online subtitle is currently loaded
|
||||||
const [selectedOnlineSubtitleId, setSelectedOnlineSubtitleId] = React.useState<string | null>(null);
|
const [selectedOnlineSubtitleId, setSelectedOnlineSubtitleId] = React.useState<string | null>(null);
|
||||||
|
|
@ -224,6 +228,57 @@ export const SubtitleModals: React.FC<SubtitleModalsProps> = ({
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
|
{/* Background Toggle Section */}
|
||||||
|
<View style={{ marginBottom: 30 }}>
|
||||||
|
<Text style={{
|
||||||
|
color: 'rgba(255, 255, 255, 0.7)',
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight: '600',
|
||||||
|
marginBottom: 15,
|
||||||
|
textTransform: 'uppercase',
|
||||||
|
letterSpacing: 0.5,
|
||||||
|
}}>
|
||||||
|
Background
|
||||||
|
</Text>
|
||||||
|
|
||||||
|
<View style={{
|
||||||
|
flexDirection: 'row',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'space-between',
|
||||||
|
backgroundColor: 'rgba(255, 255, 255, 0.05)',
|
||||||
|
borderRadius: 16,
|
||||||
|
padding: 16,
|
||||||
|
}}>
|
||||||
|
<Text style={{
|
||||||
|
color: 'white',
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: '500',
|
||||||
|
}}>
|
||||||
|
Show Background
|
||||||
|
</Text>
|
||||||
|
|
||||||
|
<TouchableOpacity
|
||||||
|
style={{
|
||||||
|
width: 50,
|
||||||
|
height: 28,
|
||||||
|
backgroundColor: subtitleBackground ? '#007AFF' : 'rgba(255, 255, 255, 0.2)',
|
||||||
|
borderRadius: 14,
|
||||||
|
justifyContent: 'center',
|
||||||
|
alignItems: subtitleBackground ? 'flex-end' : 'flex-start',
|
||||||
|
paddingHorizontal: 2,
|
||||||
|
}}
|
||||||
|
onPress={toggleSubtitleBackground}
|
||||||
|
>
|
||||||
|
<View style={{
|
||||||
|
width: 24,
|
||||||
|
height: 24,
|
||||||
|
backgroundColor: 'white',
|
||||||
|
borderRadius: 12,
|
||||||
|
}} />
|
||||||
|
</TouchableOpacity>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
|
||||||
{/* Built-in Subtitles */}
|
{/* Built-in Subtitles */}
|
||||||
{vlcTextTracks.length > 0 && (
|
{vlcTextTracks.length > 0 && (
|
||||||
<View style={{ marginBottom: 30 }}>
|
<View style={{ marginBottom: 30 }}>
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ interface CustomSubtitlesProps {
|
||||||
useCustomSubtitles: boolean;
|
useCustomSubtitles: boolean;
|
||||||
currentSubtitle: string;
|
currentSubtitle: string;
|
||||||
subtitleSize: number;
|
subtitleSize: number;
|
||||||
|
subtitleBackground: boolean;
|
||||||
zoomScale?: number; // current video zoom scale; defaults to 1
|
zoomScale?: number; // current video zoom scale; defaults to 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -13,6 +14,7 @@ export const CustomSubtitles: React.FC<CustomSubtitlesProps> = ({
|
||||||
useCustomSubtitles,
|
useCustomSubtitles,
|
||||||
currentSubtitle,
|
currentSubtitle,
|
||||||
subtitleSize,
|
subtitleSize,
|
||||||
|
subtitleBackground,
|
||||||
zoomScale = 1,
|
zoomScale = 1,
|
||||||
}) => {
|
}) => {
|
||||||
if (!useCustomSubtitles || !currentSubtitle) return null;
|
if (!useCustomSubtitles || !currentSubtitle) return null;
|
||||||
|
|
@ -23,7 +25,12 @@ export const CustomSubtitles: React.FC<CustomSubtitlesProps> = ({
|
||||||
style={styles.customSubtitleContainer}
|
style={styles.customSubtitleContainer}
|
||||||
pointerEvents="none"
|
pointerEvents="none"
|
||||||
>
|
>
|
||||||
<View style={styles.customSubtitleWrapper}>
|
<View style={[
|
||||||
|
styles.customSubtitleWrapper,
|
||||||
|
{
|
||||||
|
backgroundColor: subtitleBackground ? 'rgba(0, 0, 0, 0.7)' : 'transparent',
|
||||||
|
}
|
||||||
|
]}>
|
||||||
<Text style={[
|
<Text style={[
|
||||||
styles.customSubtitleText,
|
styles.customSubtitleText,
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -537,7 +537,6 @@ export const styles = StyleSheet.create({
|
||||||
zIndex: 1500, // Higher z-index to appear above other elements
|
zIndex: 1500, // Higher z-index to appear above other elements
|
||||||
},
|
},
|
||||||
customSubtitleWrapper: {
|
customSubtitleWrapper: {
|
||||||
backgroundColor: 'rgba(0, 0, 0, 0.7)',
|
|
||||||
padding: 10,
|
padding: 10,
|
||||||
borderRadius: 5,
|
borderRadius: 5,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue