Bonjour à tous
je viens de mettre en place le module xbmc et cela fonctionne parfaitement mais... oui... il fallait un "mais" sinon cela ne serait pas drole... j'ai un problème pour remonter le nom du film/acteurs/ durée sur la télécommande virtuelle.
Etant catastrophique en dév (merci en passant à tous ceux qui apportent leur savoir à des gens comme moi) je souhaite savoir ou se trouve mon erreur...
Le code est le suivant:
local xbmc_ip = ('192.168.1.45');
local globVar = "XBMC_PC";
selfId = fibaro:getSelfId();
function xbmcJson (label)
local xbmcFunction = pcall(function()
local XBMC = Net.FHttp(xbmc_ip, 80);
if (label == "1") then
response,status, errorCode = XBMC:GET('/jsonrpc?request={"jsonrpc":"2.0","method":"Application.GetProperties","params":{"properties":["volume"]},"id":1}');
elseif (label == "2") then
if ( (fibaro:getGlobalValue(globVar) == "PVR" )) then
response,status, errorCode = XBMC:GET('/jsonrpc?request={"jsonrpc":"2.0","method":"Player.GetItem","params":{"playerid":1,"properties":["showtitle"]},"id":1}');
elseif ( fibaro:getGlobalValue(globVar) == "Movies" ) then
response,status, errorCode = XBMC:GET('/jsonrpc?request={"jsonrpc":"2.0","method":"Player.GetItem","params":{"playerid":1,"properties":["set"]},"id":1}');
elseif ( fibaro:getGlobalValue(globVar) == "Music" ) then
response,status, errorCode = XBMC:GET('/jsonrpc?request={"jsonrpc":"2.0","method":"Player.GetItem","params":{"playerid":0,"properties":["title","album","albumartist","artist"]},"id":1}');
end
elseif (label == "3") then
if ( fibaro:getGlobalValue(globVar) == "Music" ) then
response,status, errorCode = XBMC:GET('/jsonrpc?request={"jsonrpc":"2.0","method":"Player.GetProperties","params":{"playerid":0,"properties":["percentage","time","totaltime"]},"id":1}');
elseif ( (fibaro:getGlobalValue(globVar) == "Movies") or (fibaro:getGlobalValue(globVar) == "TVShows") or (fibaro:getGlobalValue(globVar) == "PVR") ) then
response,status, errorCode = XBMC:GET('/jsonrpc?request={"jsonrpc":"2.0","method":"Player.GetProperties","params":{"playerid":1,"properties":["percentage","time","totaltime"]},"id":1}');
end
elseif (label == "4") then
response,status, errorCode = XBMC:GET('/jsonrpc?request={"jsonrpc":"2.0","id":1,"method":"Playlist.GetItems","params":{"properties":["title","artist"],"limits":{"start":0,"end":5},"playlistid":0}}');
end
local t = nil;
t = json.decode(response);
if (label == "1") then
fibaro:call(selfId, "setProperty","ui.sldVolume.value",t.result.volume);
elseif (label == "2") then
if ( (fibaro:getGlobalValue(globVar) == "PVR" )) then
fibaro:call(selfId, "setProperty", "ui.lblXbmc2.value", t.result.item.label);
elseif ( fibaro:getGlobalValue(globVar) == "Movies" ) then
local currentValue = t.result.item.set;
if (currentValue == "") then
data = "No Saga";
else
data = "Saga: " .. currentValue;
end
fibaro:call(selfId, "setProperty", "ui.lblXbmc2.value", data);
elseif ( fibaro:getGlobalValue(globVar) == "Music" ) then
fibaro:call(selfId, "setProperty", "ui.lblXbmc1.value", t.result.item.title);
if ( tostring(t.result.item.albumartist[1]) == "Various artists" ) then
fibaro:call(selfId, "setProperty", "ui.lblXbmc3.value", tostring(t.result.item.artist[1]) .. " / " .. t.result.item.album);
else
fibaro:call(selfId, "setProperty", "ui.lblXbmc3.value", tostring(t.result.item.albumartist[1]));
end
end
elseif (label == "3") then
fibaro:call(selfId, "setProperty", "ui.sldPercentage.value",string.match(t.result.percentage, "(%d.*%.%d%d)"));
fibaro:call(selfId, "setProperty", "ui.lblTime.value",t.result.time.hours .. ":" .. t.result.time.minutes .. ":" .. t.result.time.seconds .. " / " .. t.result.totaltime.hours .. ':' .. t.result.totaltime.minutes .. ':' .. t.result.totaltime.seconds);
elseif (label == "4") then
fibaro:debug("ok");
fibaro:debug(tostring(t.result.items[1]));
fibaro:call(selfId, "setProperty", "ui.lblXbmc2.value", tostring(t.result.items[1].title .. '\n' .. t.result.items[2].title .. "\n" .. t.result.items[3].title .. "\n" .. t.result.items[4].title .. "\n" .. t.result.items[5].title));
end
end)
if (not xbmcFunction) then
fibaro:debug('Decode raised an error');
end
end
if ( (fibaro:getGlobalValue(globVar) == "PVR") or (fibaro:getGlobalValue(globVar) == "Movies") ) then
xbmcJson("2");
fibaro:sleep(1000);
end
if ( fibaro:getGlobalValue(globVar) == "Music" ) then
xbmcJson("4");
fibaro:sleep(1000);
end
xbmcJson("1");
fibaro:sleep(1000);
xbmcJson("3");
j'ai en debug le message suivant "[DEBUG] 22:04:15: Decode raised an error
qu'est ce qui cloche ?
Merci pour votre aide