Skip to content

Commit 3b899bc

Browse files
authored
feat: add fullscreen control methods (#34)
Added three new methods to VimeoPlayer for fullscreen control: - requestFullscreen(): Enter fullscreen mode - exitFullscreen(): Exit fullscreen mode - getFullscreen(): Get current fullscreen state Updated example app to demonstrate fullscreen functionality with auto-exit demo.
1 parent 629e85d commit 3b899bc

File tree

7 files changed

+131
-2
lines changed

7 files changed

+131
-2
lines changed

.changeset/cyan-lights-wait.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
"react-native-vimeo-bridge": minor
3+
---
4+
5+
feat: add fullscreen control methods (requestFullscreen, exitFullscreen, getFullscreen)
6+
7+
Added three new methods to VimeoPlayer for fullscreen control:
8+
9+
- requestFullscreen(): Enter fullscreen mode
10+
- exitFullscreen(): Exit fullscreen mode
11+
- getFullscreen(): Get current fullscreen state
12+
13+
Updated example app to demonstrate fullscreen functionality with auto-exit demo.
14+
15+
Example usage:
16+
17+
```tsx
18+
const player = useVimeoPlayer(vimeoUrl, {
19+
autoplay: true,
20+
controls: true,
21+
fullscreen: true, // default: true
22+
});
23+
24+
const onFullscreenChange = async () => {
25+
const isFullscreen = await player.getFullscreen();
26+
27+
if (isFullscreen) {
28+
await player.exitFullscreen();
29+
return;
30+
}
31+
32+
await player.requestFullscreen();
33+
};
34+
```

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,6 @@ android/generated
8686
nitrogen/
8787

8888
dist/
89+
90+
# vimeo-js
91+
vimeo-js.md

example/src/App.tsx

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ function App() {
3535
const progress = useVimeoEvent(player, 'progress');
3636
const volumeStatus = useVimeoEvent(player, 'volumechange');
3737
const playbackRate = useVimeoEvent(player, 'playbackratechange');
38+
const fullscreen = useVimeoEvent(player, 'fullscreenchange');
3839

3940
const volume = safeNumber(volumeStatus?.volume);
4041
const currentTime = safeNumber(timeupdate?.seconds);
@@ -124,7 +125,7 @@ function App() {
124125

125126
return (
126127
<SafeAreaView style={styles.container}>
127-
<ScrollView showsVerticalScrollIndicator={false}>
128+
<ScrollView contentContainerStyle={styles.contentContainer} showsVerticalScrollIndicator={false}>
128129
<View style={styles.header}>
129130
<Text style={styles.title}>Vimeo Player</Text>
130131
<Text style={styles.subtitle}>Video ID: {videoId}</Text>
@@ -225,6 +226,35 @@ function App() {
225226
</View>
226227
</View>
227228

229+
<View style={styles.fullscreenSection}>
230+
<Text
231+
style={styles.sectionTitle}
232+
>{`Fullscreen control (${fullscreen?.fullscreen ? 'fullscreen' : 'not fullscreen'})`}</Text>
233+
<View style={styles.fullscreenControls}>
234+
<TouchableOpacity
235+
style={[styles.button, styles.fullscreenButton]}
236+
onPress={async () => {
237+
await player.requestFullscreen();
238+
239+
setTimeout(async () => {
240+
await player.exitFullscreen();
241+
}, 3000);
242+
}}
243+
>
244+
<Text style={styles.buttonText}>{'Enter fullscreen (auto-exit in 3s)'}</Text>
245+
</TouchableOpacity>
246+
247+
<TouchableOpacity
248+
style={[styles.button, styles.fullscreenButton]}
249+
onPress={async () => {
250+
await player.exitFullscreen();
251+
}}
252+
>
253+
<Text style={styles.buttonText}>{'Exit fullscreen'}</Text>
254+
</TouchableOpacity>
255+
</View>
256+
</View>
257+
228258
<View style={styles.infoSection}>
229259
<TouchableOpacity style={[styles.button, styles.infoButton]} onPress={getPlayerInfo}>
230260
<Text style={styles.buttonText}>📊 Player info</Text>
@@ -239,6 +269,10 @@ const styles = StyleSheet.create({
239269
container: {
240270
flex: 1,
241271
backgroundColor: '#f5f5f5',
272+
paddingBottom: 50,
273+
},
274+
contentContainer: {
275+
flexGrow: 1,
242276
},
243277
header: {
244278
padding: 16,
@@ -348,7 +382,7 @@ const styles = StyleSheet.create({
348382
volumeButton: {
349383
paddingHorizontal: 12,
350384
paddingVertical: 8,
351-
backgroundColor: '#9E9E9E',
385+
backgroundColor: '#607D8B',
352386
borderRadius: 6,
353387
minWidth: 60,
354388
},
@@ -378,6 +412,25 @@ const styles = StyleSheet.create({
378412
marginBottom: 8,
379413
minWidth: 50,
380414
},
415+
fullscreenSection: {
416+
margin: 16,
417+
marginBottom: 8,
418+
padding: 16,
419+
backgroundColor: '#fff',
420+
borderRadius: 8,
421+
},
422+
fullscreenButton: {
423+
paddingHorizontal: 12,
424+
paddingVertical: 8,
425+
backgroundColor: '#607D8B',
426+
borderRadius: 6,
427+
minWidth: 60,
428+
},
429+
fullscreenControls: {
430+
flexDirection: 'row',
431+
justifyContent: 'space-around',
432+
flexWrap: 'wrap',
433+
},
381434
activeButton: {
382435
backgroundColor: '#FF5722',
383436
},

src/VimeoView.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ function VimeoView({ player, height = 200, width = screenWidth, style, webViewPr
173173
getVideoWidth: () => player.getVideoWidth(),
174174
getVideoHeight: () => player.getVideoHeight(),
175175
getVideoUrl: () => player.getVideoUrl(),
176+
requestFullscreen: () => player.requestFullscreen(),
177+
exitFullscreen: () => player.exitFullscreen(),
178+
getFullscreen: () => player.getFullscreen(),
176179
destroy: () => {
177180
player.off('play');
178181
player.off('playing');

src/module/VimeoPlayer.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,18 @@ class VimeoPlayer {
129129
async getVideoUrl(): Promise<string> {
130130
return this.controller?.getVideoUrl() ?? '';
131131
}
132+
133+
async requestFullscreen(): Promise<void> {
134+
await this.controller?.requestFullscreen();
135+
}
136+
137+
async exitFullscreen(): Promise<void> {
138+
await this.controller?.exitFullscreen();
139+
}
140+
141+
async getFullscreen(): Promise<boolean> {
142+
return this.controller?.getFullscreen() ?? false;
143+
}
132144
}
133145

134146
export default VimeoPlayer;

src/module/WebVimeoPlayerController.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,18 @@ class WebVimeoPlayerController {
147147
return this.player?.getVideoUrl() ?? '';
148148
}
149149

150+
async requestFullscreen(): Promise<void> {
151+
await this.player?.requestFullscreen();
152+
}
153+
154+
async exitFullscreen(): Promise<void> {
155+
await this.player?.exitFullscreen();
156+
}
157+
158+
async getFullscreen(): Promise<boolean> {
159+
return this.player?.getFullscreen() ?? false;
160+
}
161+
150162
off(event: string, callback?: EventCallback): void {
151163
this.player?.off(event, callback);
152164
}

src/module/WebviewVimeoPlayerController.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,18 @@ class WebviewVimeoPlayerController {
8686
return this.executeCommand('getVideoUrl', [], true);
8787
}
8888

89+
async requestFullscreen(): Promise<void> {
90+
await this.executeCommand('requestFullscreen');
91+
}
92+
93+
async exitFullscreen(): Promise<void> {
94+
await this.executeCommand('exitFullscreen');
95+
}
96+
97+
async getFullscreen(): Promise<boolean> {
98+
return this.executeCommand('getFullscreen', [], true);
99+
}
100+
89101
async destroy(): Promise<void> {
90102
await this.executeCommand('destroy');
91103
}

0 commit comments

Comments
 (0)