mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-03-11 17:45:38 +00:00
Update TrailerContext.tsx
Added automatic screen orientation when playing trailer.
This commit is contained in:
parent
045353bc1b
commit
4449a924a3
1 changed files with 13 additions and 0 deletions
|
|
@ -1,3 +1,5 @@
|
|||
import * as ScreenOrientation from 'expo-screen-orientation';
|
||||
|
||||
import React, { createContext, useContext, useState, useCallback, useMemo, ReactNode } from 'react';
|
||||
|
||||
interface TrailerContextValue {
|
||||
|
|
@ -12,6 +14,17 @@ const TrailerContext = createContext<TrailerContextValue | undefined>(undefined)
|
|||
export const TrailerProvider: React.FC<{ children: ReactNode }> = ({ children }) => {
|
||||
const [isTrailerPlaying, setIsTrailerPlaying] = useState(true);
|
||||
|
||||
React.useEffect(() => {
|
||||
async function handleRotation() {
|
||||
if (isTrailerPlaying) {
|
||||
await ScreenOrientation.lockAsync(ScreenOrientation.OrientationLock.LANDSCAPE);
|
||||
} else {
|
||||
await ScreenOrientation.lockAsync(ScreenOrientation.OrientationLock.PORTRAIT_UP);
|
||||
}
|
||||
}
|
||||
handleRotation();
|
||||
}, [isTrailerPlaying]);
|
||||
|
||||
const pauseTrailer = useCallback(() => {
|
||||
setIsTrailerPlaying(false);
|
||||
}, []);
|
||||
|
|
|
|||
Loading…
Reference in a new issue