Skip to content

Commit e075a87

Browse files
ndonkoHenriCopilot
andauthored
feat(flet-video): enter/exit Video fullscreen programmatically (#5774)
* initial commit * chore: Update CHANGELOG for version 0.2.0 to mark as unreleased * fix typo Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent aa88388 commit e075a87

File tree

16 files changed

+167
-120
lines changed

16 files changed

+167
-120
lines changed

sdk/python/examples/controls/video/example_1.py

Lines changed: 98 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,141 +1,139 @@
11
import random
22

3+
import flet as ft
34
import flet_video as ftv
45

5-
import flet as ft
6+
sample_media = [
7+
ftv.VideoMedia(
8+
"https://user-images.githubusercontent.com/28951144/229373720-14d69157-1a56-4a78-a2f4-d7a134d7c3e9.mp4"
9+
),
10+
ftv.VideoMedia(
11+
"https://user-images.githubusercontent.com/28951144/229373718-86ce5e1d-d195-45d5-baa6-ef94041d0b90.mp4"
12+
),
13+
ftv.VideoMedia(
14+
"https://user-images.githubusercontent.com/28951144/229373716-76da0a4e-225a-44e4-9ee7-3e9006dbc3e3.mp4"
15+
),
16+
ftv.VideoMedia(
17+
"https://user-images.githubusercontent.com/28951144/229373695-22f88f13-d18f-4288-9bf1-c3e078d83722.mp4"
18+
),
19+
ftv.VideoMedia(
20+
"https://user-images.githubusercontent.com/28951144/229373709-603a7a89-2105-4e1b-a5a5-a6c3567c9a59.mp4",
21+
extras={
22+
"artist": "Thousand Foot Krutch",
23+
"album": "The End Is Where We Begin",
24+
},
25+
http_headers={
26+
"Foo": "Bar",
27+
"Accept": "*/*",
28+
},
29+
),
30+
]
631

732

833
def main(page: ft.Page):
9-
page.theme_mode = ft.ThemeMode.LIGHT
10-
page.title = "TheEthicalVideo"
11-
page.window.always_on_top = True
1234
page.spacing = 20
1335
page.horizontal_alignment = ft.CrossAxisAlignment.CENTER
1436

15-
async def handle_pause(e):
37+
async def handle_pause(e: ft.Event[ft.Button]):
1638
await video.pause()
17-
print("Video.pause()")
1839

19-
async def handle_play_or_pause(e):
40+
async def handle_play_or_pause(e: ft.Event[ft.Button]):
2041
await video.play_or_pause()
21-
print("Video.play_or_pause()")
2242

23-
async def handle_play(e):
43+
async def handle_play(e: ft.Event[ft.Button]):
2444
await video.play()
25-
print("Video.play()")
2645

27-
async def handle_stop(e):
46+
async def handle_stop(e: ft.Event[ft.Button]):
2847
await video.stop()
29-
print("Video.stop()")
3048

31-
async def handle_next(e):
49+
async def handle_next(e: ft.Event[ft.Button]):
3250
await video.next()
33-
print("Video.next()")
3451

35-
async def handle_previous(e):
52+
async def handle_previous(e: ft.Event[ft.Button]):
3653
await video.previous()
37-
print("Video.previous()")
3854

39-
def handle_volume_change(e):
55+
def handle_volume_change(e: ft.Event[ft.Slider]):
4056
video.volume = e.control.value
41-
print(f"Video.volume = {e.control.value}")
4257

43-
def handle_playback_rate_change(e):
58+
def handle_playback_rate_change(e: ft.Event[ft.Slider]):
4459
video.playback_rate = e.control.value
45-
print(f"Video.playback_rate = {e.control.value}")
4660

47-
async def handle_seek(e):
61+
async def handle_seek(e: ft.Event[ft.Button]):
4862
await video.seek(10000)
49-
print("Video.seek(10000)")
5063

51-
async def handle_add_media(e):
64+
async def handle_add_media(e: ft.Event[ft.Button]):
5265
await video.playlist_add(random.choice(sample_media))
53-
print("Video.playlist_add(random.choice(sample_media))")
5466

55-
async def handle_remove_media(e):
67+
async def handle_remove_media(e: ft.Event[ft.Button]):
5668
r = random.randint(0, len(video.playlist) - 1)
5769
await video.playlist_remove(r)
58-
print(f"Popped Item at index: {r} (position {r + 1})")
5970

60-
async def handle_jump(e):
61-
print("Video.jump_to(0)")
71+
async def handle_jump(e: ft.Event[ft.Button]):
6272
await video.jump_to(0)
6373

64-
sample_media = [
65-
ftv.VideoMedia(
66-
"https://user-images.githubusercontent.com/28951144/229373720-14d69157-1a56-4a78-a2f4-d7a134d7c3e9.mp4"
67-
),
68-
ftv.VideoMedia(
69-
"https://user-images.githubusercontent.com/28951144/229373718-86ce5e1d-d195-45d5-baa6-ef94041d0b90.mp4"
70-
),
71-
ftv.VideoMedia(
72-
"https://user-images.githubusercontent.com/28951144/229373716-76da0a4e-225a-44e4-9ee7-3e9006dbc3e3.mp4"
73-
),
74-
ftv.VideoMedia(
75-
"https://user-images.githubusercontent.com/28951144/229373695-22f88f13-d18f-4288-9bf1-c3e078d83722.mp4"
76-
),
77-
ftv.VideoMedia(
78-
"https://user-images.githubusercontent.com/28951144/229373709-603a7a89-2105-4e1b-a5a5-a6c3567c9a59.mp4",
79-
extras={
80-
"artist": "Thousand Foot Krutch",
81-
"album": "The End Is Where We Begin",
82-
},
83-
http_headers={
84-
"Foo": "Bar",
85-
"Accept": "*/*",
86-
},
87-
),
88-
]
74+
async def handle_fullscreen(e: ft.Event[ft.Button]):
75+
video.fullscreen = True
8976

9077
page.add(
91-
video := ftv.Video(
78+
ft.SafeArea(
9279
expand=True,
93-
playlist=sample_media[0:2],
94-
playlist_mode=ftv.PlaylistMode.LOOP,
95-
fill_color=ft.Colors.BLUE_400,
96-
aspect_ratio=16 / 9,
97-
volume=100,
98-
autoplay=False,
99-
filter_quality=ft.FilterQuality.HIGH,
100-
muted=False,
101-
on_load=lambda e: print("Video loaded successfully!"),
102-
on_enter_fullscreen=lambda e: print("Video entered fullscreen!"),
103-
on_exit_fullscreen=lambda e: print("Video exited fullscreen!"),
104-
),
105-
ft.Row(
106-
wrap=True,
107-
alignment=ft.MainAxisAlignment.CENTER,
108-
controls=[
109-
ft.Button("Play", on_click=handle_play),
110-
ft.Button("Pause", on_click=handle_pause),
111-
ft.Button("Play Or Pause", on_click=handle_play_or_pause),
112-
ft.Button("Stop", on_click=handle_stop),
113-
ft.Button("Next", on_click=handle_next),
114-
ft.Button("Previous", on_click=handle_previous),
115-
ft.Button("Seek s=10", on_click=handle_seek),
116-
ft.Button("Jump to first Media", on_click=handle_jump),
117-
ft.Button("Add Random Media", on_click=handle_add_media),
118-
ft.Button("Remove Random Media", on_click=handle_remove_media),
119-
],
120-
),
121-
ft.Slider(
122-
min=0,
123-
value=100,
124-
max=100,
125-
label="Volume = {value}%",
126-
divisions=10,
127-
width=400,
128-
on_change=handle_volume_change,
129-
),
130-
ft.Slider(
131-
min=1,
132-
value=1,
133-
max=3,
134-
label="PlaybackRate = {value}X",
135-
divisions=6,
136-
width=400,
137-
on_change=handle_playback_rate_change,
138-
),
80+
content=ft.Column(
81+
expand=True,
82+
controls=[
83+
video := ftv.Video(
84+
expand=True,
85+
playlist=sample_media[0:2],
86+
playlist_mode=ftv.PlaylistMode.LOOP,
87+
fill_color=ft.Colors.BLUE_400,
88+
aspect_ratio=16 / 9,
89+
volume=100,
90+
autoplay=False,
91+
filter_quality=ft.FilterQuality.HIGH,
92+
muted=False,
93+
on_load=lambda e: print("Video loaded successfully!"),
94+
on_enter_fullscreen=lambda e: print("Entered fullscreen!"),
95+
on_exit_fullscreen=lambda e: print("Exited fullscreen!"),
96+
),
97+
ft.Row(
98+
wrap=True,
99+
alignment=ft.MainAxisAlignment.CENTER,
100+
controls=[
101+
ft.Button("Play", on_click=handle_play),
102+
ft.Button("Pause", on_click=handle_pause),
103+
ft.Button("Play Or Pause", on_click=handle_play_or_pause),
104+
ft.Button("Stop", on_click=handle_stop),
105+
ft.Button("Next", on_click=handle_next),
106+
ft.Button("Previous", on_click=handle_previous),
107+
ft.Button("Seek s=10", on_click=handle_seek),
108+
ft.Button("Jump to first Media", on_click=handle_jump),
109+
ft.Button("Add Random Media", on_click=handle_add_media),
110+
ft.Button(
111+
"Remove Random Media", on_click=handle_remove_media
112+
),
113+
ft.Button("Enter Fullscreen", on_click=handle_fullscreen),
114+
],
115+
),
116+
ft.Slider(
117+
min=0,
118+
value=100,
119+
max=100,
120+
label="Volume = {value}%",
121+
divisions=10,
122+
width=400,
123+
on_change=handle_volume_change,
124+
),
125+
ft.Slider(
126+
min=1,
127+
value=1,
128+
max=3,
129+
label="Playback rate = {value}X",
130+
divisions=6,
131+
width=400,
132+
on_change=handle_playback_rate_change,
133+
),
134+
],
135+
),
136+
)
139137
)
140138

141139

sdk/python/packages/flet-ads/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

8-
## [0.2.0] - 2025-06-26
8+
## [0.2.0] - Unreleased
99

1010
### Added
1111

sdk/python/packages/flet-audio-recorder/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

8-
## [0.2.0] - 2025-06-26
8+
## [0.2.0] - Unreleased
99

1010
### Added
1111

sdk/python/packages/flet-audio/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

8-
## [0.2.0] - 2025-06-26
8+
## [0.2.0] - Unreleased
99

1010
## Added
1111

sdk/python/packages/flet-charts/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

8-
## [0.2.0] - 2025-06-26
8+
## [0.2.0] - Unreleased
99

1010
Initial release.
1111

sdk/python/packages/flet-datatable2/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

8-
## [0.2.0] - 2025-06-26
8+
## [0.2.0] - Unreleased
99

1010
## Added
1111

sdk/python/packages/flet-flashlight/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

8-
## [0.2.0] - 2025-06-26
8+
## [0.2.0] - Unreleased
99

1010
## Added
1111

sdk/python/packages/flet-geolocator/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

8-
## [0.2.0] - 2025-06-26
8+
## [0.2.0] - Unreleased
99

1010
### Added
1111

sdk/python/packages/flet-lottie/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

8-
## [0.2.0] - 2025-06-26
8+
## [0.2.0] - Unreleased
99

1010
## Added
1111

sdk/python/packages/flet-map/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7-
## [0.2.0] - 2025-06-26
7+
## [0.2.0] - Unreleased
88

99
- Added configuration helpers for cameras, interaction flags, and stroke patterns.
1010
- Introduced attribution controls and additional layer types for circles, polygons, and polylines.

0 commit comments

Comments
 (0)