-
Notifications
You must be signed in to change notification settings - Fork 2
/
marker.lua
245 lines (183 loc) · 3.84 KB
/
marker.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
-- PLUGIN : MARKER
-- version 1.0
-- By Nimish Sharma and Amit Sharma
-- Lua code was learned from websites such as http://lua.gts-stolberg.de/en/?uml=1 and http://www.lua.org/start.html
k=nil --temporary variable
m=0 --temporary variable
array1={}
array2={}
array3={}
address=nil --temporary variable
function descriptor()
return {
title = "MARKER"
version = "1.0";
author = "Amit-Nimish";
capabilities = {"input-listener"}
}
end
function activate()
inpt = vlc.object.input()
nam = vlc.input.item():name()
address="/Users/sharmanimish55/Downloads/VlcPlugTxt/".. nam ..".txt"
create_dialog(nam)
end
function create_dialog(a)
lp=3
w = vlc.dialog(a)
w:add_label("<h4>EXTENSION</h4>",3,1,4,1)
lst = w:add_list(1,3,5,lp)
p=io.open(address,"r")
if p then
temp_func()
end
w:add_button("START", start_time,1,2+lp)
w:add_button("STOP", stop_time,3,2+lp)
w:add_button("PLAY", play_selected,5,2+lp)
w:add_button("RESET", reset_all,1,3+lp)
w:add_button("PLAYALL", play_all,3,3+lp)
w:add_button("DELETE", delete_selected,5,3+lp)
tb = w:add_text_input("",1,4+lp)
w:add_button("ADD COMMENT", add_note,3,4+lp)
w:add_button("SHOW COMMENT", show_note,5,4+lp)
end
function add_note()
place()
txt = tb:get_text()
t=lst:get_selection()
local item
for id,item in pairs(t) do
m=id
end
array3[m]=txt
file=io.open(address,"w")
file:close()
file=io.open(address,"a")
if file then
k=1
while true do
if array1[k]==nil then break end
file:write(array1[k] .. " " .. array2[k] .. "-" .. array3[k] .. "\n")
k=k+1
end
end
file:close()
lst:clear()
temp_func()
tb:set_text("")
end
function show_note()
t=lst:get_selection()
local item
for id,item in pairs(t) do
m=id
end
tb:set_text(array3[m])
end
function start_time()
tim1 = vlc.var.get(inpt, "time") -- seconds from beginning
end
function stop_time()
tim2 = vlc.var.get(inpt, "time") -- seconds from beginning
file=io.open(address,"a")
if file then
file:write(tim1 .. " " .. tim2 .. "-\n")
end
file:close()
lst:clear()
temp_func()
end
function temp_func()
display()
end
function reset_all()
file=io.open(address,"w")
vlc.var.set(inpt,"time",0)
array1={}
array2={}
array3={}
lst:clear()
end
function play_all()
place()
local k=1
while true do
if array1[k]==nil then break end
vlc.var.set(inpt,"time",array1[k])
os.execute("sleep " .. array2[k]-array1[k])
k=k+1
end
end
function place()
array1={}
array2={}
array3={}
local k1=1
k2=1
i=1
file=io.open(address,"r")
while true do
line = file:read()
if line == nil then break end
k1=string.find(line," ")
k2=string.find(line,"%-")
l=string.len(line)
array1[i]=tonumber(string.sub(line,1,k1))
array2[i]=tonumber(string.sub(line,k1+1,k2-1))
array3[i]=string.sub(line,k2+1,l)
i=i+1
end
file:close()
end
function display()
place()
k=1
f=1
while true do
if array1[k]==nil then
break
end
lst:add_value(array1[k] .. " " .. array2[k],f)
k=k+1
f=f+1
end
end
function play_selected()
place()
local t=lst:get_selection()
local item
for id,item in pairs(t) do
vlc.var.set(inpt,"time",array1[id])
os.execute("sleep " .. array2[id]-array1[id])
end
end
function delete_selected()
local id
place()
local t=lst:get_selection()
local item
for id,item in pairs(t) do
y=id
end
file=io.open(address,"w")
file:close()
file=io.open(address,"a")
if file then
k=1
while true do
if k==y then
k=k+1
end
if array1[k]==nil then
break
end
file:write(array1[k] .. " " .. array2[k] .. "-" .. array3[k] .. "\n")
k=k+1
end
end
file:close()
lst:clear()
temp_func()
end
function deactivate()
end