From e28c92c3d4f0a71cc4bbe7b5384e80220df5a200 Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Fri, 23 May 2025 18:11:46 -0400 Subject: [PATCH] Show videos watch progress in playlist view --- CHANGELOG.md | 6 ++++++ .../src/components/PlaylistView/PlaylistViewCell.bs | 13 +++++++++++++ .../components/PlaylistView/PlaylistViewCell.xml | 9 +++++++++ 3 files changed, 28 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 43509e74..1da5ab37 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Fixed + +- Show videos watch progress in playlist view + ## [0.39.1] - 2025-05-23 ### Fixed diff --git a/playlet-lib/src/components/PlaylistView/PlaylistViewCell.bs b/playlet-lib/src/components/PlaylistView/PlaylistViewCell.bs index fd8d8c2c..f2f98e26 100644 --- a/playlet-lib/src/components/PlaylistView/PlaylistViewCell.bs +++ b/playlet-lib/src/components/PlaylistView/PlaylistViewCell.bs @@ -1,3 +1,4 @@ +import "pkg:/source/utils/MathUtils.bs" import "pkg:/source/utils/StringUtils.bs" import "pkg:/source/utils/TimeUtils.bs" import "pkg:/source/utils/Types.bs" @@ -5,6 +6,7 @@ import "pkg:/source/utils/Types.bs" function Init() m.durationRect = m.top.FindNode("durationRect") m.durationLabel = m.top.FindNode("durationLabel") + m.progressRect = m.top.FindNode("progressRect") end function function OnContentSet() as void @@ -35,6 +37,8 @@ function OnContentSet() as void m.top.thumbnailUri = content.thumbnail + m.top.percentDurationWatched = content.percentDurationWatched + SetDurationText(content.lengthText) end function @@ -60,3 +64,12 @@ function SetDurationText(text as string) as void rect.width = size.width + 16 rect.translation = [rectParent.width - rect.width, rect.translation[1]] end function + +function OnPercentDurationWatched() as void + if m.progressRect = invalid + return + end if + + percent = MathUtils.Clamp(m.top.percentDurationWatched, 0, 100) / 100.0 + m.progressRect.scale = [percent, 1] +end function diff --git a/playlet-lib/src/components/PlaylistView/PlaylistViewCell.xml b/playlet-lib/src/components/PlaylistView/PlaylistViewCell.xml index 8c5f2c22..eab3988a 100644 --- a/playlet-lib/src/components/PlaylistView/PlaylistViewCell.xml +++ b/playlet-lib/src/components/PlaylistView/PlaylistViewCell.xml @@ -6,6 +6,7 @@ + + +