我在互联网上搜索过这个,但似乎找不到任何东西。我知道有几个热键可以跳过几秒钟,我知道有些热键可以在VLC Media Player中暂停和播放音频/视频。但是,我使用单脚踏板进行转录,基本上需要它来做两者。我想让踏板水龙头暂停音频。然后,再次点击后,我希望它播放音频,但在这样做时跳过几秒钟。这可能吗?
答案 0 :(得分:0)
将此代码另存为rollback.lua
,并将其放置在Program Files\VideoLAN\VLC\lua\extensions
文件夹中。然后通过查看>回滚X秒激活它。
function descriptor()
return {
title = "Rollback X Seconds",
capabilities = {"input-listener", "playing-listener"}
}
end
function activate()
end
function close()
end
function deactivate()
end
function input_changed()
end
function playing_changed()
local TIME_DELTA = -3
if vlc.playlist.status()=="paused" then
local timePassed = vlc.var.get(vlc.object.input(), "time")
local newTime = timePassed + TIME_DELTA
vlc.osd.message(TIME_DELTA, vlc.osd.channel_register(), "top-left", 1400000)
vlc.var.set(vlc.object.input(), "time", newTime)
end
end
将变量TIME_DELTA
更改为您希望在暂停时进行的任何时间更改
答案 1 :(得分:0)
我通过添加GUI在code提供的Tee上进行了扩展。
我还想补充一些如何使其工作的细节。
为了使您的踏板可以使用此脚本,只需在VLC中配置热键即可进行播放/暂停切换。
VLC>工具>首选项>热键>将“播放/暂停”全局值设置为您的踏板。
(更改全局热键后,需要重新启动VLC才能使其正常工作...)
代码:
micro_second_unit = 1000000
TIME_DELTA = 1 --Default,
SHOW_OUTPUT = true
TIME_TO_DISPLAY = 1.5 --Default
function descriptor()
return {
title = "Rollback X Seconds",
capabilities = {"input-listener", "playing-listener"}
}
end
function activate()
dlg = vlc.dialog("Rollback X Seconds")
rollback_input = dlg:add_text_input("1", 2, 1 )
rollback_input_label = dlg:add_label("Seconds to back", 1, 1)
checkBox = dlg:add_check_box("Show output time ", wasChecked, 3, 3 )
timeTo_display_box = dlg:add_text_input(1.5, 2 ,3)
timeTo_display_box_label = dlg:add_label("Seconds To Display", 1, 3)
w2 = dlg:add_button("Save settings", change_step, 3, 4, 1, 1)
w2 = dlg:add_button("Save and close", updateAndClose, 3, 5, 1, 1)
done = dlg:add_label( "" , 3, 6)
end
function close()
end
function deactivate()
vlc.deactivate()
end
function input_changed()
end
function playing_changed()
if vlc.playlist.status()=="paused" then
local timePassed = tonumber(vlc.var.get(vlc.object.input(), "time"))
local newTime = timePassed - seconds_to_microsecond(TIME_DELTA)
local newTime_inSeconds = (newTime/1000000)
local newTime_inMinutes = (newTime_inSeconds/60)
local newTime_inSeconds_restOfMin = math.fmod(newTime_inSeconds,60)
local newTime_str = math.floor(newTime_inMinutes) .. "min " .. round(newTime_inSeconds_restOfMin,1) .."sec"
local timePassed_inSeconds = (timePassed/1000000)
local timePassed_inMinutes = (timePassed_inSeconds/60)
local timePassed_inSeconds_restOfMin = math.fmod(timePassed_inSeconds,60)
local timePassed_str = math.floor(timePassed_inMinutes) .. "min " .. round(timePassed_inSeconds_restOfMin,1) .."sec"
if SHOW_OUTPUT == true then
vlc.osd.message("Seconds to Back:" .. TIME_DELTA .. "sec", vlc.osd.channel_register(), "top-right", seconds_to_microsecond(TIME_TO_DISPLAY))
vlc.osd.message("New time:" .. newTime_str, vlc.osd.channel_register(), "top-left", seconds_to_microsecond(TIME_TO_DISPLAY))
vlc.osd.message("Old time:" .. timePassed_str, vlc.osd.channel_register(), "bottom-left", seconds_to_microsecond(TIME_TO_DISPLAY))
end
vlc.var.set(vlc.object.input(), "time", newTime)
end
end
function updateAndClose()
change_step()
dlg:delete()
end
function change_step()
done:set_text("Saved")
TIME_DELTA = tonumber(rollback_input:get_text())
SHOW_OUTPUT = checkBox:get_checked()
if SHOW_OUTPUT == true then
TIME_TO_DISPLAY = tonumber(timeTo_display_box:get_text())
end
end
function round(num, numDecimalPlaces)
local mult = 10^(numDecimalPlaces or 0)
return math.floor(num * mult + 0.5) / mult
end
function microsecond_to_seconds(timeToConvert)
return timeToConvert / micro_second_unit;
end
function seconds_to_microsecond(timeToConvert)
return timeToConvert * micro_second_unit;
end
这将与Tee的脚本一样工作,每次暂停时视频都会跳回。
唯一的区别是您可以设置每次启动脚本后跳回的时间。
数量以秒为单位,但是您可以使用小数来进行更多控制...
如果要显示有关跳转的信息,还可以勾选一个复选框。
我也要感谢Tee的回答!
这是我编写的第一个lua代码(或者更确切地说,是经过修改的),虽然有点杂乱,但是它确实有效,而且我每天都在使用它,所以我想我也应该分享一下。