Jump to content
C4 Forums | Control4
  • 0

Develop a Multi-Room Music Audio Driver With Some Problem


abner007

Question

We are try to develop a Multi-Room Music Audio Driver,used 2 proxies:amplifier and media service proxy! And now I have a problem。The lua txt is like that,now the problem is it can not show the ImageUrl picture on control 4 app,I didn't know what's wong with the diver.

 

function PRX_CMD.QUEUE_DELETED(idBinding, tParams)
    -- This is a notification that we receive when the queue gets deleted
    local queueId = tonumber(tParams["QUEUE_ID"])
    local lastQueueState = tParams["LAST_STATE"]
    local lastQueueStateTime = tonumber(tParams["LAST_STATE_TIME"])

    print("PRX_CMD.QUEUE_DELETED() for queue " .. queueId .. ", last state was " .. lastQueueState .. " for " .. lastQueueStateTime .. " seconds")
    
    local queueInfo = gQueues[queueId]
    if (queueInfo ~= nil) then
        print("Deleting queue info for queue " .. queueId .. ", was playing QUEUE_INFO " .. tParams["QUEUE_INFO"])
        
        ChangeDashboard(queueInfo, nil) -- Clear the media dashboard
        
        if (lastQueueState == "PLAY") then
            -- Save the current time when this station stopped playing for reporting purposes
            queueInfo["END_TIME"] = os.time()
        end
        
        gQueues[queueId] = nil
        queueInfo = nil
        
        ClearNowPlayingQueue(queueId)
    end
    
end
function PRX_CMD.QUEUE_MEDIA_INFO_UPDATED(idBinding, tParams)
      -- GetNowPlayinginfo()
end
------------------------------------------------------------------------------------------------------------------------------------------------------
function SPRX_CMD.NetData(idBinding, tParams
       table.insert(MainTable,tParams)
end
function SPRX_CMD.GetPlayingInfo(id, tParams)
       if (gNowPlaying ~= nil) then
          gNowPlaying = {}
          gCurrentSongIndex = 1
       end
       table.insert(gNowPlaying,tParams)
       local tResponse = {}
       local NowPlayingIndex = BuildSimpleXml(nil, {["NowPlayingIndex"] = 0})
       local List = BuildListXml(gNowPlaying, true)
       local args = NowPlayingIndex .. List
       tResponse["ROOMID"] = gROOMID
       tResponse["NAVID"] = gNAVID
       tResponse["NAME"] = "QueueChanged"
       tResponse["EVTARGS"] = args    
       SendToProxy(idBinding, "SEND_EVENT", tResponse, "COMMAND")
       UpdateMediaInfo(idBinding, gNowPlaying[1].Title, gNowPlaying[1].SubTitle, "", "", gNowPlaying[1].ImageUrl, gROOMID , true)
end

function DataReceived(idBinding, navId, seq, response)
    local data 
    if (type(response) == "table") then
        data = BuildListXml(response, false)
    else    
        data = response
    end
    
    local tResponse = {
        ["NAVID"] = navId,
        ["SEQ"] = seq,
        ["DATA"] = data,
    }
    SendToProxy(idBinding, "DATA_RECEIVED", tResponse)
end
function NowPlayingChanged(idBinding, tParams)
    local id = gCurrentSongIndex
    
    
    local nowplaying = BuildSimpleXml(nil, {["Id"] = id})    
    local tResponse = {
        ["NAME"] = "NowPlayingChanged",
        ["EVTARGS"] = nowplaying,
    }        
    local queueId 
    if (tParams["QUEUE_ID"] ~= nil) then
        queueId = tonumber(tParams["QUEUE_ID"])
    else
        queueId = GetQueueFromRoom(nil, tParams["ROOMID"])
    end
    local tRooms = GetRoomsByQueue(nil, queueId)
    local rooms = ""
    for i,v in pairs(tRooms) do
        if (string.len(rooms) > 0) then
            rooms = rooms .. ","
        end
        rooms = rooms .. tostring(v)
    end
    if (string.len(rooms) > 0) then
        tResponse["ROOMS"] = rooms
    else
        tResponse["NAVID"] = tParams["NAVID"]
    end
--[[    
    SendToProxy(GENERIC_MEDIA_PROXY_BINDING_ID, "SEND_EVENT", tResponse, "COMMAND")    
--]]    
    local NowPlayingIndex = BuildSimpleXml(nil, {["NowPlayingIndex"] = gCurrentSongIndex - 1})
    local NowPlaying = "<NowPlaying><actionIds>Preset</actionIds>" ..
                        "<key>" .. gNowPlaying[gCurrentSongIndex].key .. "</key>" ..
                        "<type>" .. gNowPlaying[gCurrentSongIndex].type .. "</type>" ..
                        "<is_preset>" .. gNowPlaying[gCurrentSongIndex].is_preset .. "</is_preset>" ..
                        "</NowPlaying>"    
    local args = NowPlayingIndex .. NowPlaying
    QueueChanged(idBinding, nil, tParams["ROOMID"], args)
    
    local roomid
    if (tParams["ROOMID"] ~= nil) then
        roomid = tParams["ROOMID"]
    elseif (tParams["QUEUE_ID"] ~= nil) then
        --local tRooms = GetRoomsByQueue(nil, tonumber(tParams["QUEUE_ID"]))
        roomid = tRooms[1]
    else
        print("NowPlayingChanged(), no valid Room ID.")
        return
    end
    
    SelectInternetRadio(idBinding, roomid, gNowPlaying[id].URL, id)
   
    UpdateMediaInfo(idBinding, gNowPlaying[id].Title, gNowPlaying[id].SubTitle, "", "", gNowPlaying[id].ImageUrl, roomid, "secondary", "True")        
    
end 
function ClearNowPlayingQueue(queueId)
    print("ClearNowPlayingQueue(queueId=" .. queueId .. ")")
    --gNowPlaying = {}
    --gCurrentSongIndex = 1    
    
    -- Update all navigators that care
    SendQueueChangedEvent(queueId, gNowPlaying)
end
function SelectInternetRadio(idBinding, roomId, url, info, vol)
    local tResponse = {
        ["ROOM_ID"] = roomId,
        ["STATION_URL"] = url,
        ["QUEUE_INFO"] = info,
    }    
    if (vol ~= nil) then
        tResponse["VOLUME"] = vol    
    end    
            
    SendToProxy(idBinding, "SELECT_INTERNET_RADIO", tResponse, "COMMAND")    
end

function UpdateMediaInfo(idBinding, line1, line2, line3, line4, url, roomId , merge)
        tResponse = {
            ["LINE1"] = line1,
            ["LINE2"] = line2,
            ["LINE3"] = line3,
            ["LINE4"] = line4, 
            ["IMAGEURL"] = url,
            ["ROOMID"] = roomId,
            ["MERGE"] = merge,
        }            
        SendToProxy(idBinding, "UPDATE_MEDIA_INFO", tResponse, "COMMAND", true)
end

泊生.jpg

泊生1.png

泊生2.png

泊生.png

泊生是.png

图片1.jpg

图片.jpg

Link to comment
Share on other sites

2 answers to this question

Recommended Posts


Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.