Eisa01 / mpv-scripts

This repository contain scripts I have made for mpv media player...
BSD 2-Clause "Simplified" License
507 stars 35 forks source link

Toggling pause when idle causes error #16

Closed escapezn closed 3 years ago

escapezn commented 3 years ago

When mpv is idle, if pause got touched just by pressing SPACE unconsciously, it will report errors like this

[SimpleUndo]
[SimpleUndo] stack traceback:
[SimpleUndo]    mp.defaults:397: in function 'handler'
[SimpleUndo]    mp.defaults:500: in function 'call_event_handlers'
[SimpleUndo]    mp.defaults:534: in function 'dispatch_events'
[SimpleUndo]    mp.defaults:493: in function <mp.defaults:492>
[SimpleUndo]    [C]: at 0x00f82de0
[SimpleUndo]    [C]: at 0x00f817f0
[SimpleUndo] Lua error: [string ".../mpv/portable_config/..."]:64: attempt to index global 'timer' (a nil value)

I tried editing script, seems working for now

mp.observe_property('pause', 'bool', function(name, value)
    if timer ~= nil then

    if value then
        timer:stop()
        pause = true
    else
        -- if timer ~= nil then
            timer:resume()
        -- end
        pause = false
    end
end
end)

Please check and fix it up, thanks!

Eisa01 commented 3 years ago

Silly mistake from my side. Glad that you caught it fast! Fixed in https://github.com/Eisa01/mpv-scripts/commit/d3c1655237003816edc801333a070e6258932ae1 Now I need to make a new release for most of the scripts, as they will have the same issue =/