Descolada / AHK-v2-libraries

Useful libraries for AHK v2
MIT License
78 stars 8 forks source link

Issue when calling session.Position() while video playing in the background. #12

Open mintyknight opened 1 month ago

mintyknight commented 1 month ago

Hi, I recently started to use this wonderful library, specifically the Media lib. Thank you very much for the library. While the video is playing in the background, the value retrieved with session.Position() does not change, until the video is paused. So my current workaround is to pause the video for 1 mil second, then get the current position, and set the next position, then resume playing. Example pasted below.

session := Media.GetCurrentSession() session.Pause() Sleep(1) session.ChangePlaybackPosition(Min(session.Position+5, session.MaxSeekTime)) session.Play()

one way to reproduce the issue, have a YT video playing in the background untouched, then do session.Position() multiple times, you should see it return same value every time.

Descolada commented 1 week ago

I finally had time to look into it and it appears that YouTube in particular doesn't update timeline properties. I tested in Spotify and also Spotify inside Chrome, and there Session.Position updated roughly every 5 seconds and TimelinePropertiesChangedEvent was also called about as often. Unfortunately I don't see a way to force the timeline properties to change other than the method you are currently using.

During testing I also discovered that I had omitted a way to update timeline properties without getting the session again with Media.GetCurrentSession(). I've now fixed that mistake by adding Session.UpdateTimelineProperties() (although it doesn't fix the bug described here.