mpv-player / mpv-player/mpv

lua script observe_property playlist returns reason

Open
#10,760 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

meta:feature-request
Dominant language
C
Stars
37k
Forks
3.5k
Avg merge
1d 10h
Merged PRs (30d)
22

Description

Expected behavior of the wanted feature

the playlist property is triggered for a bunch of reasons, listing some: Next file, previous file, add file, remove file, shuffle, and more. And I couldn't find a way to tell them apart.

It would help a lot to if there was a way, perhaps another parameter or field, specifying the reason why the playlist property changed, it could be a new event like end-file. My use case is basically, I want to keep a text file up to date with the playlist currently playing, some of the transformations are quite heavy, and I would like to only update this file when necessary, that is, when the playlist actually changes, basically the remove, add and shuffle events from before. If the reason field was present, I would be able to just filter those out with a simple if.

something like

function on_playlist_change(data)
   if data.reason == "shuffle" or data.reason == "add_file" or data.reason == "remove_file" then
       update();
   end
end
mp.register_event('playlist-change', on_playlist_change)
Alternative behavior of the wanted feature

another solution would be a way to listen to all of those events separetly, like listening for add-file, remove-file, shuffle, etc.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the Lua scripting API for observe_property and the playlist-related events described in the issue. Done means playlist changes expose their reason or provide separate events so scripts can distinguish add, remove, shuffle, and playback navigation without unnecessary updates.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
api, cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.