Displaying remote images in dialog boxes

Discuss your Lua playlist, album art and interface scripts.
Xavion
Blank Cone
Blank Cone
Posts: 22
Joined: 22 Jun 2011 06:13

Displaying remote images in dialog boxes

Postby Xavion » 25 Jun 2011 10:09

Given that the "vlc.dialog:add_image()" function only works with local images, what's the best way to display a remote image in a dialog box? I want to avoid using an external command (e.g. wget) to download the image to disk first. The extension shown in this article might do what I want, but I can't seem to find its source code anywhere. Does anyone know where I can find it or how to go about displaying remote images in dialog boxes?

Xavion
Blank Cone
Blank Cone
Posts: 22
Joined: 22 Jun 2011 06:13

Re: Displaying remote images in dialog boxes

Postby Xavion » 25 Jun 2011 14:00

I figured out how to work-around this inability. For the benefit of others, below is the code I'm using. I've assumed that artist image files (300x300) won't be larger than 1 MiB. Let me know if anyone knows of a better method.

Code: Select all

function get_artist_image_filename() local url = get_artist_image_url() if url == nil then return nil end local stream = vlc.stream(url) if stream == nil then return nil end local data = stream:read(1024*1024) if data == nil then return nil end local fname = os.tmpname() if fname == nil then return nil end --local fhandle = io.tmpfile() local fhandle = io.open(fname, "wb") --local fhandle = assert(io.open(fname, "wb")) if fhandle == nil then return nil end fhandle:write(data) fhandle:close() return fname end


Return to “Scripting VLC in lua”

Who is online

Users browsing this forum: No registered users and 16 guests