flet-audio 0.2.0.dev51__py3-none-any.whl → 0.2.0.dev58__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-audio might be problematic. Click here for more details.

flet_audio/__init__.py CHANGED
@@ -4,4 +4,14 @@ from .types import (
4
4
  AudioPositionChangeEvent,
5
5
  AudioState,
6
6
  AudioStateChangeEvent,
7
+ ReleaseMode,
7
8
  )
9
+
10
+ __all__ = [
11
+ "Audio",
12
+ "AudioDurationChangeEvent",
13
+ "AudioPositionChangeEvent",
14
+ "AudioState",
15
+ "AudioStateChangeEvent",
16
+ "ReleaseMode",
17
+ ]
flet_audio/audio.py CHANGED
@@ -20,44 +20,47 @@ class Audio(ft.Service):
20
20
  AssertionError: If both [`src`][(c).] and [`src_base64`][(c).] are `None`.
21
21
 
22
22
  Note:
23
- This control is non-visual and should be added to [`Page.services`][flet.Page.services]
23
+ This control is non-visual and should be added to
24
+ [`Page.services`][flet.Page.services]
24
25
  list before it can be used.
25
26
  """
26
27
 
27
28
  src: Optional[str] = None
28
29
  """
29
- The audio source. Can be a URL or a local [asset file](https://flet.dev/docs/cookbook/assets).
30
+ The audio source.
31
+ Can be a URL or a local [asset file](https://docs.flet.dev/cookbook/assets).
30
32
 
31
33
  Note:
32
- - At least one of `src` or [`src_base64`][..] must be provided,
33
- with `src_base64` having priority if both are provided.
34
- - [Here](https://github.com/bluefireteam/audioplayers/blob/main/troubleshooting.md#supported-formats--encodings)
34
+ - At least one of `src` or [`src_base64`][flet_audio.Audio.src_base64] must be
35
+ provided, with `src_base64` having priority if both are provided.
36
+ - [Here](https://github.com/bluefireteam/audioplayers/blob/main/troubleshooting.md#supported-formats--encodings)
35
37
  is a list of supported audio formats.
36
38
  """
37
39
 
38
40
  src_base64: Optional[str] = None
39
41
  """
40
42
  Defines the contents of audio file encoded in base-64 format.
41
-
43
+
42
44
  Note:
43
- - At least one of [`src`][..] or `src_base64` must be provided,
45
+ - At least one of [`src`][flet_audio.Audio.src] or `src_base64` must be provided,
44
46
  with `src_base64` having priority if both are provided.
45
- - [Here](https://github.com/bluefireteam/audioplayers/blob/main/troubleshooting.md#supported-formats--encodings)
47
+ - [Here](https://github.com/bluefireteam/audioplayers/blob/main/troubleshooting.md#supported-formats--encodings)
46
48
  is a list of supported audio formats.
47
49
  """
48
50
 
49
51
  autoplay: bool = False
50
52
  """
51
53
  Starts playing audio as soon as audio control is added to a page.
52
-
54
+
53
55
  Note:
54
- Autoplay works in desktop, mobile apps and Safari browser, but doesn't work in Chrome/Edge.
56
+ Autoplay works in desktop, mobile apps and Safari browser,
57
+ but doesn't work in Chrome/Edge.
55
58
  """
56
59
 
57
60
  volume: ft.Number = 1.0
58
61
  """
59
62
  Sets the volume (amplitude).
60
- It's value ranges between `0.0` (mute) and `1.0` (maximum volume).
63
+ It's value ranges between `0.0` (mute) and `1.0` (maximum volume).
61
64
  Intermediate values are linearly interpolated.
62
65
  """
63
66
 
@@ -65,20 +68,19 @@ class Audio(ft.Service):
65
68
  """
66
69
  Defines the stereo balance.
67
70
 
68
-
69
- * `-1` - The left channel is at full volume; the right channel is silent.
70
- * `1` - The right channel is at full volume; the left channel is silent.
71
+ * `-1` - The left channel is at full volume; the right channel is silent.
72
+ * `1` - The right channel is at full volume; the left channel is silent.
71
73
  * `0` - Both channels are at the same volume.
72
74
  """
73
75
 
74
76
  playback_rate: ft.Number = 1.0
75
77
  """
76
- Defines the playback rate.
77
-
78
+ Defines the playback rate.
79
+
78
80
  Should ideally be set when creating the constructor.
79
-
80
- Note:
81
- - iOS and macOS have limits between `0.5x` and `2x`.
81
+
82
+ Note:
83
+ - iOS and macOS have limits between `0.5x` and `2x`.
82
84
  - Android SDK version should be 23 or higher.
83
85
  """
84
86
 
@@ -92,27 +94,29 @@ class Audio(ft.Service):
92
94
  Fires when an audio is loaded/buffered.
93
95
  """
94
96
 
95
- on_duration_change: Optional[ft.EventHandler[AudioDurationChangeEvent["Audio"]]] = None
97
+ on_duration_change: Optional[ft.EventHandler[AudioDurationChangeEvent]] = None
96
98
  """
97
- Fires as soon as audio duration is available (it might take a while to download or buffer it).
99
+ Fires as soon as audio duration is available
100
+ (it might take a while to download or buffer it).
98
101
  """
99
102
 
100
- on_state_change: Optional[ft.EventHandler[AudioStateChangeEvent["Audio"]]] = None
103
+ on_state_change: Optional[ft.EventHandler[AudioStateChangeEvent]] = None
101
104
  """
102
105
  Fires when audio player state changes.
103
106
  """
104
107
 
105
- on_position_change: Optional[ft.EventHandler[AudioPositionChangeEvent["Audio"]]] = None
108
+ on_position_change: Optional[ft.EventHandler[AudioPositionChangeEvent]] = None
106
109
  """
107
- Fires when audio position is changed.
108
- Will continuously update the position of the playback every 1 second if the status is playing.
109
-
110
+ Fires when audio position is changed.
111
+ Will continuously update the position of the playback
112
+ every 1 second if the status is playing.
113
+
110
114
  Can be used for a progress bar.
111
115
  """
112
116
 
113
117
  on_seek_complete: Optional[ft.ControlEventHandler["Audio"]] = None
114
118
  """
115
- Fires on seek completions.
119
+ Fires on seek completions.
116
120
  An event is going to be sent as soon as the audio seek is finished.
117
121
  """
118
122
 
@@ -120,20 +124,28 @@ class Audio(ft.Service):
120
124
  super().before_update()
121
125
  assert self.src or self.src_base64, "either src or src_base64 must be provided"
122
126
 
123
- async def play_async(self, position: ft.DurationValue = ft.Duration(), timeout: Optional[float] = 10):
127
+ async def play_async(
128
+ self, position: ft.DurationValue = ft.Duration(), timeout: Optional[float] = 10
129
+ ):
124
130
  """
125
131
  Starts playing audio from the specified `position`.
126
132
 
127
133
  Args:
128
134
  position: The position to start playback from.
129
135
  timeout: The maximum amount of time (in seconds) to wait for a response.
130
-
136
+
131
137
  Raises:
132
138
  TimeoutError: If the request times out.
133
139
  """
134
- await self._invoke_method_async("play", {"position": position}, timeout=timeout)
135
-
136
- def play(self, position: ft.DurationValue = ft.Duration(), timeout: Optional[float] = 10):
140
+ await self._invoke_method_async(
141
+ method_name="play",
142
+ arguments={"position": position},
143
+ timeout=timeout,
144
+ )
145
+
146
+ def play(
147
+ self, position: ft.DurationValue = ft.Duration(), timeout: Optional[float] = 10
148
+ ):
137
149
  """
138
150
  Starts playing audio from the specified `position`.
139
151
 
@@ -150,7 +162,8 @@ class Audio(ft.Service):
150
162
  """
151
163
  Pauses the audio that is currently playing.
152
164
 
153
- If you call [`resume()`][(c).resume] or [`resume_async()`][(c).resume_async] later,
165
+ If you call [`resume()`][flet_audio.Audio.resume] or
166
+ [`resume_async()`][flet_audio.Audio.resume_async] later,
154
167
  the audio will resume from the point that it has been paused.
155
168
  """
156
169
  await self._invoke_method_async("pause", timeout=timeout)
@@ -159,7 +172,8 @@ class Audio(ft.Service):
159
172
  """
160
173
  Pauses the audio that is currently playing.
161
174
 
162
- If you call [`resume()`][(c).resume] or [`resume_async()`][(c).resume_async] later,
175
+ If you call [`resume()`][flet_audio.Audio.resume] or
176
+ [`resume_async()`][flet_audio.Audio.resume_async] later,
163
177
  the audio will resume from the point that it has been paused.
164
178
 
165
179
  Args:
@@ -198,7 +212,8 @@ class Audio(ft.Service):
198
212
  """
199
213
  Releases the resources associated with this media player.
200
214
  These are going to be fetched or buffered again as soon as
201
- you change the source or call [`resume()`][(c).resume] or [`resume_async()`][(c).resume_async].
215
+ you change the source or call [`resume()`][flet_audio.Audio.resume] or
216
+ [`resume_async()`][flet_audio.Audio.resume_async].
202
217
 
203
218
  Args:
204
219
  timeout: The maximum amount of time (in seconds) to wait for a response.
@@ -212,7 +227,8 @@ class Audio(ft.Service):
212
227
  """
213
228
  Releases the resources associated with this media player.
214
229
  These are going to be fetched or buffered again as soon as
215
- you change the source or call [`resume()`][(c).resume] or [`resume_async()`][(c).resume_async].
230
+ you change the source or call [`resume()`][flet_audio.Audio.resume] or
231
+ [`resume_async()`][flet_audio.Audio.resume_async].
216
232
 
217
233
  Args:
218
234
  timeout: The maximum amount of time (in seconds) to wait for a response.
@@ -222,7 +238,9 @@ class Audio(ft.Service):
222
238
  """
223
239
  asyncio.create_task(self.release_async(timeout=timeout))
224
240
 
225
- async def seek_async(self, position: ft.DurationValue, timeout: Optional[float] = 10):
241
+ async def seek_async(
242
+ self, position: ft.DurationValue, timeout: Optional[float] = 10
243
+ ):
226
244
  """
227
245
  Moves the cursor to the desired position.
228
246
 
@@ -233,7 +251,11 @@ class Audio(ft.Service):
233
251
  Raises:
234
252
  TimeoutError: If the request times out.
235
253
  """
236
- await self._invoke_method_async("seek", {"position": position}, timeout=timeout)
254
+ await self._invoke_method_async(
255
+ method_name="seek",
256
+ arguments={"position": position},
257
+ timeout=timeout,
258
+ )
237
259
 
238
260
  def seek(self, position: ft.DurationValue, timeout: Optional[float] = 10):
239
261
  """
@@ -248,7 +270,9 @@ class Audio(ft.Service):
248
270
  """
249
271
  asyncio.create_task(self.seek_async(position, timeout=timeout))
250
272
 
251
- async def get_duration_async(self, timeout: Optional[float] = 10) -> Optional[ft.Duration]:
273
+ async def get_duration_async(
274
+ self, timeout: Optional[float] = 10
275
+ ) -> Optional[ft.Duration]:
252
276
  """
253
277
  Get audio duration of the audio playback.
254
278
 
@@ -264,15 +288,24 @@ class Audio(ft.Service):
264
288
  Raises:
265
289
  TimeoutError: If the request times out.
266
290
  """
267
- return await self._invoke_method_async("get_duration", timeout=timeout)
268
-
269
- async def get_current_position_async(self, timeout: Optional[float] = 10) -> Optional[ft.Duration]:
291
+ return await self._invoke_method_async(
292
+ method_name="get_duration",
293
+ timeout=timeout,
294
+ )
295
+
296
+ async def get_current_position_async(
297
+ self, timeout: Optional[float] = 10
298
+ ) -> Optional[ft.Duration]:
270
299
  """
271
300
  Get the current position of the audio playback.
272
301
 
273
302
  Args:
274
303
  timeout: The maximum amount of time (in seconds) to wait for a response.
304
+
275
305
  Returns:
276
306
  The current position of the audio playback.
277
307
  """
278
- return await self._invoke_method_async("get_current_position", timeout=timeout)
308
+ return await self._invoke_method_async(
309
+ method_name="get_current_position",
310
+ timeout=timeout,
311
+ )
flet_audio/types.py CHANGED
@@ -1,13 +1,17 @@
1
- from dataclasses import dataclass, field
1
+ from dataclasses import dataclass
2
2
  from enum import Enum
3
+ from typing import TYPE_CHECKING
3
4
 
4
5
  import flet as ft
5
6
 
7
+ if TYPE_CHECKING:
8
+ from .audio import Audio # noqa
9
+
6
10
  __all__ = [
11
+ "AudioDurationChangeEvent",
12
+ "AudioPositionChangeEvent",
7
13
  "AudioState",
8
14
  "AudioStateChangeEvent",
9
- "AudioPositionChangeEvent",
10
- "AudioDurationChangeEvent",
11
15
  "ReleaseMode",
12
16
  ]
13
17
 
@@ -21,9 +25,10 @@ class ReleaseMode(Enum):
21
25
 
22
26
  Info:
23
27
  - On Android, the media player is quite resource-intensive, and this will
24
- let it go. Data will be buffered again when needed (if it's a remote file,
25
- it will be downloaded again).
26
- - On iOS and macOS, works just like [`Audio.release()`][(p).Audio.release] method.
28
+ let it go. Data will be buffered again when needed (if it's a remote file,
29
+ it will be downloaded again).
30
+ - On iOS and macOS, works just like [`Audio.release()`][flet_audio.Audio.release]
31
+ method.
27
32
  """
28
33
 
29
34
  LOOP = "loop"
@@ -60,7 +65,7 @@ class AudioState(Enum):
60
65
 
61
66
 
62
67
  @dataclass
63
- class AudioStateChangeEvent(ft.Event[ft.EventControlType]):
68
+ class AudioStateChangeEvent(ft.Event["Audio"]):
64
69
  """
65
70
  Event triggered when the audio playback state changes.
66
71
  """
@@ -70,7 +75,7 @@ class AudioStateChangeEvent(ft.Event[ft.EventControlType]):
70
75
 
71
76
 
72
77
  @dataclass
73
- class AudioPositionChangeEvent(ft.Event[ft.EventControlType]):
78
+ class AudioPositionChangeEvent(ft.Event["Audio"]):
74
79
  """
75
80
  Event triggered when the audio playback position changes.
76
81
  """
@@ -80,7 +85,7 @@ class AudioPositionChangeEvent(ft.Event[ft.EventControlType]):
80
85
 
81
86
 
82
87
  @dataclass
83
- class AudioDurationChangeEvent(ft.Event[ft.EventControlType]):
88
+ class AudioDurationChangeEvent(ft.Event["Audio"]):
84
89
  """
85
90
  Event triggered when the audio duration changes.
86
91
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flet-audio
3
- Version: 0.2.0.dev51
3
+ Version: 0.2.0.dev58
4
4
  Summary: Eases audio integration and playback in Flet apps.
5
5
  Author-email: Flet contributors <hello@flet.dev>
6
6
  License-Expression: Apache-2.0
@@ -1,18 +1,18 @@
1
- flet_audio/__init__.py,sha256=aLfmcJXT-xQPy6DAn-jQCh0fXRk5ji96Fg15PL5lo0E,151
2
- flet_audio/audio.py,sha256=IaJ_nIp410ClXFZRTlhwOLvQv9xv2heuQikCjeXeNig,9444
3
- flet_audio/types.py,sha256=YJ_RYQanID06LZ8q3APHcM7QBielawXNo5ft8Zi0VKw,2257
4
- flet_audio-0.2.0.dev51.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
1
+ flet_audio/__init__.py,sha256=6uWGMdSCJYudjp3naJzcbM89EcupsJ2De2J9rmDV0ME,326
2
+ flet_audio/audio.py,sha256=a_APLvecPmJMtAsiMIcfX8Ctoo8r3A1OPVZjZ8KpB0A,9885
3
+ flet_audio/types.py,sha256=ZxjM1LSKQospbvv9qrcwnpmka0tFtva_4M38prn9GdI,2330
4
+ flet_audio-0.2.0.dev58.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
5
5
  flutter/flet_audio/CHANGELOG.md,sha256=66sWepPaeTc9_lzcYIGU55AlxSU5Z1XVtknXpzd_-p8,40
6
6
  flutter/flet_audio/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
7
7
  flutter/flet_audio/README.md,sha256=BEITqZ4okarTGCquI4ii6tdffGm2qyxMkMZbsedCwLQ,60
8
8
  flutter/flet_audio/analysis_options.yaml,sha256=32kjGAc-zF87inWaH5M46yGZWQDTwrwfvNLHeAocfG4,154
9
- flutter/flet_audio/pubspec.lock,sha256=Rje88uBW7vkOXea40g_LPnX_P5pFO1r-3gE_5X3Mris,25471
10
- flutter/flet_audio/pubspec.yaml,sha256=_lJ8tH_SgiuDKkYdpHOlzPYqNguX5mMlaEfZJbz_KFg,510
9
+ flutter/flet_audio/pubspec.lock,sha256=BxIAyK5slzN4RTADs8Byq6oa5UkSTu6Bijzse0WRh08,25471
10
+ flutter/flet_audio/pubspec.yaml,sha256=AzhTbc7Ccloq9APOXFIgTgkPSivh_g1ONnzKpv-zf3M,510
11
11
  flutter/flet_audio/lib/flet_audio.dart,sha256=JsHEW9Gic_011jhKpnn278pi1kiWjp9gUjfNF5rWmXs,65
12
12
  flutter/flet_audio/lib/src/audio.dart,sha256=ExGoAU9pIlR5z6ptVDXRMhD5NktkBljN9OgRy5InfIw,5108
13
13
  flutter/flet_audio/lib/src/extension.dart,sha256=okI-bxwSUB9FwgJ7TmiiHcE5yi5z66Yp1ri--V1wVnw,299
14
14
  flutter/flet_audio/lib/src/utils/audio.dart,sha256=Rpbf7xJkNB3xtwrfmXru1t2k3_TgPEnh3Ws6i_2J0EQ,346
15
- flet_audio-0.2.0.dev51.dist-info/METADATA,sha256=lxqKNt7Aj8VEWIAyF6ub3_0DIkyjcBhHfvwyG05_Zoo,1935
16
- flet_audio-0.2.0.dev51.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
17
- flet_audio-0.2.0.dev51.dist-info/top_level.txt,sha256=hZbGOXppSiKRUWJf1ZRlBKMyfijq6Y-8DffGOh10Wq4,19
18
- flet_audio-0.2.0.dev51.dist-info/RECORD,,
15
+ flet_audio-0.2.0.dev58.dist-info/METADATA,sha256=4K69ubpkH1-Us0OT6aKbstliBPfFl2K3-hZQUalyCsU,1935
16
+ flet_audio-0.2.0.dev58.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
17
+ flet_audio-0.2.0.dev58.dist-info/top_level.txt,sha256=hZbGOXppSiKRUWJf1ZRlBKMyfijq6Y-8DffGOh10Wq4,19
18
+ flet_audio-0.2.0.dev58.dist-info/RECORD,,
@@ -190,7 +190,7 @@ packages:
190
190
  description:
191
191
  path: "packages/flet"
192
192
  ref: main
193
- resolved-ref: b996d06ff462b88f5b31d6cceafac34ea6f57968
193
+ resolved-ref: cf8823c5d766ea7866480986aa3ee871f4091e78
194
194
  url: "https://github.com/flet-dev/flet.git"
195
195
  source: git
196
196
  version: "0.70.0"
@@ -211,10 +211,10 @@ packages:
211
211
  dependency: "direct dev"
212
212
  description:
213
213
  name: flutter_lints
214
- sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04
214
+ sha256: "9e8c3858111da373efc5aa341de011d9bd23e2c5c5e0c62bccf32438e192d7b1"
215
215
  url: "https://pub.dev"
216
216
  source: hosted
217
- version: "2.0.3"
217
+ version: "3.0.2"
218
218
  flutter_localizations:
219
219
  dependency: transitive
220
220
  description: flutter
@@ -322,10 +322,10 @@ packages:
322
322
  dependency: transitive
323
323
  description:
324
324
  name: lints
325
- sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452"
325
+ sha256: cbf8d4b858bb0134ef3ef87841abdf8d63bfc255c266b7bf6b39daa1085c4290
326
326
  url: "https://pub.dev"
327
327
  source: hosted
328
- version: "2.1.1"
328
+ version: "3.0.0"
329
329
  logging:
330
330
  dependency: transitive
331
331
  description:
@@ -823,10 +823,10 @@ packages:
823
823
  dependency: transitive
824
824
  description:
825
825
  name: window_manager
826
- sha256: "51d50168ab267d344b975b15390426b1243600d436770d3f13de67e55b05ec16"
826
+ sha256: "7eb6d6c4164ec08e1bf978d6e733f3cebe792e2a23fb07cbca25c2872bfdbdcd"
827
827
  url: "https://pub.dev"
828
828
  source: hosted
829
- version: "0.5.0"
829
+ version: "0.5.1"
830
830
  window_to_front:
831
831
  dependency: transitive
832
832
  description:
@@ -20,4 +20,4 @@ dependencies:
20
20
  dev_dependencies:
21
21
  flutter_test:
22
22
  sdk: flutter
23
- flutter_lints: ^2.0.0
23
+ flutter_lints: ^3.0.0