1
0
Fork 0

Resume playback whenever needed

This commit is contained in:
Casey 2023-10-20 02:41:39 +03:00
parent 2e64a3200f
commit 7d7b03474d
Signed by: hkc
GPG Key ID: F0F6CFE11CDB0960
1 changed files with 17 additions and 10 deletions

View File

@ -282,17 +282,13 @@ local mplayer = {
currentScreen = 2, currentScreen = 2,
} }
local function setupTerminal() for k, v in pairs(mplayer.colors) do
for k, v in pairs(mplayer.colors) do
term.setPaletteColor(v, settings.get("mplayer.colors." .. k)) term.setPaletteColor(v, settings.get("mplayer.colors." .. k))
end
term.setCursorPos(1, 1)
term.setBackgroundColor(mplayer.colors.bg)
term.setTextColor(mplayer.colors.fg)
term.clear()
end end
term.setCursorPos(1, 1)
setupTerminal() term.setBackgroundColor(mplayer.colors.bg)
term.setTextColor(mplayer.colors.fg)
term.clear()
local tw, th = term.getSize() local tw, th = term.getSize()
parallel.waitForAny( parallel.waitForAny(
@ -416,6 +412,11 @@ function()
elseif ev == "tape_removed" then elseif ev == "tape_removed" then
mplayer.songs = {} mplayer.songs = {}
elseif ev == "tape_inserted" then elseif ev == "tape_inserted" then
local seekToAndPlay = nil
if drive.getState() == "PLAYING" then
seekToAndPlay = drive.getPosition()
end
drive.stop() drive.stop()
drive.seek(-drive.getSize()) drive.seek(-drive.getSize())
for i = 1, 48 do for i = 1, 48 do
@ -431,6 +432,12 @@ function()
} }
end end
end end
if seekToAndPlay ~= nil then
drive.seek(-drive.getSize())
drive.seek(seekToAndPlay)
drive.play()
end
elseif ev ~= "timer" then elseif ev ~= "timer" then
if drive.isDummy then if drive.isDummy then
local m = term.redirect(peripheral.wrap("right")) local m = term.redirect(peripheral.wrap("right"))