Author: titmuss
Date: Thu Jan 24 03:30:50 2008
New Revision: 1600
URL: http://svn.slimdevices.com?rev=1600&root=Jive&view=rev
Log:
[EMAIL PROTECTED] (orig r1593): bklaas | 2008-01-24 03:36:45 +0000
Bug: 5433, 5814, 5961, 6378, 6752
Description:
Send notification on playlist change (keyed by change in playlist_timestamp)
Add notification handler for playlist change in SlimBrowser
Clean up notification handler for track change in SlimBrowser
add method to retrieve playlist timestamp from player object
Modified:
trunk/ (props changed)
trunk/jive/src/pkg/jive/share/applets/SlimBrowser/SlimBrowserApplet.lua
trunk/jive/src/pkg/jive/share/jive/slim/Player.lua
Propchange: trunk/
------------------------------------------------------------------------------
--- svk:merge (original)
+++ svk:merge Thu Jan 24 03:30:50 2008
@@ -1,3 +1,3 @@
-bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/branches/7.0:1592
+bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/branches/7.0:1593
bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/branches/SN:1083
bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/branches/scrolling:1378
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=1600&root=Jive&r1=1599&r2=1600&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 24 03:30:50 2008
@@ -1667,8 +1667,7 @@
end
end
-
-function notify_playerTrackChange(self, player, nowplaying)
+function notify_playerPlaylistChange(self, player)
if _player ~= player then
return
end
@@ -1676,24 +1675,30 @@
local playerStatus = player:getPlayerStatus()
local step = _statusStep
- -- move selection if playing track is selected
- local moveSelection = (step.menu:getSelectedIndex() ==
step.db:playlistIndex())
-
- if step.db:updateStatus(playerStatus) then
- -- move selection if playlist has changed
- moveSelection = true
- end
-
- if moveSelection then
- step.menu:setSelectedIndex(step.db:playlistIndex())
- else
- step.menu:reLayout()
- end
+ step.db:updateStatus(playerStatus)
+ step.menu:reLayout()
-- does the playlist need loading?
_requestStatus()
-end
-
+
+end
+
+function notify_playerTrackChange(self, player, nowplaying)
+
+ log:warn('SlimBrowser.notify_playerTrackChange')
+ if _player ~= player then
+ return
+ end
+ local playerStatus = player:getPlayerStatus()
+ local step = _statusStep
+
+ step.db:updateStatus(playerStatus)
+ step.menu:setSelectedIndex(step.db:playlistIndex())
+ step.menu:reLayout()
+
+ -- does the playlist need loading?
+ _requestStatus()
+end
-- notify_playerNewName
-- this is called when the player name changes
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=1600&root=Jive&r1=1599&r2=1600&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 24 03:30:50 2008
@@ -20,6 +20,7 @@
playerDelete (performed by SlimServer)
playerTrackChange
playerModeChange
+ playerPlaylistChange
=head1 FUNCTIONS
@@ -29,7 +30,7 @@
local debug = require("jive.utils.debug")
-- stuff we need
-local _assert, setmetatable, tonumber, tostring, pairs = _assert,
setmetatable, tonumber, tostring, pairs
+local _assert, setmetatable, tonumber, tostring, pairs, ipairs = _assert,
setmetatable, tonumber, tostring, pairs, ipairs
local os = require("os")
local math = require("math")
@@ -82,9 +83,11 @@
log:warn("########### ", err)
elseif chunk then
- --log:info(chunk)
-
local proc = "_process_" .. cmd[1]
+ if cmd[1] == 'status' then
+ log:debug('stored playlist timestamp: ',
self.playlist_timestamp)
+ log:debug(' new playlist timestamp: ',
chunk.data.playlist_timestamp)
+ end
if self[proc] then
self[proc](self, chunk)
end
@@ -159,10 +162,20 @@
return nil
end
+-- _setPlayerPlaylistChange()
+-- sends notifications when anything gets sent about the playlist changing
+local function _setPlayerPlaylistChange(self, timestamp)
+ log:debug("Player:_setPlayerPlaylistChange")
+ if self.playlist_timestamp != timestamp then
+ self.playlist_timestamp = timestamp
+ self.jnt:notify('playerPlaylistChange', self)
+ end
+end
+
-- _setPlayerTrackChange()
-- sends notifications when a change occurs to the currently playing track
-local function _setPlayerTrackChange(self, nowPlaying, data)
- log:debug("_setPlayerTrackChange")
+local function _setPlayerTrackChange(self, nowPlaying)
+ log:debug("Player:_setPlayerTrackChange")
if self.nowPlaying != nowPlaying then
self.nowPlaying = nowPlaying
@@ -304,6 +317,20 @@
return trackElapsed, self.trackDuration
end
+end
+
+--[[
+
+=head2 jive.slim.Player:getPlaylistTimestamp()
+
+returns the playlist timestamp for a given player object
+the timestamp is an indicator of the last time the playlist changed
+it serves as a good check to see whether playlist items should be refreshed
+
+=cut
+--]]
+function getPlaylistTimestamp(self)
+ return self.playlist_timestamp
end
@@ -625,11 +652,11 @@
local nowPlaying = _whatsPlaying(event.data)
- _setPlayerTrackChange(self, nowPlaying, event.data)
+ _setPlayerTrackChange(self, nowPlaying)
+ _setPlayerPlaylistChange(self, event.data.playlist_timestamp)
self:updateIconbar()
end
-
function artworkThumbUri (iconId, size)
return '/music/' .. iconId .. '/cover_' .. size .. 'x' .. size ..
'_f_000000.jpg'
_______________________________________________
Jive-checkins mailing list
[email protected]
http://lists.slimdevices.com/cgi-bin/mailman/listinfo/jive-checkins