Commit 34315944 authored by Rafaël Carré's avatar Rafaël Carré

Makes vlc the 2nd Media Player in history to implement the MPRIS draft (after audacious)

parent 979f5cc2
...@@ -85,6 +85,16 @@ def TrackChange(Track): ...@@ -85,6 +85,16 @@ def TrackChange(Track):
t = Track["title"] t = Track["title"]
except: except:
t = Track["URI"] t = Track["URI"]
try:
length = Track["length"]
except:
length = 0
if length > 0:
time_s.set_range(0,Track["length"])
time_s.set_sensitive(True)
else:
# disable the position scale if length isn't available
time_s.set_sensitive(False)
# update the labels # update the labels
l_artist.set_text(a) l_artist.set_text(a)
l_title.set_text(t) l_title.set_text(t)
...@@ -110,6 +120,7 @@ def Connect(name): ...@@ -110,6 +120,7 @@ def Connect(name):
# determine if the Media Player is playing something # determine if the Media Player is playing something
if player.GetStatus() == 0: if player.GetStatus() == 0:
playing = True playing = True
TrackChange(player.GetMetadata())
# gets its identity (name and version) # gets its identity (name and version)
identity = root.Identity() identity = root.Identity()
......
...@@ -97,7 +97,7 @@ DBUS_METHOD( Quit ) ...@@ -97,7 +97,7 @@ DBUS_METHOD( Quit )
} }
DBUS_METHOD( PositionGet ) DBUS_METHOD( PositionGet )
{ /* returns position as an int in the range [0;1000] */ { /* returns position in milliseconds */
REPLY_INIT; REPLY_INIT;
OUT_ARGUMENTS; OUT_ARGUMENTS;
vlc_value_t position; vlc_value_t position;
...@@ -110,8 +110,8 @@ DBUS_METHOD( PositionGet ) ...@@ -110,8 +110,8 @@ DBUS_METHOD( PositionGet )
i_pos = 0; i_pos = 0;
else else
{ {
var_Get( p_input, "position", &position ); var_Get( p_input, "time", &position );
i_pos = position.f_float * 1000 ; i_pos = position.i_time / 1000;
} }
pl_Release( ((vlc_object_t*) p_this) ); pl_Release( ((vlc_object_t*) p_this) );
ADD_INT32( &i_pos ); ADD_INT32( &i_pos );
...@@ -119,7 +119,7 @@ DBUS_METHOD( PositionGet ) ...@@ -119,7 +119,7 @@ DBUS_METHOD( PositionGet )
} }
DBUS_METHOD( PositionSet ) DBUS_METHOD( PositionSet )
{ /* set position from an int in the range [0;1000] */ { /* set position in milliseconds */
REPLY_INIT; REPLY_INIT;
vlc_value_t position; vlc_value_t position;
...@@ -145,8 +145,8 @@ DBUS_METHOD( PositionSet ) ...@@ -145,8 +145,8 @@ DBUS_METHOD( PositionSet )
if( p_input ) if( p_input )
{ {
position.f_float = ((float)i_pos) / 1000; position.i_time = i_pos * 1000;
var_Set( p_input, "position", position ); var_Set( p_input, "time", position );
} }
pl_Release( ((vlc_object_t*) p_this) ); pl_Release( ((vlc_object_t*) p_this) );
REPLY_SEND; REPLY_SEND;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment