New option to enable/disable the playback

This commit is contained in:
Tobias Jakobs
2014-12-26 19:14:48 +01:00
parent fde658e499
commit 3cfb2ecfb9

View File

@@ -25,31 +25,38 @@ USAGE
]] ]]
local dt = require "darktable" local dt = require "darktable"
dt.configuration.check_version(...,{2,0,1}) dt.configuration.check_version(...,{2,0,2})
local function playSlideshowMusic(_, old_view, new_view) local function playSlideshowMusic(_, old_view, new_view)
local filename local filename, playMusic
filename = dt.preferences.read("slideshowMusic","SlideshowMusic","string") filename = dt.preferences.read("slideshowMusic","SlideshowMusic","string")
playMusic = dt.preferences.read("slideshowMusic","PlaySlideshowMusic","bool")
if (playMusic) then
local playCommand, stopCommand local playCommand, stopCommand
if (new_view.id == "slideshow") then if (new_view.id == "slideshow") then
playCommand = 'rhythmbox-client --play-uri="'..filename..'"' playCommand = 'rhythmbox-client --play-uri="'..filename..'"'
dt.print_error(playCommand) --dt.print_error(playCommand)
os.execute(playCommand) coroutine.yield("RUN_COMMAND", playCommand)
--coroutine.yield("RUN_COMMAND", playCommand)
else else
stopCommand = "rhythmbox-client --pause" stopCommand = "rhythmbox-client --pause"
dt.print_error(stopCommand) --dt.print_error(stopCommand)
os.execute(stopCommand) coroutine.yield("RUN_COMMAND", stopCommand)
--coroutine.yield("RUN_COMMAND", stopCommand) end
end end
end end
-- Preferences -- Preferences
dt.preferences.register("slideshowMusic", "SlideshowMusic", "file", "Slideshow background music file", "", "") dt.preferences.register("slideshowMusic", "SlideshowMusic", "file", "Slideshow background music file", "", "")
dt.preferences.register("slideshowMusic",
"PlaySlideshowMusic",
"bool",
"Play slideshow background music",
"Plays music with rhythmbox if a slideshow starts",
true)
-- Register -- Register
dt.register_event("view-changed",playSlideshowMusic) dt.register_event("view-changed",playSlideshowMusic)