Advertisement
Guest User

main.lua (custom)

a guest
Mar 27th, 2022
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 44.21 KB | None | 0 0
  1. --[[ *************************************************************
  2. * Menu defintions and script-message registration
  3. * Thomas Carmichael (carmanaught) https://gitlab.com/carmanaught
  4. *
  5. * Used in concert with menu-builder.lua to create a menu. The script-message registration
  6. * and calling of the createMenu script are done from the definitions here as trying to
  7. * pass the menu definitions to the menu builder with the script-message register there
  8. * doesn't allow for the unloaded/loaded state to work propertly.
  9. *
  10. * Specify the menu type in the createMenu function call below. Current options are:
  11. * tk
  12. *
  13. * 2017-08-04 - Version 0.1 - Separation of menu building from definitions.
  14. * 2017-08-07 - Version 0.2 - Added second mp.register_script_message and changed original
  15. * to allow the use of different menu types by using the related
  16. * script-message name.
  17. * 2020-06-19 - Version 0.3 - Add script directory detection for mpv 0.32. Change video-aspect
  18. * to video-aspect-override due to deprecation.
  19. * 2020-11-28 - Version 0.4 - Remove script directory detection added for mpv 0.32.0. Change
  20. * filename to support mpv 0.33.0 script folders and move
  21. * menu script files into 'mpvcontextmenu' folder. Also pull in the
  22. * gui-dialogs.lua here so that all script files are kept in the new
  23. * script directory.
  24. * 2021-05-29 - Version 0.5 - Add file_loaded_menu value to help with showing menu when the
  25. * pseudo-gui is being used.
  26. *
  27. ***************************************************************
  28. --]]
  29.  
  30. local guiDialogs = require "gui-dialogs"
  31.  
  32. local langcodes = require "langcodes"
  33. local function mpdebug(x) mp.msg.info(x) end
  34. local propNative = mp.get_property_native
  35.  
  36. -- Set options
  37. local options = require "mp.options"
  38. local opt = {
  39. -- Play > Speed - Percentage
  40. playSpeed = 5,
  41. -- Play > Seek - Seconds
  42. seekSmall = 5,
  43. seekMedium = 30,
  44. seekLarge = 60,
  45. -- Video > Aspect - Percentage
  46. vidAspect = 0.1,
  47. -- Video > Zoom - Percentage
  48. vidZoom = 0.1,
  49. -- Video > Screen Position - Percentage
  50. vidPos = 0.1,
  51. -- Video > Color - Percentage
  52. vidColor = 1,
  53. -- Audio > Sync - Milliseconds
  54. audSync = 100,
  55. -- Audio > Volume - Percentage
  56. audVol = 2,
  57. -- Subtitle > Position - Percentage
  58. subPos = 1,
  59. -- Subtitle > Scale - Percentage
  60. subScale = 1,
  61. -- Subtitle > Sync
  62. subSync = 100, -- Milliseconds
  63. }
  64. options.read_options(opt)
  65.  
  66. -- Set some constant values
  67. local SEP = "separator"
  68. local CASCADE = "cascade"
  69. local COMMAND = "command"
  70. local CHECK = "checkbutton"
  71. local RADIO = "radiobutton"
  72. local AB = "ab-button"
  73.  
  74. local function round(num, numDecimalPlaces)
  75. return tonumber(string.format("%." .. (numDecimalPlaces or 0) .. "f", num))
  76. end
  77.  
  78. -- Edition menu functions
  79. local function enableEdition()
  80. local editionState = false
  81. if (propNative("edition-list/count") < 1) then editionState = true end
  82. return editionState
  83. end
  84.  
  85. local function checkEdition(editionNum)
  86. local editionEnable, editionCur = false, propNative("edition")
  87. if (editionNum == editionCur) then editionEnable = true end
  88. return editionEnable
  89. end
  90.  
  91. local function editionMenu()
  92. local editionCount = propNative("edition-list/count")
  93. local editionMenuVal = {}
  94.  
  95. if not (editionCount == 0) then
  96. for editionNum=0, (editionCount - 1), 1 do
  97. local editionTitle = propNative("edition-list/" .. editionNum .. "/title")
  98. if not (editionTitle) then editionTitle = "Edition " .. (editionNum + 1) end
  99.  
  100. local editionCommand = "set edition " .. editionNum
  101. table.insert(editionMenuVal, {RADIO, editionTitle, "", editionCommand, function() return checkEdition(editionNum) end, false, true})
  102. end
  103. else
  104. table.insert(editionMenuVal, {COMMAND, "No Editions", "", "", "", true})
  105. end
  106.  
  107. return editionMenuVal
  108. end
  109.  
  110. -- Chapter menu functions
  111. local function enableChapter()
  112. local chapterEnable = false
  113. if (propNative("chapter-list/count") < 1) then chapterEnable = true end
  114. return chapterEnable
  115. end
  116.  
  117. local function checkChapter(chapterNum)
  118. local chapterState, chapterCur = false, propNative("chapter")
  119. if (chapterNum == chapterCur) then chapterState = true end
  120. return chapterState
  121. end
  122.  
  123. local function chapterMenu()
  124. local chapterCount = propNative("chapter-list/count")
  125. local chapterMenuVal = {}
  126.  
  127. chapterMenuVal = {
  128. {COMMAND, "Previous", "PgUp", "no-osd add chapter -1", "", false, true},
  129. {COMMAND, "Next", "PgDown", "no-osd add chapter 1", "", false, true},
  130. }
  131. if not (chapterCount == 0) then
  132. for chapterNum=0, (chapterCount - 1), 1 do
  133. local chapterTitle = propNative("chapter-list/" .. chapterNum .. "/title")
  134. if not (chapterTitle) then chapterTitle = "Chapter " .. (chapterNum + 1) end
  135.  
  136. local chapterCommand = "set chapter " .. chapterNum
  137. if (chapterNum == 0) then table.insert(chapterMenuVal, {SEP}) end
  138. table.insert(chapterMenuVal, {RADIO, chapterTitle, "", chapterCommand, function() return checkChapter(chapterNum) end, false, true})
  139. end
  140. end
  141.  
  142. return chapterMenuVal
  143. end
  144.  
  145. -- Track type count function to iterate through the track-list and get the number of
  146. -- tracks of the type specified. Types are: video / audio / sub. This actually
  147. -- returns a table of track numbers of the given type so that the track-list/N/
  148. -- properties can be obtained.
  149.  
  150. local function trackCount(checkType)
  151. local tracksCount = propNative("track-list/count")
  152. local trackCountVal = {}
  153.  
  154. if not (tracksCount < 1) then
  155. for i = 0, (tracksCount - 1), 1 do
  156. local trackType = propNative("track-list/" .. i .. "/type")
  157. if (trackType == checkType) then table.insert(trackCountVal, i) end
  158. end
  159. end
  160.  
  161. return trackCountVal
  162. end
  163.  
  164. -- Track check function, to check if a track is selected. This isn't specific to a set
  165. -- track type and can be used for the video/audio/sub tracks, since they're all part
  166. -- of the track-list.
  167.  
  168. local function checkTrack(trackNum)
  169. local trackState, trackCur = false, propNative("track-list/" .. trackNum .. "/selected")
  170. if (trackCur == true) then trackState = true end
  171. return trackState
  172. end
  173.  
  174. -- Video > Track menu functions
  175. local function enableVidTrack()
  176. local vidTrackEnable, vidTracks = false, trackCount("video")
  177. if (#vidTracks < 1) then vidTrackEnable = true end
  178. return vidTrackEnable
  179. end
  180.  
  181. local function vidTrackMenu()
  182. local vidTrackMenuVal, vidTrackCount = {}, trackCount("video")
  183.  
  184. if not (#vidTrackCount == 0) then
  185. for i = 1, #vidTrackCount, 1 do
  186. local vidTrackNum = vidTrackCount[i]
  187. local vidTrackID = propNative("track-list/" .. vidTrackNum .. "/id")
  188. local vidTrackTitle = propNative("track-list/" .. vidTrackNum .. "/title")
  189. if not (vidTrackTitle) then vidTrackTitle = "Video Track " .. i end
  190.  
  191. local vidTrackCommand = "set vid " .. vidTrackID
  192. table.insert(vidTrackMenuVal, {RADIO, vidTrackTitle, "", vidTrackCommand, function() return checkTrack(vidTrackNum) end, false, true})
  193. end
  194. else
  195. table.insert(vidTrackMenuVal, {RADIO, "No Video Tracks", "", "", "", true})
  196. end
  197.  
  198. return vidTrackMenuVal
  199. end
  200.  
  201. -- Convert ISO 639-1/639-2 codes to be full length language names. The full length names
  202. -- are obtained by using the property accessor with the iso639_1/_2 tables stored in
  203. -- the langcodes.lua file (require "langcodes" above).
  204. function getLang(trackLang)
  205. trackLang = string.upper(trackLang)
  206. if (string.len(trackLang) == 2) then trackLang = langcodes.iso639_1(trackLang)
  207. elseif (string.len(trackLang) == 3) then trackLang = langcodes.iso639_2(trackLang) end
  208. return trackLang
  209. end
  210.  
  211. function noneCheck(checkType)
  212. local checkVal, trackID = false, propNative(checkType)
  213. if (type(trackID) == "boolean") then
  214. if (trackID == false) then checkVal = true end
  215. end
  216. return checkVal
  217. end
  218.  
  219. -- Audio > Track menu functions
  220. local function audTrackMenu()
  221. local audTrackMenuVal, audTrackCount = {}, trackCount("audio")
  222.  
  223. audTrackMenuVal = {
  224. --{COMMAND, "Open File", "", "script-binding add_audio_dialog", "", false},
  225. --{COMMAND, "Reload File", "", "audio-reload", "", false},
  226. --{COMMAND, "Remove", "", "audio-remove", "", false},
  227. --{SEP},
  228. --{COMMAND, "Select Next", "Ctrl+A", "cycle audio", "", false, true},
  229. }
  230. if not (#audTrackCount == 0) then
  231. for i = 1, (#audTrackCount), 1 do
  232. local audTrackNum = audTrackCount[i]
  233. local audTrackID = propNative("track-list/" .. audTrackNum .. "/id")
  234. local audTrackTitle = propNative("track-list/" .. audTrackNum .. "/title")
  235. local audTrackLang = propNative("track-list/" .. audTrackNum .. "/lang")
  236. -- Convert ISO 639-1/2 codes
  237. if not (audTrackLang == nil) then audTrackLang = getLang(audTrackLang) and getLang(audTrackLang) or audTrackLang end
  238.  
  239. --if (audTrackTitle) then audTrackTitle = audTrackTitle .. ((audTrackLang ~= nil) and " (" .. audTrackLang .. ")" or "")
  240. local isext = propNative("track-list/" .. audTrackNum .. "/external")
  241. local isext2 = ""
  242. --if isext == true then isext2 = " (ext)" end
  243. if isext == true then isext2 = ", (ext)" end
  244. --local showcodec = "unknown"
  245. local showcodec = mp.get_property("current-tracks/audio/codec")
  246. local showchannels = mp.get_property('current-tracks/audio/demux-channel-count') .. "ch"
  247. if (audTrackTitle) then audTrackTitle = audTrackTitle .. ((audTrackLang ~= nil) and " (" .. audTrackLang .. ")" or "") .. ": " .. showcodec .. ", " .. showchannels .. isext2
  248. elseif (audTrackLang) then audTrackTitle = ((audTrackLang ~= nil) and " (" .. audTrackLang .. ")" or "") .. ": " .. showcodec .. ", " .. showchannels .. isext2
  249. --else audTrackTitle = "Audio Track " .. i end
  250. else audTrackTitle = ((audTrackLang ~= nil) and " (" .. audTrackLang .. ")" or "") .. ": " .. showcodec .. ", " .. showchannels .. isext2 end
  251.  
  252. local audTrackCommand = "set aid " .. audTrackID
  253. if (i == 1) then
  254. --table.insert(audTrackMenuVal, {SEP})
  255. table.insert(audTrackMenuVal, {RADIO, "Select None", "", "set aid 0", function() return noneCheck("aid") end, false, true})
  256. table.insert(audTrackMenuVal, {SEP})
  257. end
  258. table.insert(audTrackMenuVal, {RADIO, audTrackTitle, "", audTrackCommand, function() return checkTrack(audTrackNum) end, false, true})
  259. end
  260. end
  261.  
  262. return audTrackMenuVal
  263. end
  264.  
  265. -- Subtitle label
  266. local function subVisLabel() return propNative("sub-visibility") and "Hide" or "Un-hide" end
  267.  
  268. -- Subtitle > Track menu functions
  269.  
  270. local function subTrackMenu()
  271. local subTrackMenuVal, subTrackCount = {}, trackCount("sub")
  272.  
  273. subTrackMenuVal = {
  274. --{COMMAND, "Open File", "(Shift+F)", "script-binding add_subtitle_dialog", "", false},
  275. --{COMMAND, "Reload File", "", "sub-reload", "", false},
  276. --{COMMAND, "Clear File", "", "sub-remove", "", false},
  277. --{SEP},
  278. --{COMMAND, "Select Next", "Shift+N", "cycle sub", "", false, true},
  279. --{COMMAND, "Select Previous", "Ctrl+Shift+N", "cycle sub down", "", false, true},
  280. --{CHECK, function() return subVisLabel() end, "V", "cycle sub-visibility", function() return not propNative("sub-visibility") end, false, true},
  281. }
  282. if not (#subTrackCount == 0) then
  283. for i = 1, (#subTrackCount), 1 do
  284. local subTrackNum = subTrackCount[i]
  285. local subTrackID = propNative("track-list/" .. subTrackNum .. "/id")
  286. local subTrackTitle = propNative("track-list/" .. subTrackNum .. "/title")
  287. local subTrackLang = propNative("track-list/" .. subTrackNum .. "/lang")
  288. -- Convert ISO 639-1/2 codes
  289. if not (subTrackLang == nil) then subTrackLang = getLang(subTrackLang) and getLang(subTrackLang) or subTrackLang end
  290.  
  291. --if (subTrackTitle) then subTrackTitle = subTrackTitle .. ((subTrackLang ~= nil) and " (" .. subTrackLang .. ")" or "")
  292. local isextsub = propNative("track-list/" .. subTrackNum .. "/external")
  293. local isextsub2 = ""
  294. if isextsub == true then isextsub2 = ", (ext)" end
  295. --local showcodecsub = mp.get_property("current-tracks/sub/codec")
  296. local showcodecsub = propNative("track-list/" .. subTrackNum .. "/codec")
  297. local subTrackTitle = ""
  298. --if (subTrackTitle) then subTrackTitle = subTrackTitle .. ((subTrackLang ~= nil) and " (" .. subTrackLang .. ")" or "") .. ": " .. showcodecsub .. ", " .. isextsub2
  299. if (subTrackTitle) then subTrackTitle = subTrackTitle .. ((subTrackLang ~= nil) and " (" .. subTrackLang .. ")" or "") .. ": " .. showcodecsub .. isextsub2
  300. --elseif (subTrackLang) then subTrackTitle = subTrackLang
  301. --elseif (subTrackLang) then subTrackTitle = "- " .. ((subTrackLang ~= nil) and " (" .. subTrackLang .. ")" or "") .. ": " .. showcodecsub .. ", " .. isextsub2
  302. elseif (subTrackLang) then subTrackTitle = "- " .. ((subTrackLang ~= nil) and " (" .. subTrackLang .. ")" or "") .. ": " .. showcodecsub .. isextsub2
  303. --else subTrackTitle = "Subtitle Track " .. i end
  304. --else subTrackTitle = subTrackTitle .. ((subTrackLang ~= nil) and " (" .. subTrackLang .. ")" or "") .. ": " .. showcodecsub .. ", " .. isextsub2 end
  305. else subTrackTitle = subTrackTitle .. ((subTrackLang ~= nil) and " (" .. subTrackLang .. ")" or "") .. ": " .. showcodecsub .. isextsub2 end
  306.  
  307. local subTrackCommand = "set sid " .. subTrackID
  308. if (i == 1) then
  309. --table.insert(subTrackMenuVal, {SEP})
  310. table.insert(subTrackMenuVal, {RADIO, "Select None", "", "set sid 0", function() return noneCheck("sid") end, false, true})
  311. table.insert(subTrackMenuVal, {SEP})
  312. end
  313. table.insert(subTrackMenuVal, {RADIO, subTrackTitle, "", subTrackCommand, function() return checkTrack(subTrackNum) end, false, true})
  314. end
  315. end
  316.  
  317. return subTrackMenuVal
  318. end
  319.  
  320. local function stateABLoop()
  321. local abLoopState = ""
  322. local abLoopA, abLoopB = propNative("ab-loop-a"), propNative("ab-loop-b")
  323.  
  324. if (abLoopA == "no") and (abLoopB == "no") then abLoopState = "off"
  325. elseif not (abLoopA == "no") and (abLoopB == "no") then abLoopState = "a"
  326. elseif not (abLoopA == "no") and not (abLoopB == "no") then abLoopState = "b" end
  327.  
  328. return abLoopState
  329. end
  330.  
  331. local function stateFileLoop()
  332. local loopState, loopval = false, propNative("loop-file")
  333. if (loopval == "inf") then loopState = true end
  334. return loopState
  335. end
  336.  
  337. -- Aspect Ratio radio item check
  338. local function stateRatio(ratioVal)
  339. -- Ratios and Decimal equivalents
  340. -- Ratios: "4:3" "16:10" "16:9" "1.85:1" "2.35:1"
  341. -- Decimal: "1.333" "1.600" "1.778" "1.850" "2.350"
  342. local ratioState = false
  343. local ratioCur = round(propNative("video-aspect-override"), 3)
  344.  
  345. if (ratioVal == "4:3") and (ratioCur == round(4/3, 3)) then ratioState = true
  346. elseif (ratioVal == "16:10") and (ratioVal == round(16/10, 3)) then ratioState = true
  347. elseif (ratioVal == "16:9") and (ratioVal == round(16/9, 3)) then ratioState = true
  348. elseif (ratioVal == "1.85:1") and (ratioVal == round(1.85/1, 3)) then ratioState = true
  349. elseif (ratioVal == "2.35:1") and (ratioVal == round(2.35/1, 3)) then ratioState = true
  350. end
  351.  
  352. return ratioState
  353. end
  354.  
  355. -- Video Rotate radio item check
  356. local function stateRotate(rotateVal)
  357. local rotateState, rotateCur = false, propNative("video-rotate")
  358. if (rotateVal == rotateCur) then rotateState = true end
  359. return rotateState
  360. end
  361.  
  362. -- Video Alignment radio item checks
  363. local function stateAlign(alignAxis, alignPos)
  364. local alignState = false
  365. local alignValY, alignValX = propNative("video-align-y"), propNative("video-align-x")
  366.  
  367. -- This seems a bit unwieldy. Should look at simplifying if possible.
  368. if (alignAxis == "y") then
  369. if (alignPos == alignValY) then alignState = true end
  370. elseif (alignAxis == "x") then
  371. if (alignPos == alignValX) then alignState = true end
  372. end
  373.  
  374. return alignState
  375. end
  376.  
  377. -- Deinterlacing radio item check
  378. local function stateDeInt(deIntVal)
  379. local deIntState, deIntCur = false, propNative("deinterlace")
  380. if (deIntVal == deIntCur) then deIntState = true end
  381. return deIntState
  382. end
  383.  
  384. local function stateFlip(flipVal)
  385. local vfState, vfVals = false, propNative("vf")
  386. for i, vf in pairs(vfVals) do
  387. if (vf["name"] == flipVal) then vfState = true end
  388. end
  389. return vfState
  390. end
  391.  
  392. -- Mute label
  393. local function muteLabel() return propNative("mute") and "Un-mute" or "Mute" end
  394.  
  395. -- Based on "mpv --audio-channels=help", reordered/renamed in part as per Bomi
  396. local audio_channels = { {"Auto", "auto"}, {"Auto (Safe)", "auto-safe"}, {"Empty", "empty"}, {"Mono", "mono"}, {"Stereo", "stereo"}, {"2.1ch", "2.1"}, {"3.0ch", "3.0"}, {"3.0ch (Back)", "3.0(back)"}, {"3.1ch", "3.1"}, {"3.1ch (Back)", "3.1(back)"}, {"4.0ch", "quad"}, {"4.0ch (Side)", "quad(side)"}, {"4.0ch (Diamond)", "4.0"}, {"4.1ch", "4.1(alsa)"}, {"4.1ch (Diamond)", "4.1"}, {"5.0ch", "5.0(alsa)"}, {"5.0ch (Alt.)", "5.0"}, {"5.0ch (Side)", "5.0(side)"}, {"5.1ch", "5.1(alsa)"}, {"5.1ch (Alt.)", "5.1"}, {"5.1ch (Side)", "5.1(side)"}, {"6.0ch", "6.0"}, {"6.0ch (Front)", "6.0(front)"}, {"6.0ch (Hexagonal)", "hexagonal"}, {"6.1ch", "6.1"}, {"6.1ch (Top)", "6.1(top)"}, {"6.1ch (Back)", "6.1(back)"}, {"6.1ch (Front)", "6.1(front)"}, {"7.0ch", "7.0"}, {"7.0ch (Back)", "7.0(rear)"}, {"7.0ch (Front)", "7.0(front)"}, {"7.1ch", "7.1(alsa)"}, {"7.1ch (Alt.)", "7.1"}, {"7.1ch (Wide)", "7.1(wide)"}, {"7.1ch (Side)", "7.1(wide-side)"}, {"7.1ch (Back)", "7.1(rear)"}, {"8.0ch (Octagonal)", "octagonal"} }
  397.  
  398. -- Create audio key/value pairs to check against the native property
  399. -- e.g. audio_pair["2.1"] = "2.1", etc.
  400. local audio_pair = {}
  401. for i = 1, #audio_channels do
  402. audio_pair[audio_channels[i][2]] = audio_channels[i][2]
  403. end
  404.  
  405. -- Audio channel layout radio item check
  406. local function stateAudChannel(audVal)
  407. local audState, audLayout = false, propNative("audio-channels")
  408.  
  409. audState = (audio_pair[audVal] == audLayout) and true or false
  410. return audState
  411. end
  412.  
  413. -- Audio channel layout menu creation
  414. local function audLayoutMenu()
  415. local audLayoutMenuVal = {}
  416.  
  417. for i = 1, #audio_channels do
  418. if (i == 3) then table.insert(audLayoutMenuVal, {SEP}) end
  419. table.insert(audLayoutMenuVal, {RADIO, audio_channels[i][1], "", "set audio-channels \"" .. audio_channels[i][2] .. "\"", function() return stateAudChannel(audio_channels[i][2]) end, false, true})
  420. end
  421.  
  422. return audLayoutMenuVal
  423. end
  424.  
  425. -- Subtitle Alignment radio item check
  426. local function stateSubAlign(subAlignVal)
  427. local subAlignState, subAlignCur = false, propNative("sub-align-y")
  428. subAlignState = (subAlignVal == subAlignCur) and true or false
  429. return subAlignState
  430. end
  431.  
  432. -- Subtitle Position radio item check
  433. local function stateSubPos(subPosVal)
  434. local subPosState, subPosCur = false, propNative("image-subs-video-resolution")
  435. subPosState = (subPosVal == subPosCur) and true or false
  436. return subPosState
  437. end
  438.  
  439. local function movePlaylist(direction)
  440. local playlistPos, newPos = propNative("playlist-pos"), 0
  441. -- We'll remove 1 here to "0 index" the value since we're using it with playlist-pos
  442. local playlistCount = propNative("playlist-count") - 1
  443.  
  444. if (direction == "up") then
  445. newPos = playlistPos - 1
  446. if not (playlistPos == 0) then
  447. mp.commandv("plalist-move", playlistPos, newPos)
  448. else mp.osd_message("Can't move item up any further") end
  449. elseif (direction == "down") then
  450. if not (playlistPos == playlistCount) then
  451. newPos = playlistPos + 2
  452. mp.commandv("plalist-move", playlistPos, newPos)
  453. else mp.osd_message("Can't move item down any further") end
  454. end
  455. end
  456.  
  457. local function statePlayLoop()
  458. local loopState, loopVal = false, propNative("loop-playlist")
  459. if not (tostring(loopVal) == "false") then loopState = true end
  460. return loopState
  461. end
  462.  
  463. local function stateOnTop(onTopVal)
  464. local onTopState, onTopCur = false, propNative("ontop")
  465. onTopState = (onTopVal == onTopCur) and true or false
  466. return onTopState
  467. end
  468.  
  469. --[[ ************ CONFIG: start ************ ]]--
  470.  
  471. local menuList = {}
  472.  
  473. -- Format for object tables
  474. -- {Item Type, Label, Accelerator, Command, Item State, Item Disable, Repost Menu (Optional)}
  475.  
  476. -- Item Type - The type of item, e.g. CASCADE, COMMAND, CHECK, RADIO, etc
  477. -- Label - The label for the item
  478. -- Accelerator - The text shortcut/accelerator for the item
  479. -- Command - This is the command to run when the item is clicked
  480. -- Item State - The state of the item (selected/unselected). A/B Repeat is a special case.
  481. -- Item Disable - Whether to disable
  482. -- Repost Menu (Optional) - This is only for use with the Tk menu and is optional (only needed
  483. -- if the intent is for the menu item to cause the menu to repost)
  484.  
  485. -- Item Type, Label and Accelerator should all evaluate to strings as a result of the return
  486. -- from a function or be strings themselves.
  487. -- Command can be a function or string, this will be handled after a click.
  488. -- Item State and Item Disable should normally be boolean but can be a string for A/B Repeat.
  489. -- Repost Menu (Optional) should only be boolean and is only needed if the value is true.
  490.  
  491. -- The 'file_loaded_menu' value is used when the table is passed to the menu-engine to handle the
  492. -- behavior of the 'playback_only' (cancellable) argument.
  493.  
  494. -- This is to be shown when nothing is open yet and is a small subset of the greater menu that
  495. -- will be overwritten when the full menu is created.
  496. menuList = {
  497. file_loaded_menu = false,
  498.  
  499. context_menu = {
  500. {CASCADE, "Open", "open_menu", "", "", false},
  501. {SEP},
  502. {CASCADE, "Window", "window_menu", "", "", false},
  503. {SEP},
  504. {COMMAND, "Dismiss Menu", "", "", "", false},
  505. --{COMMAND, "Quit", "", "quit", "", false},
  506. },
  507.  
  508. open_menu = {
  509. {COMMAND, "File", "Ctrl+F", "script-binding add_files_dialog", "", false},
  510. {COMMAND, "Folder", "Ctrl+G", "script-binding add_folder_dialog", "", false},
  511. {COMMAND, "URL", "", "script-binding open_url_dialog", "", false},
  512. },
  513.  
  514. window_menu = {
  515. {CASCADE, "Stays on Top", "staysontop_menu", "", "", false},
  516. {CHECK, "Remove Frame", "", "cycle border", function() return not propNative("border") end, false, true},
  517. {SEP},
  518. {COMMAND, "Toggle Fullscreen", "F", "cycle fullscreen", "", false, true},
  519. {COMMAND, "Enter Fullscreen", "", "set fullscreen \"yes\"", "", false, true},
  520. {COMMAND, "Exit Fullscreen", "Escape", "set fullscreen \"no\"", "", false, true},
  521. {SEP},
  522. {COMMAND, "Close", "Ctrl+W", "quit", "", false},
  523. },
  524.  
  525. staysontop_menu = {
  526. {COMMAND, "Select Next", "", "cycle ontop", "", false, true},
  527. {SEP},
  528. {RADIO, "Off", "", "set ontop \"yes\"", function() return stateOnTop(false) end, false, true},
  529. {RADIO, "On", "", "set ontop \"no\"", function() return stateOnTop(true) end, false, true},
  530. },
  531. }
  532.  
  533. -- DO NOT create the "playing" menu tables until AFTER the file has loaded as we're unable to
  534. -- dynamically create some menus if it tries to build the table before the file is loaded.
  535. -- A prime example is the chapter-list or track-list values, which are unavailable until
  536. -- the file has been loaded.
  537.  
  538. --etcmenushow = mp.get_property("speed")
  539. --etcmenushow2 = ""
  540. --if etcmenushow ~= mp.get_property("speed") then etcmenushow2 = mp.get_property("speed") end
  541. --if etcmenushow2 ~= "" then etcmenu0 = etcmenushow2 else etcmenu0 = etcmenushow end
  542.  
  543. mp.register_event("file-loaded", function()
  544. menuList = {
  545. file_loaded_menu = true,
  546.  
  547. context_menu = {
  548. --{CASCADE, "Open", "open_menu", "", "", false},
  549. --{SEP},
  550. --{CASCADE, "Play", "play_menu", "", "", false},
  551. --{CASCADE, "Video", "video_menu", "", "", false},
  552. --{CASCADE, "Audio", "audio_menu", "", "", false},
  553. {CASCADE, "Audio", "audtrack_menu", "", "", false},
  554. --{SEP},
  555. --{CASCADE, "Subtitle", "subtitle_menu", "", "", false},
  556. {CASCADE, "Subtitle", "subtrack_menu", "", "", false},
  557. --{SEP},
  558. --{CASCADE, "Tools", "tools_menu", "", "", false},
  559. --{CASCADE, "Window", "window_menu", "", "", false},
  560. {SEP},
  561. {CASCADE, "profiles", "profilecascade", "", "", false},
  562. {SEP},
  563. {COMMAND, "Dismiss Menu", "", "", "", false},
  564. --{COMMAND, "Quit", "", "quit", "", false},
  565.  
  566. --{CASCADE, etcmenu0, "etc_menu", "", "", false},
  567. --{CASCADE, "profiles", "profilecascade", "", "", false},
  568. --{CASCADE, "profiles", profilecascade, "", "", false}
  569. },
  570.  
  571. -- profilecascade = {
  572. -- {COMMAND, "apply-profile vhs", "ctrl+f7", "VHS/lo-fi", "", false}
  573. -- },
  574.  
  575. open_menu = {
  576. {COMMAND, "File", "Ctrl+F", "script-binding add_files_dialog", "", false},
  577. {COMMAND, "Folder", "Ctrl+G", "script-binding add_folder_dialog", "", false},
  578. {COMMAND, "URL", "", "script-binding open_url_dialog", "", false},
  579. },
  580.  
  581. play_menu = {
  582. {COMMAND, "Play/Pause", "Space", "cycle pause", "", false, true},
  583. {COMMAND, "Stop", "Ctrl+Space", "stop", "", false},
  584. {SEP},
  585. {COMMAND, "Previous", "<", "playlist-prev", "", false, true},
  586. {COMMAND, "Next", ">", "playlist-next", "", false, true},
  587. {SEP},
  588. {CASCADE, "Speed", "speed_menu", "", "", false},
  589. {CASCADE, "A-B Repeat", "abrepeat_menu", "", "", false},
  590. {SEP},
  591. {CASCADE, "Seek", "seek_menu", "", "", false},
  592. {CASCADE, "Title/Edition", "edition_menu", "", "", function() return enableEdition() end},
  593. {CASCADE, "Chapter", "chapter_menu", "", "", function() return enableChapter() end},
  594. },
  595.  
  596. speed_menu = {
  597. {COMMAND, "Reset", "Backspace", "no-osd set speed 1.0 ; show-text \"Play Speed - Reset\"", "", false, true},
  598. {SEP},
  599. {COMMAND, "+" .. opt.playSpeed .. "%", "=", "multiply speed " .. (1 + (opt.playSpeed / 100)), "", false, true},
  600. {COMMAND, "-" .. opt.playSpeed .. "%", "-", "multiply speed " .. (1 - (opt.playSpeed / 100)), "", false, true},
  601. },
  602.  
  603. abrepeat_menu = {
  604. {AB, "Set/Clear A-B Loop", "R", "ab-loop", function() return stateABLoop() end, false, true},
  605. {CHECK, "Toggle Infinite Loop", "", "cycle-values loop-file \"inf\" \"no\"", function() return stateFileLoop() end, false, true},
  606. },
  607.  
  608. profilecascade = {
  609. {COMMAND, "VHS/lo-fi", "Ctrl+f7", "apply-profile vhs", "", false, true}
  610. --{CHECK, "VHS/lo-fi", "Ctrl+f7", "apply-profile vhs", function() return stateFileLoop() end, false, true},
  611. --{CHECK, "VHS/lo-fi", "Ctrl+f7", "apply-profile vhs", function() return stateFileLoop() end, false, true},
  612. },
  613.  
  614. seek_menu = {
  615. {COMMAND, "Beginning", "Ctrl+Home", "no-osd seek 0 absolute", "", false, true},
  616. {SEP},
  617. {COMMAND, "+" .. opt.seekSmall .. " Sec", "Right", "no-osd seek " .. opt.seekSmall, "", false, true},
  618. {COMMAND, "-" .. opt.seekSmall .. " Sec", "Left", "no-osd seek -" .. opt.seekSmall, "", false, true},
  619. {COMMAND, "+" .. opt.seekMedium .. " Sec", "Up", "no-osd seek " .. opt.seekMedium, "", false, true},
  620. {COMMAND, "-" .. opt.seekMedium .. " Sec", "Down", "no-osd seek -" .. opt.seekMedium, "", false, true},
  621. {COMMAND, "+" .. opt.seekLarge .. " Sec", "End", "no-osd seek " .. opt.seekLarge, "", false, true},
  622. {COMMAND, "-" .. opt.seekLarge .. " Sec", "Home", "no-osd seek -" .. opt.seekLarge, "", false, true},
  623. {SEP},
  624. {COMMAND, "Previous Frame", "Alt+Left", "frame-back-step", "", false, true},
  625. {COMMAND, "Next Frame", "Alt+Right", "frame-step", "", false, true},
  626. {COMMAND, "Next Black Frame", "Alt+b", "script-binding skip_scene", "", false, true},
  627. {SEP},
  628. {COMMAND, "Previous Subtitle", "", "no-osd sub-seek -1", "", false, true},
  629. {COMMAND, "Current Subtitle", "", "no-osd sub-seek 0", "", false, true},
  630. {COMMAND, "Next Subtitle", "", "no-osd sub-seek 1", "", false, true},
  631. },
  632.  
  633. -- Use functions returning tables, since we don't need these menus if there
  634. -- aren't any editions or any chapters to seek through.
  635. edition_menu = editionMenu(),
  636. chapter_menu = chapterMenu(),
  637.  
  638. video_menu = {
  639. {CASCADE, "Track", "vidtrack_menu", "", "", function() return enableVidTrack() end},
  640. --{SEP},
  641. --{CASCADE, "Take Screenshot", "screenshot_menu", "", "", false},
  642. {SEP},
  643. {CASCADE, "Aspect Ratio", "aspect_menu", "", "", false},
  644. {CASCADE, "Zoom", "zoom_menu", "", "", false},
  645. {CASCADE, "Rotate", "rotate_menu", "", "", false},
  646. {CASCADE, "Screen Position", "screenpos_menu", "", "", false},
  647. {CASCADE, "Screen Alignment", "screenalign_menu", "", "", false},
  648. {SEP},
  649. {CASCADE, "Deinterlacing", "deint_menu", "", "", false},
  650. {CASCADE, "Filter", "filter_menu", "", "", false},
  651. {CASCADE, "Adjust Color", "color_menu", "", "", false},
  652. },
  653.  
  654. -- Use function to return list of Video Tracks
  655. vidtrack_menu = vidTrackMenu(),
  656.  
  657. screenshot_menu = {
  658. {COMMAND, "Screenshot", "Ctrl+S", "async screenshot", "", false},
  659. {COMMAND, "Screenshot (No Subs)", "Alt+S", "async screenshot video", "", false},
  660. {COMMAND, "Screenshot (Subs/OSD/Scaled)", "", "async screenshot window", "", false},
  661. },
  662.  
  663. aspect_menu = {
  664. {COMMAND, "Reset", "Ctrl+Shift+R", "no-osd set video-aspect-override \"-1\" ; no-osd set video-aspect-override \"-1\" ; show-text \"Video Aspect Ratio - Reset\"", "", false, true},
  665. {COMMAND, "Select Next", "", "cycle-values video-aspect-override \"4:3\" \"16:10\" \"16:9\" \"1.85:1\" \"2.35:1\" \"-1\" \"-1\"", "", false, true},
  666. {SEP},
  667. {RADIO, "4:3 (TV)", "", "set video-aspect-override \"4:3\"", function() return stateRatio("4:3") end, false, true},
  668. {RADIO, "16:10 (Wide Monitor)", "", "set video-aspect-override \"16:10\"", function() return stateRatio("16:10") end, false, true},
  669. {RADIO, "16:9 (HDTV)", "", "set video-aspect-override \"16:9\"", function() return stateRatio("16:9") end, false, true},
  670. {RADIO, "1.85:1 (Wide Vision)", "", "set video-aspect-override \"1.85:1\"", function() return stateRatio("1.85:1") end, false, true},
  671. {RADIO, "2.35:1 (CinemaScope)", "", "set video-aspect-override \"2.35:1\"", function() return stateRatio("2.35:1") end, false, true},
  672. {SEP},
  673. {COMMAND, "+" .. opt.vidAspect .. "%", "Ctrl+Shift+A", "add video-aspect-override " .. (opt.vidAspect / 100), "", false, true},
  674. {COMMAND, "-" .. opt.vidAspect .. "%", "Ctrl+Shift+D", "add video-aspect-override -" .. (opt.vidAspect / 100), "", false, true},
  675. },
  676.  
  677. zoom_menu = {
  678. {COMMAND, "Reset", "Shift+R", "no-osd set panscan 0 ; show-text \"Pan/Scan - Reset\"", "", false, true},
  679. {SEP},
  680. {COMMAND, "+" .. opt.vidZoom .. "%", "Shift+T", "add panscan " .. (opt.vidZoom / 100), "", false, true},
  681. {COMMAND, "-" .. opt.vidZoom .. "%", "Shift+G", "add panscan -" .. (opt.vidZoom / 100), "", false, true},
  682. },
  683.  
  684. rotate_menu = {
  685. {COMMAND, "Reset", "", "set video-rotate \"0\"", "", false, true},
  686. {COMMAND, "Select Next", "", "cycle-values video-rotate \"0\" \"90\" \"180\" \"270\"", "", false, true},
  687. {SEP},
  688. {RADIO, "0°", "", "set video-rotate \"0\"", function() return stateRotate(0) end, false, true},
  689. {RADIO, "90°", "", "set video-rotate \"90\"", function() return stateRotate(90) end, false, true},
  690. {RADIO, "180°", "", "set video-rotate \"180\"", function() return stateRotate(180) end, false, true},
  691. {RADIO, "270°", "", "set video-rotate \"270\"", function() return stateRotate(270) end, false, true},
  692. },
  693.  
  694. screenpos_menu = {
  695. {COMMAND, "Reset", "Shift+X", "no-osd set video-pan-x 0 ; no-osd set video-pan-y 0 ; show-text \"Video Pan - Reset\"", "", false, true},
  696. {SEP},
  697. {COMMAND, "Horizontally +" .. opt.vidPos .. "%", "Shift+D", "add video-pan-x " .. (opt.vidPos / 100), "", false, true},
  698. {COMMAND, "Horizontally -" .. opt.vidPos .. "%", "Shift+A", "add video-pan-x -" .. (opt.vidPos / 100), "", false, true},
  699. {SEP},
  700. {COMMAND, "Vertically +" .. opt.vidPos .. "%", "Shift+S", "add video-pan-y -" .. (opt.vidPos / 100), "", false, true},
  701. {COMMAND, "Vertically -" .. opt.vidPos .. "%", "Shift+W", "add video-pan-y " .. (opt.vidPos / 100), "", false, true},
  702. },
  703.  
  704. screenalign_menu = {
  705. -- Y Values: -1 = Top, 0 = Vertical Center, 1 = Bottom
  706. -- X Values: -1 = Left, 0 = Horizontal Center, 1 = Right
  707. {RADIO, "Top", "", "no-osd set video-align-y -1", function() return stateAlign("y",-1) end, false, true},
  708. {RADIO, "Vertical Center", "", "no-osd set video-align-y 0", function() return stateAlign("y",0) end, false, true},
  709. {RADIO, "Bottom", "", "no-osd set video-align-y 1", function() return stateAlign("y",1) end, false, true},
  710. {SEP},
  711. {RADIO, "Left", "", "no-osd set video-align-x -1", function() return stateAlign("x",-1) end, false, true},
  712. {RADIO, "Horizontal Center", "", "no-osd set video-align-x 0", function() return stateAlign("x",0) end, false, true},
  713. {RADIO, "Right", "", "no-osd set video-align-x 1", function() return stateAlign("x",1) end, false, true},
  714. },
  715.  
  716. deint_menu = {
  717. {COMMAND, "Toggle", "Ctrl+D", "cycle deinterlace", "", false, true},
  718. {COMMAND, "Auto", "", "set deinterlace \"auto\"", "", false, true},
  719. {SEP},
  720. {RADIO, "Off", "", "no-osd set deinterlace \"no\"", function() return stateDeInt(false) end, false, true},
  721. {RADIO, "On", "", "no-osd set deinterlace \"yes\"", function() return stateDeInt(true) end, false, true},
  722. },
  723.  
  724. filter_menu = {
  725. {CHECK, "Flip Vertically", "", "no-osd vf toggle vflip", function() return stateFlip("vflip") end, false, true},
  726. {CHECK, "Flip Horizontally", "", "no-osd vf toggle hflip", function() return stateFlip("hflip") end, false, true}
  727. },
  728.  
  729. color_menu = {
  730. {COMMAND, "Reset", "O", "no-osd set brightness 0 ; no-osd set contrast 0 ; no-osd set hue 0 ; no-osd set saturation 0 ; show-text \"Colors - Reset\"", "", false, true},
  731. {SEP},
  732. {COMMAND, "Brightness +" .. opt.vidColor .. "%", "T", "add brightness " .. opt.vidColor, "", false, true},
  733. {COMMAND, "Brightness -" .. opt.vidColor .. "%", "G", "add brightness -" .. opt.vidColor, "", false, true},
  734. {COMMAND, "Contrast +" .. opt.vidColor .. "%", "Y", "add contrast " .. opt.vidColor, "", false, true},
  735. {COMMAND, "Contrast -" .. opt.vidColor .. "%", "H", "add contrast -" .. opt.vidColor, "", false, true},
  736. {COMMAND, "Saturation +" .. opt.vidColor .. "%", "U", "add saturation " .. opt.vidColor, "", false, true},
  737. {COMMAND, "Saturation -" .. opt.vidColor .. "%", "J", "add saturation -" .. opt.vidColor, "", false, true},
  738. {COMMAND, "Hue +" .. opt.vidColor .. "%", "I", "add hue " .. opt.vidColor, "", false, true},
  739. {COMMAND, "Hue -" .. opt.vidColor .. "%", "K", "add hue -" .. opt.vidColor, "", false, true},
  740. },
  741.  
  742. audio_menu = {
  743. {CASCADE, "Track", "audtrack_menu", "", "", false},
  744. --{CASCADE, "Sync", "audsync_menu", "", "", false},
  745. --{SEP},
  746. --{CASCADE, "Volume", "volume_menu", "", "", false},
  747. --{CASCADE, "Channel Layout", "channel_layout", "", "", false},
  748. },
  749.  
  750. -- Use function to return list of Audio Tracks
  751. audtrack_menu = audTrackMenu(),
  752.  
  753. audsync_menu = {
  754. {COMMAND, "Reset", "\\", "no-osd set audio-delay 0 ; show-text \"Audio Sync - Reset\"", "", false, true},
  755. {SEP},
  756. {COMMAND, "+" .. opt.audSync .. " ms", "]", "add audio-delay " .. (opt.audSync / 1000) .. "", "", false, true},
  757. {COMMAND, "-" .. opt.audSync .. " ms", "[", "add audio-delay -" .. (opt.audSync / 1000) .. "", "", false, true},
  758. },
  759.  
  760. volume_menu = {
  761. {CHECK, function() return muteLabel() end, "", "cycle mute", function() return propNative("mute") end, false, true},
  762. {SEP},
  763. {COMMAND, "+" .. opt.audVol.. "%", "Shift+Up", "add volume " .. opt.audVol, "", false, true},
  764. {COMMAND, "-" .. opt.audVol.. "%", "Shift+Down", "add volume -" .. opt.audVol, "", false, true},
  765. },
  766.  
  767. channel_layout = audLayoutMenu(),
  768.  
  769. subtitle_menu = {
  770. {CASCADE, "Track", "subtrack_menu", "", "", false},
  771. {SEP},
  772. {CASCADE, "Alightment", "subalign_menu", "", "", false},
  773. {CASCADE, "Position", "subpos_menu", "", "", false},
  774. {CASCADE, "Scale", "subscale_menu", "", "", false},
  775. {SEP},
  776. {CASCADE, "Sync", "subsync_menu", "", "", false},
  777. },
  778.  
  779. -- Use function to return list of Subtitle Tracks
  780. subtrack_menu = subTrackMenu(),
  781.  
  782. subalign_menu = {
  783. {COMMAND, "Select Next", "", "cycle-values sub-align-y \"top\" \"bottom\"", "", false, true},
  784. {SEP},
  785. {RADIO, "Top", "", "set sub-align-y \"top\"", function() return stateSubAlign("top") end, false, true},
  786. {RADIO, "Bottom", "","set sub-align-y \"bottom\"", function() return stateSubAlign("bottom") end, false, true},
  787. },
  788.  
  789. subpos_menu = {
  790. {COMMAND, "Reset", "Alt+S", "no-osd set sub-pos 100 ; no-osd set sub-scale 1 ; show-text \"Subtitle Position - Reset\"", "", false, true},
  791. {SEP},
  792. {COMMAND, "+" .. opt.subPos .. "%", "S", "add sub-pos " .. opt.subPos, "", false, true},
  793. {COMMAND, "-" .. opt.subPos .. "%", "W", "add sub-pos -" .. opt.subPos, "", false, true},
  794. {SEP},
  795. {RADIO, "Display on Letterbox", "", "set image-subs-video-resolution \"no\"", function() return stateSubPos(false) end, false, true},
  796. {RADIO, "Display in Video", "", "set image-subs-video-resolution \"yes\"", function() return stateSubPos(true) end, false, true},
  797. },
  798.  
  799. subscale_menu = {
  800. {COMMAND, "Reset", "", "no-osd set sub-pos 100 ; no-osd set sub-scale 1 ; show-text \"Subtitle Position - Reset\"", "", false, true},
  801. {SEP},
  802. {COMMAND, "+" .. opt.subScale .. "%", "Shift+K", "add sub-scale " .. (opt.subScale / 100), "", false, true},
  803. {COMMAND, "-" .. opt.subScale .. "%", "Shift+J", "add sub-scale -" .. (opt.subScale / 100), "", false, true},
  804. },
  805.  
  806. subsync_menu = {
  807. {COMMAND, "Reset", "Q", "no-osd set sub-delay 0 ; show-text \"Subtitle Delay - Reset\"", "", false, true},
  808. {SEP},
  809. {COMMAND, "+" .. opt.subSync .. " ms", "D", "add sub-delay +" .. (opt.subSync / 1000) .. "", "", false, true},
  810. {COMMAND, "-" .. opt.subSync .. " ms", "A", "add sub-delay -" .. (opt.subSync / 1000) .. "", "", false, true},
  811. },
  812.  
  813. etc_menu = {
  814. {CASCADE, yuy , "playlist_menu", "", "", false},
  815. --{COMMAND, "Find Subtitle (Subit)", "", "script-binding subit", "", false},
  816. --{COMMAND, "Playback Information", "Tab", "script-binding display-stats-toggle", "", false, true},
  817. },
  818.  
  819. tools_menu = {
  820. {CASCADE, "Playlist", "playlist_menu", "", "", false},
  821. {COMMAND, "Find Subtitle (Subit)", "", "script-binding subit", "", false},
  822. {COMMAND, "Playback Information", "Tab", "script-binding display-stats-toggle", "", false, true},
  823. },
  824.  
  825. playlist_menu = {
  826. {COMMAND, "Show", "L", "script-binding showplaylist", "", false},
  827. {SEP},
  828. {COMMAND, "Open", "", "script-binding open_playlist_dialog", "", false},
  829. {COMMAND, "Save", "", "script-binding saveplaylist", "", false},
  830. {COMMAND, "Regenerate", "", "script-binding loadfiles", "", false},
  831. {COMMAND, "Clear", "Shift+L", "playlist-clear", "", false},
  832. {SEP},
  833. {COMMAND, "Append File", "", "script-binding append_files_dialog", "", false},
  834. {COMMAND, "Append URL", "", "script_binding append_url_dialog", "", false},
  835. {COMMAND, "Remove", "", "playlist-remove current", "", false, true},
  836. {SEP},
  837. {COMMAND, "Move Up", "", function() movePlaylist("up") end, "", function() return (propNative("playlist-count") < 2) and true or false end, true},
  838. {COMMAND, "Move Down", "", function() movePlaylist("down") end, "", function() return (propNative("playlist-count") < 2) and true or false end, true},
  839. {SEP},
  840. {CHECK, "Shuffle", "", "cycle shuffle", function() return propNative("shuffle") end, false, true},
  841. {CHECK, "Repeat", "", "cycle-values loop-playlist \"inf\" \"no\"", function() return statePlayLoop() end, false, true},
  842. },
  843.  
  844. window_menu = {
  845. {CASCADE, "Stays on Top", "staysontop_menu", "", "", false},
  846. {CHECK, "Remove Frame", "", "cycle border", function() return not propNative("border") end, false, true},
  847. {SEP},
  848. {COMMAND, "Toggle Fullscreen", "F", "cycle fullscreen", "", false, true},
  849. {COMMAND, "Enter Fullscreen", "", "set fullscreen \"yes\"", "", false, true},
  850. {COMMAND, "Exit Fullscreen", "Escape", "set fullscreen \"no\"", "", false, true},
  851. {SEP},
  852. {COMMAND, "Close", "Ctrl+W", "quit", "", false},
  853. },
  854.  
  855. staysontop_menu = {
  856. {COMMAND, "Select Next", "", "cycle ontop", "", false, true},
  857. {SEP},
  858. {RADIO, "Off", "", "set ontop \"yes\"", function() return stateOnTop(false) end, false, true},
  859. {RADIO, "On", "", "set ontop \"no\"", function() return stateOnTop(true) end, false, true},
  860. },
  861. }
  862.  
  863. -- This check ensures that all tables of data without SEP in them are 6 or 7 items long.
  864. for key, value in pairs(menuList) do
  865. -- Skip the 'file_loaded_menu' key as the following for loop will fail due to an
  866. -- attempt to get the length of a boolean value.
  867. if (key == "file_loaded_menu") then goto keyjump end
  868.  
  869. for i = 1, #value do
  870. if (value[i][1] ~= SEP) then
  871. if (#value[i] < 6 or #value[i] > 7) then mpdebug("Menu item at index of " .. i .. " is " .. #value[i] .. " items long for: " .. key) end
  872. end
  873. end
  874.  
  875. ::keyjump::
  876. end
  877. end)
  878.  
  879. --[[ ************ CONFIG: end ************ ]]--
  880.  
  881. local menuEngine = require "menu-engine"
  882.  
  883. mp.register_script_message("mpv_context_menu_tk", function()
  884. menuEngine.createMenu(menuList, "context_menu", -1, -1, "tk")
  885. end)
  886.  
  887. mp.register_script_message("mpv_context_menu_tk_static", function()
  888. menuEngine.createMenu(menuList, "context_menu", 2800, 1400, "tk")
  889. end)
  890.  
  891. mp.register_script_message("mpv_context_menu_gtk", function()
  892. menuEngine.createMenu(menuList, "context_menu", -1, -1, "gtk")
  893. end)
  894.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement