Pause and save text from dialog

Discuss your Lua playlist, album art and interface scripts.
missnpm
New Cone
New Cone
Posts: 1
Joined: 18 Nov 2022 06:07

Pause and save text from dialog

Postby missnpm » 18 Nov 2022 06:23

Hello. I am trying to work on extensions that:
1. let user input text/label whenever they hit pause, and time is recorded
2. user can enter text which will be saved
3. all input and time will be saved to csv file as logs,

I used this code 5 years ago, I remember it worked well, but now that I want to re-use it, I am not sure why it won't work.
Now the code works only until displaying dialog box asking whether to record or not in show_ui function, but after I click yes, it does not work as it supposed to.

Any input is appreciated. Thanks!

Code: Select all

function descriptor() return { title = "Pause to Save", version = "0.1" ; capabilities = { "playing-listener" } } end function activate() input = "" stringTime = "" fileCreated = false local item = vlc.input.item() if not (item==nil) then create_file() end end function deactivate() end function meta_changed() end function playing_changed() vlc.msg.dbg("[Dummy] Status: " .. vlc.playlist.status()) if vlc.playlist.status()=="playing" then if not fileCreated then create_file() end end if vlc.playlist.status()=="paused" then show_ui() end if vlc.playlist.status()=="stopped" then close_file() end end function show_ui() d = vlc.dialog("Record?") d:set_title("Record?") d:add_button("Yes", log) d:add_button("No", hide_ui) d:show() end function log() d:delete() d = vlc.dialog("Enter Label") d: set_title("Enter Label: ") w = d:add_text_input(text) w1 = d:add_button("Save Label", getText) end function getText() input = w:get_text(text) --vlc.msg.dbg("Time: " .. input) write_to_file() d:delete() end function hide_ui() d:delete() end function write_to_file() if not fileCreated then create_file() end file:write(""..timest .. ":" .. input .. "\n") --vlc.msg.dbg("Output time = " .. timest) end function close_file() file:write("\n") file:close() fileCreated = false end function create_file() vlc.msg.dbg("in createFile") fileCreated = true get_time() file = io.open("C:\\Users\\Users\\Documents\\VideoLogs\\" .. os.date("%m-%d-%Y", time) .. "_log.txt","a+") file:write("Annotated on: " .. os.date() .. "\n------------------------------------------------\n\n") end function get_time() vid = vlc.input.item() obj = vlc.object.input() name = vid:name() timeList = {month=name:sub(9,10) , day=name:sub(11,12), year=name:sub(5,8), hour=name:sub(14,15), min=name:sub(16,17), sec = name:sub(18,19)} time = os.time(timeList) currentTime = time + vlc.var.get(obj, "time") timestr = os.date("%H:%M:%S", currentTime) vlc.msg.dbg("Time = " .. timestr) return timestr end

mederi
Big Cone-huna
Big Cone-huna
Posts: 1951
Joined: 15 Mar 2011 16:38
VLC version: 2.0.8
Operating System: Windows Vista/XP

Re: Pause and save text from dialog

Postby mederi » 20 Nov 2022 21:13

73> timest?


Return to “Scripting VLC in lua”

Who is online

Users browsing this forum: No registered users and 5 guests