summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-02-24 21:54:50 +0100
committerwm4 <wm4@nowhere>2014-02-24 22:50:24 +0100
commit0797babbfa42ec29cf953070f520648e9d11d971 (patch)
tree7fdef194a0e9eef5c6eb939e769d631e50e7005a /player
parent4d1575173b64b7a95f7cf9626956aebafdbc103f (diff)
downloadmpv-0797babbfa42ec29cf953070f520648e9d11d971.tar.bz2
mpv-0797babbfa42ec29cf953070f520648e9d11d971.tar.xz
lua, osc: use properties for chapter/track lists
Diffstat (limited to 'player')
-rw-r--r--player/lua.c77
-rw-r--r--player/lua/osc.lua10
2 files changed, 5 insertions, 82 deletions
diff --git a/player/lua.c b/player/lua.c
index d8996eb7b9..dec5d22cab 100644
--- a/player/lua.c
+++ b/player/lua.c
@@ -726,81 +726,6 @@ static int script_get_time(lua_State *L)
return 1;
}
-static int script_get_chapter_list(lua_State *L)
-{
- struct MPContext *mpctx = get_mpctx(L);
- mp_dispatch_lock(mpctx->dispatch);
- lua_newtable(L); // list
- int num = get_chapter_count(mpctx);
- for (int n = 0; n < num; n++) {
- double time = chapter_start_time(mpctx, n);
- char *name = chapter_display_name(mpctx, n);
- lua_newtable(L); // list ch
- lua_pushnumber(L, time); // list ch time
- lua_setfield(L, -2, "time"); // list ch
- lua_pushstring(L, name); // list ch name
- lua_setfield(L, -2, "name"); // list ch
- lua_pushinteger(L, n + 1); // list ch n1
- lua_insert(L, -2); // list n1 ch
- lua_settable(L, -3); // list
- talloc_free(name);
- }
- mp_dispatch_unlock(mpctx->dispatch);
- return 1;
-}
-
-static const char *stream_type(enum stream_type t)
-{
- switch (t) {
- case STREAM_VIDEO: return "video";
- case STREAM_AUDIO: return "audio";
- case STREAM_SUB: return "sub";
- default: return "unknown";
- }
-}
-
-static int script_get_track_list(lua_State *L)
-{
- struct MPContext *mpctx = get_mpctx(L);
- mp_dispatch_lock(mpctx->dispatch);
- lua_newtable(L); // list
- for (int n = 0; n < mpctx->num_tracks; n++) {
- struct track *track = mpctx->tracks[n];
- lua_newtable(L); // list track
-
- lua_pushstring(L, stream_type(track->type));
- lua_setfield(L, -2, "type");
- lua_pushinteger(L, track->user_tid);
- lua_setfield(L, -2, "id");
- lua_pushboolean(L, track->default_track);
- lua_setfield(L, -2, "default");
- lua_pushboolean(L, track->attached_picture);
- lua_setfield(L, -2, "attached_picture");
- if (track->lang) {
- lua_pushstring(L, track->lang);
- lua_setfield(L, -2, "language");
- }
- if (track->title) {
- lua_pushstring(L, track->title);
- lua_setfield(L, -2, "title");
- }
- lua_pushboolean(L, track->is_external);
- lua_setfield(L, -2, "external");
- if (track->external_filename) {
- lua_pushstring(L, track->external_filename);
- lua_setfield(L, -2, "external_filename");
- }
- lua_pushboolean(L, track->auto_loaded);
- lua_setfield(L, -2, "auto_loaded");
-
- lua_pushinteger(L, n + 1); // list track n1
- lua_insert(L, -2); // list n1 track
- lua_settable(L, -3); // list
- }
- mp_dispatch_unlock(mpctx->dispatch);
- return 1;
-}
-
static int script_input_define_section(lua_State *L)
{
struct MPContext *mpctx = get_mpctx(L);
@@ -933,8 +858,6 @@ static struct fn_entry fn_list[] = {
FN_ENTRY(get_screen_size),
FN_ENTRY(get_mouse_pos),
FN_ENTRY(get_time),
- FN_ENTRY(get_chapter_list),
- FN_ENTRY(get_track_list),
FN_ENTRY(input_define_section),
FN_ENTRY(input_enable_section),
FN_ENTRY(input_disable_section),
diff --git a/player/lua/osc.lua b/player/lua/osc.lua
index 033f2c0d7e..0ccb4c3552 100644
--- a/player/lua/osc.lua
+++ b/player/lua/osc.lua
@@ -251,7 +251,7 @@ local nicetypes = {video = "Video", audio = "Audio", sub = "Subtitle"}
-- updates the OSC internal playlists, should be run each time the track-layout changes
function update_tracklist()
- local tracktable = mp.get_track_list()
+ local tracktable = mp.get_property_native("track-list", {})
-- by osc_id
tracks_osc = {}
@@ -284,7 +284,7 @@ function get_tracklist(type)
for n = 1, #tracks_osc[type] do
local track = tracks_osc[type][n]
local lang, title, selected = "unkown", "", "{\\fscx" .. select_scale .. "\\fscy" .. select_scale .. "}○{\\fscx100\\fscy100}"
- if not(track.language == nil) then lang = track.language end
+ if not(track.lang == nil) then lang = track.lang end
if not(track.title == nil) then title = track.title end
if (track.id == tonumber(mp.get_property(type))) then
selected = "{\\fscx" .. select_scale .. "\\fscy" .. select_scale .. "}●{\\fscx100\\fscy100}"
@@ -318,7 +318,7 @@ function set_track(type, next)
show_message(nicetypes[type] .. " Track: none")
else
show_message(nicetypes[type] .. " Track: " .. new_track_osc .. "/" .. #tracks_osc[type]
- .. " [" .. (tracks_osc[type][new_track_osc].language or "unkown") .. "] " .. (tracks_osc[type][new_track_osc].title or ""))
+ .. " [" .. (tracks_osc[type][new_track_osc].lang or "unkown") .. "] " .. (tracks_osc[type][new_track_osc].title or ""))
end
end
@@ -804,7 +804,7 @@ function osc_init()
--chapters
-- do we have any?
local metainfo = {}
- metainfo.enabled = ((#mp.get_chapter_list()) > 0)
+ metainfo.enabled = ((#mp.get_property_native("chapter-list", {})) > 0)
--prev
local eventresponder = {}
@@ -923,7 +923,7 @@ function osc_init()
duration = tonumber(mp.get_property("length"))
end
- local chapters = mp.get_chapter_list()
+ local chapters = mp.get_property_native("chapter-list", {})
local markers = {}
for n = 1, #chapters do
markers[n] = (chapters[n].time / duration * 100)