Skip to content

Commit

Permalink
fix: Video.jump_to() fails with negative indexes (#4294)
Browse files Browse the repository at this point in the history
* support negative indexes in Video.jump_to()

* deprecate `Video.jump_to_async()` and `seek_async()`` methods
  • Loading branch information
ndonkoHenri authored Nov 4, 2024
1 parent 1d09aef commit 3fa90c4
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions sdk/python/packages/flet/src/flet/core/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,15 +265,31 @@ async def previous_async(self):
def seek(self, position_milliseconds: int):
self.invoke_method("seek", {"position": str(position_milliseconds)})

@deprecated(
reason="Use seek() method instead.",
version="0.25.0",
delete_version="0.28.0",
)
async def seek_async(self, position_milliseconds: int):
await self.invoke_method_async("seek", {"position": str(position_milliseconds)})

def jump_to(self, media_index: int):
assert self.__playlist[media_index], "index out of range"
assert self.__playlist[media_index], "media_index is out of range"
if media_index < 0:
# dart doesn't support negative indexes
media_index = len(self.__playlist) + media_index
self.invoke_method("jump_to", {"media_index": str(media_index)})

@deprecated(
reason="Use jump_to() method instead.",
version="0.25.0",
delete_version="0.28.0",
)
async def jump_to_async(self, media_index: int):
assert self.__playlist[media_index], "index out of range"
assert self.__playlist[media_index], "media_index is out of range"
if media_index < 0:
# dart doesn't support negative indexes
media_index = len(self.__playlist) + media_index
await self.invoke_method_async("jump_to", {"media_index": str(media_index)})

def playlist_add(self, media: VideoMedia):
Expand Down

0 comments on commit 3fa90c4

Please sign in to comment.