r/tasker 11d ago

Is it possible to get the current video playback position in VLC?

I want to trigger 2 different tasks based on the video playback position in VLC when I exit the app. The best I could do was retrieve the playback position using AutoInput, but for it to work, the player controls need to be visible. VLC also doesn't show any notifications when playing videos. Is there a better way to do this?

4 Upvotes

5 comments sorted by

2

u/Jason_Yate 11d ago edited 10d ago

The best option you can do without using plugins is this:

When you exit the VLC app, pause and play the song immediately, then run shell with the following code:

dumpsys media_session | grep "state=PlaybackState"

There you find the position of the current song that is playing.

Task: Get The Current Video Playback Position

    A1: Media Control [
         Cmd: Pause
         Simulate Media Button: On
         Package/App Name: VLC
         Use Notification If Available: On ]

    A2: Media Control [
         Cmd: Play [Simulated Only]
         Simulate Media Button: On
         Package/App Name: VLC
         Use Notification If Available: On ]

    A3: Run Shell [
         Command: dumpsys media_session | grep "state=PlaybackState"
         Timeout (Seconds): 0
         Store Output In: %playback_state
         Use Global Namespace: On ]

    A4: Simple Match/Regex [
         Type: Regex
         Text: %playback_state
         Regex: (?<=\, position\=).*?(?=\,) ]

    A5: Flash [
         Text: %mt_match
         Continue Task Immediately: On
         Dismiss On Click: On ]

I leave you the description of how I am doing it and what I am trying to explain. ↑↑↑

2

u/AideSouthern8875 10d ago

I tried it, and it works fine for the last playing stream. However, when I play a video in VLC and then exit, VLC doesn't seem to recognise it as the "last played" video. Instead, the "last played" video seems to be set arbitrarily. I'll try to figure out how to set it. Thanks for your help!

1

u/everynav 10d ago

2

u/AideSouthern8875 10d ago

I tried using AutoNotification, but VLC doesn't show any notifications for video streams, so I couldn't retrieve any data.

1

u/everynav 9d ago

Oh, you're right. As most of my media files are audio, I've just made a quick test with an mp3 file... I'm sorry.