-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
-- Whether to show the embedded audio track title by default | ||
local show_title = false | ||
|
||
function toggle_show_title() | ||
show_title = not show_title | ||
end | ||
|
||
mp.add_key_binding("6", "toggle_show_title", toggle_show_title) | ||
|
||
function cycle_audio_tracks() | ||
mp.command("cycle audio") | ||
local audio_info = mp.get_property_native("track-list") | ||
local media = mp.get_property("user-data/plex/playing-media") | ||
local displayTitle = "None" | ||
|
||
for _, track in pairs(audio_info) do | ||
if track["type"] == "audio" and track["selected"] then | ||
local ff_index = track["ff-index"] | ||
|
||
for audio in string.gmatch(media, "{(.-)}") do | ||
local index = string.match(audio, "\"index\":(%d+)") | ||
local id = string.match(audio, "\"id\":\"(.-)\"") | ||
local title, display | ||
if show_title then | ||
if not track["title"] then | ||
display = string.match(audio, "\"displayTitle\":\"(.-)\"") | ||
else | ||
title = track["title"] | ||
end | ||
else | ||
display = string.match(audio, "\"displayTitle\":\"(.-)\"") | ||
end | ||
|
||
if ff_index ~= 0 and index and (title or display) and tonumber(index) == ff_index then | ||
displayTitle = title or display | ||
break | ||
end | ||
end | ||
end | ||
end | ||
|
||
mp.osd_message("Current Audio Track: " .. displayTitle) | ||
end | ||
|
||
mp.add_key_binding("y", "cycle_audio_tracks", cycle_audio_tracks) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
-- 是否默认显示内置音轨标题 | ||
local show_title = false | ||
|
||
function toggle_show_title() | ||
show_title = not show_title | ||
end | ||
|
||
mp.add_key_binding("6", "toggle_show_title", toggle_show_title) | ||
|
||
function cycle_audio_tracks() | ||
mp.command("cycle audio") | ||
local audio_info = mp.get_property_native("track-list") | ||
local media = mp.get_property("user-data/plex/playing-media") | ||
local displayTitle = "无" | ||
|
||
for _, track in pairs(audio_info) do | ||
if track["type"] == "audio" and track["selected"] then | ||
local ff_index = track["ff-index"] | ||
|
||
for audio in string.gmatch(media, "{(.-)}") do | ||
local index = string.match(audio, "\"index\":(%d+)") | ||
local id = string.match(audio, "\"id\":\"(.-)\"") | ||
local title, display | ||
if show_title then | ||
if not track["title"] then | ||
display = string.match(audio, "\"displayTitle\":\"(.-)\"") | ||
else | ||
title = track["title"] | ||
end | ||
else | ||
display = string.match(audio, "\"displayTitle\":\"(.-)\"") | ||
end | ||
|
||
if ff_index ~= 0 and index and (title or display) and tonumber(index) == ff_index then | ||
displayTitle = title or display | ||
break | ||
end | ||
end | ||
end | ||
end | ||
|
||
mp.osd_message("当前音轨: " .. displayTitle) | ||
end | ||
|
||
mp.add_key_binding("y", "cycle_audio_tracks", cycle_audio_tracks) |