Author: bklaas
Date: Thu Jan 17 12:51:21 2008
New Revision: 1489
URL: http://svn.slimdevices.com?rev=1489&root=Jive&view=rev
Log:
Allow for radio.png to be used as menu icon for remote streams that lack artwork
A workaround was required to force this image (and service provider icons) as
png instead of gd, because they either look like garbage in gd or don't work at
all.
Modified:
trunk/jive/src/pkg/jive/share/applets/SlimBrowser/SlimBrowserApplet.lua
trunk/jive/src/pkg/jive/share/jive/slim/SlimServer.lua
Modified:
trunk/jive/src/pkg/jive/share/applets/SlimBrowser/SlimBrowserApplet.lua
URL:
http://svn.slimdevices.com/trunk/jive/src/pkg/jive/share/applets/SlimBrowser/SlimBrowserApplet.lua?rev=1489&root=Jive&r1=1488&r2=1489&view=diff
==============================================================================
--- trunk/jive/src/pkg/jive/share/applets/SlimBrowser/SlimBrowserApplet.lua
(original)
+++ trunk/jive/src/pkg/jive/share/applets/SlimBrowser/SlimBrowserApplet.lua Thu
Jan 17 12:51:21 2008
@@ -176,7 +176,10 @@
-- artworkThumbUri
-- returns a URI to fetch artwork on the server
-- FIXME: should this be styled?
-local function _artworkThumbUri(iconId, size)
+local function _artworkThumbUri(iconId, size, imgFormat)
+
+ -- imgFormat can force to a different format than gd, the default
+ if not imgFormat then imgFormat = 'gd' end
-- we want a 56 pixel thumbnail if it wasn't specified
if not size then size = 56 end
@@ -198,11 +201,13 @@
local resizeFrag = '_' .. size .. 'x' .. size .. '_p' -- 'p' is for
padded
if thisIsAnId then
-- we want a 56 pixel thumbnail if it wasn't specified
- artworkUri = '/music/' .. iconId .. '/cover' .. resizeFrag ..
'.gd'
+ artworkUri = '/music/' .. iconId .. '/cover' .. resizeFrag ..
'.' .. imgFormat
elseif string.match(iconId, '.png') then
-- if this isn't a number, then we just want the path
-- with server-side resizing
- artworkUri = string.gsub(iconId, '.png', resizeFrag .. '.png')
+ -- and we don't want this in gd format, because that doesn't
work
+ imgFormat = 'png'
+ artworkUri = string.gsub(iconId, '.png', resizeFrag .. '.' ..
imgFormat)
-- otherwise punt
else
return iconId
@@ -380,6 +385,18 @@
}
end
+-- _staticArtworkThumbUri
+-- helper method for cobbling together a properly formed url for static content
+local function _staticArtworkThumbUri(path, ARTWORK_SIZE)
+ -- 'p' is for padded, png gives us transparency
+ local resizeFrag = '_' .. ARTWORK_SIZE .. 'x' .. ARTWORK_SIZE ..
'_p.png'
+ local artworkUri = path
+ -- replace .png with the resize params
+ if string.match(path, '.png') then
+ artworkUri = string.gsub(path, '.png', resizeFrag)
+ end
+ return artworkUri
+end
-- _artworkItem
-- updates a group widget with the artwork for item
@@ -400,10 +417,26 @@
-- Don't load artwork while accelerated
_server:cancelArtwork(icon)
else
- -- Fetch a remote image URL, sized to 56x56
- _server:fetchArtworkURL(item["icon"], icon, 56)
- end
-
+
+ local remoteContent = string.find(item['icon'],
'http://')
+ if remoteContent then
+ -- Fetch a remote image URL, sized to
56x56 (artwork from a streamed source)
+ _server:fetchArtworkURL(item["icon"],
icon, 56)
+ else
+ -- sometimes we have static img content
sent from SC (e.g., playlist icon)
+ _server:fetchArtworkThumb(item["icon"],
icon, _staticArtworkThumbUri, 56)
+ end
+ end
+
+ -- this is for the radio image-- remote URLs with no icon (Bug 6087)
+ elseif item["params"] and item["params"]["track_id"] then
+ if menuAccel and not
_server:artworkThumbCached(item["params"]["track_id"], 56) then
+ -- Don't load artwork while accelerated
+ _server:cancelArtwork(icon)
+ else
+ -- workaround: this needs to be png not gd because in
gd it looks like garbage
+ _server:fetchArtworkThumb(item["params"]["track_id"],
icon, _artworkThumbUri, 56, 'png')
+ end
else
_server:cancelArtwork(icon)
Modified: trunk/jive/src/pkg/jive/share/jive/slim/SlimServer.lua
URL:
http://svn.slimdevices.com/trunk/jive/src/pkg/jive/share/jive/slim/SlimServer.lua?rev=1489&root=Jive&r1=1488&r2=1489&view=diff
==============================================================================
--- trunk/jive/src/pkg/jive/share/jive/slim/SlimServer.lua (original)
+++ trunk/jive/src/pkg/jive/share/jive/slim/SlimServer.lua Thu Jan 17 12:51:21
2008
@@ -552,18 +552,19 @@
--[[
-=head2 jive.slim.SlimServer:fetchArtworkThumb(iconId, icon, uriGenerator, size)
+=head2 jive.slim.SlimServer:fetchArtworkThumb(iconId, icon, uriGenerator,
size, imgFormat)
The SlimServer object maintains an artwork cache. This function either loads
from the cache or
gets from the network the thumb for I<iconId>. A L<jive.ui.Surface> is used to
perform
I<icon>:setValue(). I<uriGenerator> must be a function that
computes the URI to request the artwork from the server from I<iconId> (i.e.
if needed, this
-method will call uriGenerator(iconId) and use the result as URI).
-
-
-=cut
---]]
-function fetchArtworkThumb(self, iconId, icon, uriGenerator, size)
+method will call uriGenerator(iconId) and use the result as URI). I<imgFormat>
is an optional
+argument sent to the uriGenerator. See applets.SlimBrowser._artworkThumbUri as
an example.
+
+
+=cut
+--]]
+function fetchArtworkThumb(self, iconId, icon, uriGenerator, size, imgFormat)
logcache:debug(self, ":fetchArtworkThumb(", iconId, ")")
if logcache:isDebug() then
@@ -608,7 +609,7 @@
-- queue up the request on a lifo
table.insert(self.artworkFetchQueue, {
key = iconId,
- url = uriGenerator(iconId, size),
+ url = uriGenerator(iconId, size, imgFormat),
size = size,
thumb = true
})
_______________________________________________
Jive-checkins mailing list
[email protected]
http://lists.slimdevices.com/cgi-bin/mailman/listinfo/jive-checkins