flet-video 0.2.0.dev47__py3-none-any.whl → 0.2.0.dev76__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of flet-video might be problematic. Click here for more details.

flet_video/__init__.py CHANGED
@@ -1,7 +1,8 @@
1
- from flet_video.video import (
1
+ from .types import (
2
2
  PlaylistMode,
3
- Video,
4
3
  VideoConfiguration,
5
4
  VideoMedia,
6
5
  VideoSubtitleConfiguration,
6
+ VideoSubtitleTrack,
7
7
  )
8
+ from .video import Video
flet_video/types.py ADDED
@@ -0,0 +1,168 @@
1
+ from dataclasses import dataclass, field
2
+ from enum import Enum
3
+ from typing import Dict, Optional
4
+
5
+ import flet as ft
6
+
7
+ __all__ = [
8
+ "PlaylistMode",
9
+ "VideoMedia",
10
+ "VideoConfiguration",
11
+ "VideoSubtitleConfiguration",
12
+ "VideoSubtitleTrack",
13
+ ]
14
+
15
+
16
+ class PlaylistMode(Enum):
17
+ """Defines the playback mode for the video playlist."""
18
+
19
+ NONE = "none"
20
+ """End playback once end of the playlist is reached."""
21
+
22
+ SINGLE = "single"
23
+ """Indefinitely loop over the currently playing file in the playlist."""
24
+
25
+ LOOP = "loop"
26
+ """Loop over the playlist & restart it from beginning once end is reached."""
27
+
28
+
29
+ @dataclass
30
+ class VideoMedia:
31
+ """Represents a media resource for video playback."""
32
+
33
+ resource: str
34
+ """URI of the media resource."""
35
+
36
+ http_headers: Optional[Dict[str, str]] = None
37
+ """HTTP headers to be used for the media resource."""
38
+
39
+ extras: Optional[Dict[str, str]] = None
40
+ """Additional metadata for the media resource."""
41
+
42
+
43
+ @dataclass
44
+ class VideoConfiguration:
45
+ """Additional configuration for video playback."""
46
+
47
+ output_driver: Optional[str] = None
48
+ """
49
+ Sets the [--vo](https://mpv.io/manual/stable/#options-vo) property on native backend.
50
+
51
+ The default value is platform dependent:
52
+ - Windows, GNU/Linux, macOS & iOS : `"libmpv"`
53
+ - Android: `"gpu"`
54
+ """
55
+
56
+ hardware_decoding_api: Optional[str] = None
57
+ """
58
+ Sets the [--hwdec](https://mpv.io/manual/stable/#options-hwdec) property on native backend.
59
+
60
+ The default value is platform dependent:
61
+ - Windows, GNU/Linux, macOS & iOS : `"auto"`
62
+ - Android: `"auto-safe"`
63
+ """
64
+
65
+ enable_hardware_acceleration: bool = True
66
+ """
67
+ Whether to enable hardware acceleration.
68
+ When disabled, may cause battery drain, device heating, and high CPU usage.
69
+ """
70
+
71
+ width: Optional[ft.Number] = None
72
+ """
73
+ The fixed width for the video output.
74
+ """
75
+
76
+ height: Optional[ft.Number] = None
77
+ """
78
+ The fixed height for the video output.
79
+ """
80
+
81
+ scale: ft.Number = 1.0
82
+ """
83
+ The scale for the video output.
84
+ Specifying this option will cause `width` & `height` to be ignored.
85
+ """
86
+
87
+
88
+ @dataclass
89
+ class VideoSubtitleTrack:
90
+ """Represents a subtitle track for a video."""
91
+
92
+ src: str
93
+ """
94
+ The subtitle source.
95
+
96
+ Supported values:
97
+ - A URL (e.g. "https://example.com/subs.srt" or "www.example.com/sub.vtt")
98
+ - An absolute local file path (not supported on the web platform)
99
+ - A raw subtitle text string (e.g. the full contents of an SRT/VTT file)
100
+ """
101
+
102
+ title: Optional[str] = None
103
+ """The title of the subtitle track, e.g. 'English'."""
104
+
105
+ language: Optional[str] = None
106
+ """The language of the subtitle track, e.g. 'en'."""
107
+
108
+ channels_count: Optional[int] = None
109
+ channels: Optional[str] = None
110
+ sample_rate: Optional[int] = None
111
+ fps: Optional[ft.Number] = None
112
+ bitrate: Optional[int] = None
113
+ rotate: Optional[int] = None
114
+ par: Optional[ft.Number] = None
115
+ audio_channels: Optional[int] = None
116
+ album_art: Optional[bool] = None
117
+ codec: Optional[str] = None
118
+ decoder: Optional[str] = None
119
+
120
+ @classmethod
121
+ def none(cls) -> "VideoSubtitleTrack":
122
+ """No subtitle track. Disables subtitle output."""
123
+ return VideoSubtitleTrack(src="none")
124
+
125
+ @classmethod
126
+ def auto(cls) -> "VideoSubtitleTrack":
127
+ """Default subtitle track. Selects the first subtitle track."""
128
+ return VideoSubtitleTrack(src="auto")
129
+
130
+
131
+ @dataclass
132
+ class VideoSubtitleConfiguration:
133
+ """Represents the configuration for video subtitles."""
134
+
135
+ text_style: ft.TextStyle = field(
136
+ default_factory=lambda: ft.TextStyle(
137
+ height=1.4,
138
+ size=32.0,
139
+ letter_spacing=0.0,
140
+ word_spacing=0.0,
141
+ color=ft.Colors.WHITE,
142
+ weight=ft.FontWeight.NORMAL,
143
+ bgcolor=ft.Colors.BLACK54,
144
+ )
145
+ )
146
+ """The text style to be used for the subtitles."""
147
+
148
+ text_scale_factor: ft.Number = 1.0
149
+ """
150
+ Defines the scale factor for the subtitle text.
151
+ """
152
+
153
+ text_align: ft.TextAlign = ft.TextAlign.CENTER
154
+ """
155
+ The text alignment to be used for the subtitles.
156
+ """
157
+
158
+ padding: ft.PaddingValue = field(
159
+ default_factory=lambda: ft.Padding(left=16.0, top=0.0, right=16.0, bottom=24.0)
160
+ )
161
+ """
162
+ The padding to be used for the subtitles.
163
+ """
164
+
165
+ visible: bool = True
166
+ """
167
+ Whether the subtitles should be visible or not.
168
+ """