Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Video.jump_to() fails with negative indexes #4294

Merged
merged 2 commits into from
Nov 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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