GithubHelp home page GithubHelp logo

Comments (5)

jcorporation avatar jcorporation commented on August 17, 2024

It should be completely async. I dig into this.

from mympd.

jcorporation avatar jcorporation commented on August 17, 2024

I can not reproduce your issue. I used following script:

mympd.init()
mympd.log(4, "Skript " .. mympd_arguments.nr)
return "Skript " .. mympd_arguments.nr

However I added some code in devel that could fix your issue.

from mympd.

loop333 avatar loop333 commented on August 17, 2024

Yes, with two scripts/triggers, containing only mympd.init() and one api call mympd.api("MYMPD_API_PLAYER_CURRENT_SONG") there is no error. Here are my 2 simple scripts, with which I can reproduce error:

test_init_1.lua:

-- {"order":1,"file":"","version":0,"arguments":["trigger"]}
print("test_init_1 begin")

mympd.init()

local play_state = mympd_state.play_state
local elapsed_time = mympd_state.elapsed_time

if play_state ~= 2 or elapsed_time > 5 then
  print("test_init_1 not playing")
  return "test_init_1 not playing"
end

local rc, result = mympd.api("MYMPD_API_PLAYER_CURRENT_SONG")
if rc ~= 0 then
 print("test_init_1 current song error")
 return "test_init_1 current song error"
end

print("test_init_1", result.uri)

print("test_init_1 end")

return "test_init_1 return"

test_init_2.lua:

-- {"order":1,"file":"","version":0,"arguments":["trigger"]}
print("test_init_2 begin")

function mympd_set_variable(p_key, p_value)
  print("mympd_set_variable " .. p_key .. "=" .. p_value)
  mympd.api("MYMPD_API_SCRIPT_VAR_SET", { key = p_key, value = tostring(p_value) })
end

mympd.init()

local play_state = mympd_state.play_state
local elapsed_time = mympd_state.elapsed_time
local song_pos = mympd_state.song_pos

if play_state ~= 2 or elapsed_time > 5 then
  print("test_init_2 not playing")
  return "test_init_2 not playing"
end

if play_state == 2 and song_pos > 0 and mympd_env.var_playlist_current_playlist then
  print("playing stored playlist " .. song_pos)
  mympd_set_variable("test", song_pos)
end

print("test_init_2 end")

return "test_init_2 return"

of course assuming that mympd_env.var_playlist_current_playlist exists
then script 1 ends with error

I will try devel branch a bit later

from mympd.

loop333 avatar loop333 commented on August 17, 2024

I confirm, on devel branch there is no error with my test scripts and with my real scripts
no_error.log

from mympd.

jcorporation avatar jcorporation commented on August 17, 2024

Great!

from mympd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.