Author: titmuss
Date: Thu Jan 31 05:50:10 2008
New Revision: 1718

URL: http://svn.slimdevices.com?rev=1718&root=Jive&view=rev
Log:
 [EMAIL PROTECTED] (orig r1712):  bklaas | 2008-01-30 23:23:20 +0000
 Bug: 6848
 Description:
 
 Have jive handle the single-item 'NOTHING' and 'OFF' "playlists" delivered 
when the player has and empty playlist and is off, respectively.
 
 Don't use _uses metatable for albumitemNoAction, as it delivers an icon to the 
skin element that it inexplicably inherits from albumitem, even though it's 
explicitly left out
 
 Add new player notification for playerPlaylistSize that SlimBrowser uses to 
determine whether to display the 'NOTHING' window or re-show the current 
playlist
 
 Add two new player methods, getPlaylistSize and getPlayerPower
 
 Add string for SLIMBROWSER_OFF
 

Modified:
    trunk/   (props changed)
    trunk/jive/src/pkg/jive/share/applets/DefaultSkin/DefaultSkinApplet.lua
    trunk/jive/src/pkg/jive/share/applets/SlimBrowser/SlimBrowserApplet.lua
    trunk/jive/src/pkg/jive/share/applets/SlimBrowser/strings.txt
    trunk/jive/src/pkg/jive/share/jive/slim/Player.lua

Propchange: trunk/
------------------------------------------------------------------------------
--- svk:merge (original)
+++ svk:merge Thu Jan 31 05:50:10 2008
@@ -1,3 +1,3 @@
-bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/branches/7.0:1711
+bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/branches/7.0:1712
 bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/branches/SN:1083
 bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/branches/scrolling:1378

Modified: 
trunk/jive/src/pkg/jive/share/applets/DefaultSkin/DefaultSkinApplet.lua
URL: 
http://svn.slimdevices.com/trunk/jive/src/pkg/jive/share/applets/DefaultSkin/DefaultSkinApplet.lua?rev=1718&root=Jive&r1=1717&r2=1718&view=diff
==============================================================================
--- trunk/jive/src/pkg/jive/share/applets/DefaultSkin/DefaultSkinApplet.lua 
(original)
+++ trunk/jive/src/pkg/jive/share/applets/DefaultSkin/DefaultSkinApplet.lua Thu 
Jan 31 05:50:10 2008
@@ -963,10 +963,31 @@
        s.albumitem.icon.img = Surface:loadImage(imgpath .. 
"menu_album_noartwork.png")
        s.albumitem.icon.padding = { 8, 0, 0, 0 }
 
-
+       s.albumitemNoAction = {}
+       s.albumitemNoAction.order = { "text" }
+       s.albumitemNoAction.text = {}
+       s.albumitemNoAction.text.w = WH_FILL
+       s.albumitemNoAction.text.padding = { 6, 8, 8, 8 }
+       s.albumitemNoAction.text.align = "top-left"
+       s.albumitemNoAction.text.font = FONT_13px
+       s.albumitemNoAction.text.lineHeight = 16
+       s.albumitemNoAction.text.line = {
+               {
+                       font = FONT_BOLD_13px,
+                       height = 17
+               }
+       }
+       s.albumitemNoAction.text.fg = TEXT_COLOR
+       s.albumitemNoAction.text.sh = TEXT_SH_COLOR
+
+
+--FIXME: albumitemNoAction can't use _uses because it sticks an icon on the 
screen
+--[[
        s.albumitemNoAction = _uses(s.albumitem, {
-                                       order = { 'text' }
+                                       order = { 'text' },
+                                       icon  = nil
                                })
+--]]
        s.selected.albumitemNoAction = _uses(s.albumitemNoAction)
 
        -- selected item with artwork and song info

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=1718&root=Jive&r1=1717&r2=1718&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 31 05:50:10 2008
@@ -114,6 +114,7 @@
 -- The path of enlightenment
 local _curStep = false
 local _statusStep = false
+local _emptyStep = false
 
 -- Our main menu/handlers
 local _playerMenus = {}
@@ -1277,12 +1278,6 @@
 
                        if style == 'item' then
                                local chunk = db:chunk()
-                               local bActionPlay = _safeDeref(chunk, 'base', 
'actions', 'play')
-                               local iActionPlay = _safeDeref(item, 'actions', 
'play')
-                               local bActionAdd  = _safeDeref(chunk, 'base', 
'actions', 'add')
-                               local iActionAdd  = _safeDeref(item, 'actions', 
'add')
-                               local bActionGo   = _safeDeref(chunk, 'base', 
'actions', 'go')
-                               local iActionGo   = _safeDeref(item, 'actions', 
'go')
                        end
                        
                        if current then
@@ -1657,11 +1652,29 @@
        _performJSONAction(jsonAction, 0, 200, sink)
 end
 
+-- showEmptyPlaylist
+-- if the player is off or if the playlist is empty, we replace _statusStep 
with this window
+function showEmptyPlaylist(token)
+
+       local window = Window("window", _string('SLIMBROWSER_NOW_PLAYING'), 
'currentplaylisttitle')
+       local menu = SimpleMenu("menu")
+       menu:addItem({
+                    text = _string(token),
+                       style = 'albumitemNoAction'
+       })
+       window:addWidget(menu)
+
+       _emptyStep = {}
+       _emptyStep.window = window
+
+       return window
+
+end
+
 -- showPlaylist
 --
 function showPlaylist()
        if _statusStep then
-               log:debug("showPlaylist()")
 
                -- arrange so that menuListener works
                _statusStep.origin = _curStep
@@ -1671,10 +1684,21 @@
                -- if there is only one item in the playlist, bring the 
selected item to top
                local playerStatus = _player:getPlayerStatus()
                local playlistSize = playerStatus and 
playerStatus.playlist_tracks
+               local playerPower = _player:getPlayerPower()
+
+               if playerPower == 0 then
+                       local customWindow = 
showEmptyPlaylist('SLIMBROWSER_OFF') 
+                       customWindow:show()
+                       return EVENT_CONSUME
+               end
 
                if playlistSize == 0 then
-                       
_statusStep.window:setTitle(_string("SLIMBROWSER_NOW_PLAYING"))
-               end
+                       log:warn('mark1')
+                       local customWindow = 
showEmptyPlaylist('SLIMBROWSER_NOTHING') 
+                       customWindow:show()
+                       return EVENT_CONSUME
+               end
+
 
                if playlistSize == nil or (playlistSize and playlistSize <= 1) 
then
                        _statusStep.menu["_lastSelectedIndex"] = 1
@@ -1712,13 +1736,80 @@
 
                _statusStep.window:show()
 
+
                return EVENT_CONSUME
        end
        return EVENT_UNUSED
 
 end
 
+function notify_playerPlaylistSize(self, player, playlistSize)
+       log:warn('SlimBrowser.notify_playerPlaylistSize')
+       if _player ~= player then
+               return
+       end
+
+       local power = _player:getPlayerPower()
+       local step = _statusStep
+       local emptyStep = _emptyStep
+
+       -- display 'NOTHING' if the player is on and there aren't any tracks in 
the playlist
+       if power and playlistSize == 0 then
+               local customWindow = showEmptyPlaylist('SLIMBROWSER_NOTHING') 
+               if emptyStep then
+                       customWindow:replace(emptyStep.window, 
Window.transitionFadeIn)
+               end
+               if step.window then
+                       customWindow:replace(step.window, 
Window.transitionFadeIn)
+               end
+       -- make sure we have step.window replace emptyStep.window when there 
are tracks
+       elseif playlistSize and emptyStep then
+               if step.window then
+                       step.window:replace(emptyStep.window, 
Window.transitionFadeIn)
+               end
+       
+       end
+       
+end
+
+function notify_playerPower(self, player, power)
+       log:warn('SlimBrowser.notify_playerPower')
+       if _player ~= player then
+               return
+       end
+       local playerStatus = player:getPlayerStatus()
+       if not playerStatus then
+               log:warn('no player status')
+               return
+       end
+
+       local playlistSize = playerStatus.playlist_tracks
+
+       -- when player goes off, user should get single item styled 'Off' 
playlist
+       local step = _statusStep
+       local emptyStep = _emptyStep
+
+       if step.menu then
+               -- show 'OFF' in playlist window when the player is off
+               if power == 0 then
+                       local customWindow = 
showEmptyPlaylist('SLIMBROWSER_OFF') 
+                       if emptyStep then
+                               customWindow:replace(emptyStep.window, 
Window.transitionFadeIn)
+                       end
+                       if step.window then
+                               customWindow:replace(step.window, 
Window.transitionFadeIn)
+                       end
+               elseif power == 1 and emptyStep then
+                       -- only with the player on and a non-zero playlist do 
we bring the playlist up
+                       if step.window then
+                               step.window:replace(emptyStep.window, 
Window.transitionFadeIn)
+                       end
+               end
+       end
+end
+
 function notify_playerModeChange(self, player, mode)
+       log:warn('SlimBrowser.notify_playerModeChange')
        if _player ~= player then
                return
        end
@@ -1738,6 +1829,7 @@
 end
 
 function notify_playerPlaylistChange(self, player)
+       log:warn('SlimBrowser.notify_playerPlaylistChange')
        if _player ~= player then
                return
        end
@@ -1754,7 +1846,7 @@
 end
 
 function notify_playerTrackChange(self, player, nowplaying)
-       log:debug('SlimBrowser.notify_playerTrackChange')
+       log:warn('SlimBrowser.notify_playerTrackChange')
 
        if _player ~= player then
                return
@@ -1881,6 +1973,18 @@
        _requestStatus()
        _server.comet:endBatch()
 
+       -- look to see if the playlist has size and the state of player power
+       -- if playlistSize is 0 or power is off, we show and empty playlist
+       local playerPower = _player:getPlayerPower()
+       log:warn('power: ', playerPower)
+       if playerPower == 0 then
+               log:warn('you be empty')
+               local customWindow = showEmptyPlaylist('SLIMBROWSER_OFF')
+               if _statusStep.window then
+                       customWindow:replace(_statusStep.window, 
Window.transitionFadeIn)
+               end
+       end
+
        -- add a fullscreen popup that waits for the _menuSink to load
        _menuReceived = false
        _connectingToPlayer(self, player)

Modified: trunk/jive/src/pkg/jive/share/applets/SlimBrowser/strings.txt
URL: 
http://svn.slimdevices.com/trunk/jive/src/pkg/jive/share/applets/SlimBrowser/strings.txt?rev=1718&root=Jive&r1=1717&r2=1718&view=diff
==============================================================================
--- trunk/jive/src/pkg/jive/share/applets/SlimBrowser/strings.txt (original)
+++ trunk/jive/src/pkg/jive/share/applets/SlimBrowser/strings.txt Thu Jan 31 
05:50:10 2008
@@ -90,6 +90,14 @@
        IT      Niente
        NL      Niets
 
+SLIMBROWSER_OFF
+       DE      Aus
+       EN      Off
+       ES      Apagado
+       FR      Désactivé
+       IT      Disattivato
+       NL      Uit
+
 SLIMBROWSER_CONNECTING_TO
        DE      Verbindung mit %s
        EN      Connecting to\n%s
@@ -113,3 +121,4 @@
        FR      Volume (En sourdine)
        IT      Volume (Audio disattivato)
        NL      Volume (Gedempt)
+

Modified: trunk/jive/src/pkg/jive/share/jive/slim/Player.lua
URL: 
http://svn.slimdevices.com/trunk/jive/src/pkg/jive/share/jive/slim/Player.lua?rev=1718&root=Jive&r1=1717&r2=1718&view=diff
==============================================================================
--- trunk/jive/src/pkg/jive/share/jive/slim/Player.lua (original)
+++ trunk/jive/src/pkg/jive/share/jive/slim/Player.lua Thu Jan 31 05:50:10 2008
@@ -21,6 +21,7 @@
  playerTrackChange
  playerModeChange
  playerPlaylistChange
+ playerPlaylistSize
 
 =head1 FUNCTIONS
 
@@ -126,6 +127,15 @@
        end
 end
 
+local function _setPlayerPlaylistSize(self, playlistSize)
+       log:debug("_setPlayerPlaylistSize")
+
+       if playlistSize != self.playlistSize then
+               self.playlistSize = playlistSize
+               self.jnt:notify('playerPlaylistSize', self, playlistSize)
+       end
+end
+
 
 local function _setPlayerPower(self, power)
        log:debug("_setPlayerPower")
@@ -355,6 +365,31 @@
        return self.playlist_timestamp
 end
 
+--[[
+
+=head2 jive.slim.Player:getPlaylistSize()
+
+returns the playlist size for a given player object
+
+=cut
+--]]
+function getPlaylistSize(self)
+       return self.playlistSize
+end
+
+
+--[[
+
+=head2 jive.slim.Player:getPlayerPower()
+
+returns the playerPower for a given player object
+
+=cut
+--]]
+function getPlayerPower(self)
+       return self.power
+end
+
 
 --[[
 
@@ -674,6 +709,8 @@
        self.trackDuration = event.data.duration
 
        _setConnected(self, self.state["player_connected"])
+       _setPlayerPlaylistSize(self, tonumber(event.data.playlist_tracks))
+       _setPlayerPower(self, tonumber(self.power))
 
        _setPlayerModeChange(self, event.data.mode)
 

_______________________________________________
Jive-checkins mailing list
[email protected]
http://lists.slimdevices.com/cgi-bin/mailman/listinfo/jive-checkins

Reply via email to