PDA

View Full Version : Updating XPL support



John Gorst
2005-05-26, 03:17
There is talk about updating some aspects of the slimserver xpl support
to include these features:

- send xpl message when power toggles (web interface or remote)
- send xpl message when new song starts playing
- send xpl message at the end of a playlist

These changes have been created by someone else, but does not have the
time or energy to get them integrated with the slimserver nightlys.

I do not have much experience of this either.

The changes are:
- quite substatial changes to xpl.pm (but this is quite a static file so
will be easy to supply an updated version)
- addition of 3 segments in source.pm
- addition of 3 segments in command.pm

What is the best way to supply you with the changes made to these files.
They have been made to a nightly from a few days ago.

Cheers

kdf
2005-05-26, 03:31
Quoting John Gorst <john_gorst (AT) hotmail (DOT) com>:

>
> What is the best way to supply you with the changes made to these files.
> They have been made to a nightly from a few days ago.

diff -upB is preferred.

one for each, or all together is up to you.

-kdf

John Gorst
2005-05-26, 03:38
kdf wrote:
> Quoting John Gorst <john_gorst (AT) hotmail (DOT) com>:
>
>
>>What is the best way to supply you with the changes made to these files..
>>They have been made to a nightly from a few days ago.
>
>
> diff -upB is preferred.
>
> one for each, or all together is up to you.

You will have to forgive my ignorance!
If the file has been updated since the changes were made will this not
mess things up - or does diff take account of this.

If I manually make the changes to the latest nightly and then do a diff
will this be the most desireable?

Cheers

Marc Sherman
2005-05-26, 04:16
John Gorst wrote:
>
> You will have to forgive my ignorance!
> If the file has been updated since the changes were made will this not
> mess things up - or does diff take account of this.
>
> If I manually make the changes to the latest nightly and then do a diff
> will this be the most desireable?

If you just make a note of which svn revision your diff was made
against, one of the developers will be able to merge it properly.

- Marc

John Gorst
2005-05-26, 05:48
kdf wrote:

> Quoting John Gorst <john_gorst (AT) hotmail (DOT) com>:
>
>
>> What is the best way to supply you with the changes made to these
files..
>> They have been made to a nightly from a few days ago.
>
>
>
> diff -upB is preferred.


I have done that and I get text output at the command line which seems
to include all the changes I have made. Do I save the output as a file?

I have attahced a new copy of xPL.pm as that file /never/ changes (as
well as the other files)! (.... message seemed to have got bounced
because of attachments so I have resent it without)

The diff output for Source.pm,Command.pm and xPL.pm are included below
(made against 26/5/5 RPM 6.1 nightly).

Thanks to anyone who can review the changes and possible submit them.

Updated features
- send xpl message when power toggles (web interface or remote)
- send xpl message when new song starts playing with artist,album and
title info
- send xpl message at the end of a playlist

Bugs
- artist, album and title info are missing from xpl message if a song is
skipped

[john@mandrake Desktop]$ diff -upB Commandold.pm Command.pm
--- Commandold.pm 2005-05-26 13:05:53.732277816 +0100
+++ Command.pm 2005-05-26 11:54:18.000000000 +0100
@@ -1,6 +1,6 @@
package Slim::Control::Command;

-# $Id$
+# $Id: Command.pm 3242 2005-05-18 15:09:55Z fred $
#
# SlimServer Copyright (C) 2001-2004 Sean Adams, Slim Devices Inc.
# This program is free software; you can redistribute it and/or
@@ -19,6 +19,7 @@ use Slim::Music::Info;
use Slim::Utils::Misc;
use Slim::Utils::Scan;
use Slim::Utils::Strings qw(string);
+use Slim::Control::xPL;

our %executeCallbacks = ();

@@ -745,6 +746,11 @@ sub execute {

$client->power(!$client->power());

+ # send xpl message when power toggles
+ if (Slim::Utils::Prefs::get('xplsupport')) {
+ Slim::Control::xPL::sendXplHBeatMsg($client,1);
+ }
+
} elsif ($p1 eq "?") {

$p1 = $client->power();
@@ -757,6 +763,11 @@ sub execute {
}

$client->power($p1);
+
+ # send xpl message when power toggles
+ if (Slim::Utils::Prefs::get('xplsupport')) {
+ Slim::Control::xPL::sendXplHBeatMsg($client,1);
+ }

if ($p1 eq "0") {
# Powering off cancels sleep...




[john@mandrake Desktop]$ diff -upB Sourceold.pm Source.pm
--- Sourceold.pm 2005-05-26 13:06:34.932356005 +0100
+++ Source.pm 2005-05-26 11:57:35.000000000 +0100
@@ -1,6 +1,6 @@
package Slim::Player::Source;

-# $Id$
+# $Id: Source.pm 3295 2005-05-25 18:26:40Z adrian $

# SlimServer Copyright (C) 2001-2004 Sean Adams, Slim Devices Inc.
# This program is free software; you can redistribute it and/or
@@ -16,6 +16,7 @@ use IO::Socket qw(:DEFAULT :crlf);
use Time::HiRes;
use Fcntl qw(SEEK_CUR);
use bytes;
+use Slim::Control::xPL;

BEGIN {
if ($^O =~ /Win32/) {
@@ -827,6 +828,11 @@ sub gotoNext {
# connection to the client.
dropStreamingConnection($client);

+ # send xpl to tell them we're done
+ if (Slim::Utils::Prefs::get('xplsupport')) {
+ Slim::Control::xPL::sendXplStatusMsg($client,"end of list");
+ }
+
$client->update();

return 0;
@@ -1472,6 +1478,11 @@ sub openSong {
binmode($client->audioFilehandle());
}

+ # force xpl msg for new song
+ if (Slim::Utils::Prefs::get('xplsupport')) {
+ Slim::Control::xPL::sendXplHBeatMsg($client, 1);
+ }
+
# keep track of some stats for this track
$track->set('playCount' => ($track->playCount() || 0)
+ 1);
$track->set('lastPlayed' => time());




[john@mandrake Desktop]$ diff -upB xPLold.pm xPL.pm
--- xPLold.pm 2005-05-26 13:05:22.628748304 +0100
+++ xPL.pm 2005-05-26 12:47:28.000000000 +0100
@@ -17,6 +17,7 @@ use strict;
use IO::Socket;
use Slim::Utils::Prefs;
use Sys::Hostname;
+use Slim::DataStores::DBI::DBIStore;

my $xpl_source = "slimdev-slimserv";
my $localip;
@@ -245,27 +248,42 @@ sub sendXplHBeatMsg {
my $clientName = validInstance($client->name);
my $playmode = $client->playmode;
my $song = $client->currentplayingsong();
- my $prevline1 = $client->prevline1();
+ my $prevline1 = $client->prevline1();
my $prevline2 = $client->prevline2();

+ my $album = " ";
+ my $artist = " ";
+ my $trackname = " ";
+ my $power = $client->power();
+
if ($playmode eq 'play') {
- $playmode = "playing";
+ $playmode = "playing";
+ my $currentDB = Slim::DataStores::DBI::DBIStore->new();
+ my $url = Slim::Player::Playlist::song($client);
+ my $track = ref $url ? $url :
$currentDB->objectForUrl($url, 1, 1);
+ $album = $track->album()->title();
+ $artist = $track->artist()->name();
+ $trackname = Slim::Music::Info::getCurrentTitle($client,
Slim::Player::Playlist::song($client));
+ # if the song name has the track number at the beginning,
remove it
+ $trackname =~ s/^[0-9]*\.//g;
+ $trackname =~ s/^ //g;
} elsif ($playmode eq 'stop') {
- $playmode = "stopped";
- } elsif ($playmode eq 'pause') {
- $playmode = "paused";
- }
+ $playmode = "stopped";
+ } elsif ($playmode eq 'pause') {
+ $playmode = "paused";
+ }

if (defined($_[1])) {
$msg = "status=$playmode";
- $msg =
"$msg\nsong=$song\nline1=$prevline1\nline2=$prevlin e2";
+ $msg =
"$msg\nARTIST=$artist\nALBUM=$album\nTRACK=$trackna me\nPOWER=$power";
sendxplmsg("xpl-stat",
- "*","audio.slimserv",
+ "*","audio.basic",
$msg,
$clientName);
} else {
$msg =
"interval=$xpl_interval\nport=$xpl_port\nremote-ip=$localip\nschema=audio.slimserv\nstatus=$playmo de";
- $msg =
"$msg\nsong=$song\nline1=$prevline1\nline2=$prevlin e2";
+ $msg =
"$msg\nsong=$song\nline1=$prevline1\nline2=$prevlin e2";
+ $msg =
"$msg\nARTIST=$artist\nALBUM=$album\nTRACK=$trackna me\nPOWER=$power";
sendxplmsg("xpl-stat",
"*","hbeat.app",
$msg,
@@ -283,6 +301,19 @@ sub sendxplhbeat {

Slim::Utils::Timers::setTimer("", Time::HiRes::time() +
($xpl_interval*60), \&sendxplhbeat);
}
+sub sendXplStatusMsg {
+ my $msg;
+ my $client = $_[0];
+ my $status = $_[1];
+ my $clientName = validInstance($client->name);
+ my $playmode = $client->playmode;
+ $msg = "status=$playmode";
+ $msg = "$msg\nupdate=$status";
+ sendxplmsg("xpl-stat",
+ "*","audio.slimserv",
+ $msg,
+ $clientName);
+}

# Generic routine for sending an xPL message.
sub sendxplmsg {

kdf
2005-05-26, 06:34
Quoting John Gorst <john_gorst (AT) hotmail (DOT) com>:

> You will have to forgive my ignorance!
> If the file has been updated since the changes were made will this not
> mess things up - or does diff take account of this.

if you make a diff against the versions from a couple days ago, it will be fine.

> If I manually make the changes to the latest nightly and then do a diff
> will this be the most desireable?

that will work too :)

-kdf

John Gorst
2005-05-26, 08:09
> Bugs
> - artist, album and title info are missing from xpl message if a song is
> skipped

New bug
When playing an AlienBBC stream I get the following error and the server
crashes just before (presumeably) an xpl.heartbeat messages is going to
be sent (one is automatically sent every five minutes)

Can't call method "title" on an undefined value at
/usr/local/slimserver/Slim/Control/xPL.pm line 264.

The offending line is $album = $track->album()->title();

Should this (minor) error cause slimserver to crash! Presumeably this is
something 'special' with alienBBC streams (?other radio streams) not
having the typical album/artist/title info.

If this information is not known should it not just return 'unknown'.

Cheers

>
> [john@mandrake Desktop]$ diff -upB Commandold.pm Command.pm
> --- Commandold.pm 2005-05-26 13:05:53.732277816 +0100
> +++ Command.pm 2005-05-26 11:54:18.000000000 +0100
> @@ -1,6 +1,6 @@
> package Slim::Control::Command;
>
> -# $Id$
> +# $Id: Command.pm 3242 2005-05-18 15:09:55Z fred $
> #
> # SlimServer Copyright (C) 2001-2004 Sean Adams, Slim Devices Inc.
> # This program is free software; you can redistribute it and/or
> @@ -19,6 +19,7 @@ use Slim::Music::Info;
> use Slim::Utils::Misc;
> use Slim::Utils::Scan;
> use Slim::Utils::Strings qw(string);
> +use Slim::Control::xPL;
>
> our %executeCallbacks = ();
>
> @@ -745,6 +746,11 @@ sub execute {
>
> $client->power(!$client->power());
>
> + # send xpl message when power toggles
> + if
> (Slim::Utils::Prefs::get('xplsupport')) {
> + Slim::Control::xPL::sendXplHBeatMsg($client,1);
> + }
> +
> } elsif ($p1 eq "?") {
>
> $p1 = $client->power();
> @@ -757,6 +763,11 @@ sub execute {
> }
>
> $client->power($p1);
> +
> + # send xpl message when power toggles
> + if
> (Slim::Utils::Prefs::get('xplsupport')) {
> + Slim::Control::xPL::sendXplHBeatMsg($client,1);
> + }
>
> if ($p1 eq "0") {
> # Powering off cancels sleep...
>
>
>
>
> [john@mandrake Desktop]$ diff -upB Sourceold.pm Source.pm
> --- Sourceold.pm 2005-05-26 13:06:34.932356005 +0100
> +++ Source.pm 2005-05-26 11:57:35.000000000 +0100
> @@ -1,6 +1,6 @@
> package Slim::Player::Source;
>
> -# $Id$
> +# $Id: Source.pm 3295 2005-05-25 18:26:40Z adrian $
>
> # SlimServer Copyright (C) 2001-2004 Sean Adams, Slim Devices Inc.
> # This program is free software; you can redistribute it and/or
> @@ -16,6 +16,7 @@ use IO::Socket qw(:DEFAULT :crlf);
> use Time::HiRes;
> use Fcntl qw(SEEK_CUR);
> use bytes;
> +use Slim::Control::xPL;
>
> BEGIN {
> if ($^O =~ /Win32/) {
> @@ -827,6 +828,11 @@ sub gotoNext {
> # connection to the client.
> dropStreamingConnection($client);
>
> + # send xpl to tell them we're done
> + if
> (Slim::Utils::Prefs::get('xplsupport')) {
> + Slim::Control::xPL::sendXplStatusMsg($client,"end of list");
> + }
> +
> $client->update();
>
> return 0;
> @@ -1472,6 +1478,11 @@ sub openSong {
> binmode($client->audioFilehandle());
> }
>
> + # force xpl msg for new song
> + if (Slim::Utils::Prefs::get('xplsupport')) {
> + Slim::Control::xPL::sendXplHBeatMsg($client, 1);
> + }
> +
> # keep track of some stats for this track
> $track->set('playCount' => ($track->playCount() || 0) +
> 1);
> $track->set('lastPlayed' => time());
>
>
>
>
> [john@mandrake Desktop]$ diff -upB xPLold.pm xPL.pm
> --- xPLold.pm 2005-05-26 13:05:22.628748304 +0100
> +++ xPL.pm 2005-05-26 12:47:28.000000000 +0100
> @@ -17,6 +17,7 @@ use strict;
> use IO::Socket;
> use Slim::Utils::Prefs;
> use Sys::Hostname;
> +use Slim::DataStores::DBI::DBIStore;
>
> my $xpl_source = "slimdev-slimserv";
> my $localip;
> @@ -245,27 +248,42 @@ sub sendXplHBeatMsg {
> my $clientName = validInstance($client->name);
> my $playmode = $client->playmode;
> my $song = $client->currentplayingsong();
> - my $prevline1 = $client->prevline1();
> + my $prevline1 = $client->prevline1();
> my $prevline2 = $client->prevline2();
>
> + my $album = " ";
> + my $artist = " ";
> + my $trackname = " ";
> + my $power = $client->power();
> +
> if ($playmode eq 'play') {
> - $playmode = "playing";
> + $playmode = "playing";
> + my $currentDB = Slim::DataStores::DBI::DBIStore->new();
> + my $url = Slim::Player::Playlist::song($client);
> + my $track = ref $url ? $url :
> $currentDB->objectForUrl($url, 1, 1);
> + $album = $track->album()->title();
> + $artist = $track->artist()->name();
> + $trackname = Slim::Music::Info::getCurrentTitle($client,
> Slim::Player::Playlist::song($client));
> + # if the song name has the track number at the beginning,
> remove it
> + $trackname =~ s/^[0-9]*\.//g;
> + $trackname =~ s/^ //g;
> } elsif ($playmode eq 'stop') {
> - $playmode = "stopped";
> - } elsif ($playmode eq 'pause') {
> - $playmode = "paused";
> - }
> + $playmode = "stopped";
> + } elsif ($playmode eq 'pause') {
> + $playmode = "paused";
> + }
>
> if (defined($_[1])) {
> $msg = "status=$playmode";
> - $msg =
> "$msg\nsong=$song\nline1=$prevline1\nline2=$prevlin e2";
> + $msg =
> "$msg\nARTIST=$artist\nALBUM=$album\nTRACK=$trackna me\nPOWER=$power";
> sendxplmsg("xpl-stat",
> - "*","audio.slimserv",
> + "*","audio.basic",
> $msg,
> $clientName);
> } else {
> $msg =
> "interval=$xpl_interval\nport=$xpl_port\nremote-ip=$localip\nschema=audio.slimserv\nstatus=$playmo de";
>
> - $msg =
> "$msg\nsong=$song\nline1=$prevline1\nline2=$prevlin e2";
> + $msg =
> "$msg\nsong=$song\nline1=$prevline1\nline2=$prevlin e2";
> + $msg =
> "$msg\nARTIST=$artist\nALBUM=$album\nTRACK=$trackna me\nPOWER=$power";
> sendxplmsg("xpl-stat",
> "*","hbeat.app",
> $msg,
> @@ -283,6 +301,19 @@ sub sendxplhbeat {
>
> Slim::Utils::Timers::setTimer("", Time::HiRes::time() +
> ($xpl_interval*60), \&sendxplhbeat);
> }
> +sub sendXplStatusMsg {
> + my $msg;
> + my $client = $_[0];
> + my $status = $_[1];
> + my $clientName = validInstance($client->name);
> + my $playmode = $client->playmode;
> + $msg = "status=$playmode";
> + $msg = "$msg\nupdate=$status";
> + sendxplmsg("xpl-stat",
> + "*","audio.slimserv",
> + $msg,
> + $clientName);
> +}
>
> # Generic routine for sending an xPL message.
> sub sendxplmsg {

John Gorst
2005-05-26, 09:46
John Gorst wrote:

> Bugs
> - artist, album and title info are missing from xpl message if a song is
> skipped

Here is an updated diff output against 26/5/5 nightly for source.pm to
correct this bug.

Cheers

[john@mandrake Desktop]$ diff -upB Sourceold.pm Source.pm
--- Sourceold.pm 2005-05-26 13:06:34.932356005 +0100
+++ Source.pm 2005-05-26 17:40:57.000000000 +0100
@@ -1,6 +1,6 @@
package Slim::Player::Source;

-# $Id$
+# $Id: Source.pm 3295 2005-05-25 18:26:40Z adrian $

# SlimServer Copyright (C) 2001-2004 Sean Adams, Slim Devices Inc.
# This program is free software; you can redistribute it and/or
@@ -16,6 +16,7 @@ use IO::Socket qw(:DEFAULT :crlf);
use Time::HiRes;
use Fcntl qw(SEEK_CUR);
use bytes;
+use Slim::Control::xPL;

BEGIN {
if ($^O =~ /Win32/) {
@@ -513,6 +514,10 @@ sub playmode {
}

Slim::Player::Playlist::refreshPlaylist($everyclie nt);
+ # force xpl msg for new song
+ if (Slim::Utils::Prefs::get('xplsupport')) {
+ Slim::Control::xPL::sendXplHBeatMsg($client, 1);
+ }
}

$::d_source && msg($client->id() . ": Current playmode:
$newmode\n");
@@ -827,6 +832,11 @@ sub gotoNext {
# connection to the client.
dropStreamingConnection($client);

+ # send xpl to tell them we're done
+ if (Slim::Utils::Prefs::get('xplsupport')) {
+
Slim::Control::xPL::sendXplStatusMsg($client,"end of list");
+ }
+
$client->update();

return 0;

John Gorst
2005-05-26, 10:05
The bug described below occurs with all streams (alienbbc or ordinary
mp3 radio streams). It only occurs when xpl support it switched on.

Can anyone see how the line $album = $track->album()->title(); would
cause this problem with any type of radio stream. Is there a work around?

Cheers

> New bug
> When playing an AlienBBC stream I get the following error and the server
> crashes just before (presumeably) an xpl.heartbeat messages is going to
> be sent (one is automatically sent every five minutes)
>
> Can't call method "title" on an undefined value at
> /usr/local/slimserver/Slim/Control/xPL.pm line 264.
>
> The offending line is $album = $track->album()->title();
>
> Should this (minor) error cause slimserver to crash! Presumeably this is
> something 'special' with alienBBC streams (?other radio streams) not
> having the typical album/artist/title info.
>
> If this information is not known should it not just return 'unknown'.
>
> Cheers
>
>>
>> [john@mandrake Desktop]$ diff -upB Commandold.pm Command.pm
>> --- Commandold.pm 2005-05-26 13:05:53.732277816 +0100
>> +++ Command.pm 2005-05-26 11:54:18.000000000 +0100
>> @@ -1,6 +1,6 @@
>> package Slim::Control::Command;
>>
>> -# $Id$
>> +# $Id: Command.pm 3242 2005-05-18 15:09:55Z fred $
>> #
>> # SlimServer Copyright (C) 2001-2004 Sean Adams, Slim Devices Inc.
>> # This program is free software; you can redistribute it and/or
>> @@ -19,6 +19,7 @@ use Slim::Music::Info;
>> use Slim::Utils::Misc;
>> use Slim::Utils::Scan;
>> use Slim::Utils::Strings qw(string);
>> +use Slim::Control::xPL;
>>
>> our %executeCallbacks = ();
>>
>> @@ -745,6 +746,11 @@ sub execute {
>>
>> $client->power(!$client->power());
>>
>> + # send xpl message when power toggles
>> + if
>> (Slim::Utils::Prefs::get('xplsupport')) {
>> + Slim::Control::xPL::sendXplHBeatMsg($client,1);
>> + }
>> +
>> } elsif ($p1 eq "?") {
>>
>> $p1 = $client->power();
>> @@ -757,6 +763,11 @@ sub execute {
>> }
>>
>> $client->power($p1);
>> +
>> + # send xpl message when power toggles
>> + if
>> (Slim::Utils::Prefs::get('xplsupport')) {
>> + Slim::Control::xPL::sendXplHBeatMsg($client,1);
>> + }
>>
>> if ($p1 eq "0") {
>> # Powering off cancels sleep...
>>
>>
>>
>>
>> [john@mandrake Desktop]$ diff -upB Sourceold.pm Source.pm
>> --- Sourceold.pm 2005-05-26 13:06:34.932356005 +0100
>> +++ Source.pm 2005-05-26 11:57:35.000000000 +0100
>> @@ -1,6 +1,6 @@
>> package Slim::Player::Source;
>>
>> -# $Id$
>> +# $Id: Source.pm 3295 2005-05-25 18:26:40Z adrian $
>>
>> # SlimServer Copyright (C) 2001-2004 Sean Adams, Slim Devices Inc.
>> # This program is free software; you can redistribute it and/or
>> @@ -16,6 +16,7 @@ use IO::Socket qw(:DEFAULT :crlf);
>> use Time::HiRes;
>> use Fcntl qw(SEEK_CUR);
>> use bytes;
>> +use Slim::Control::xPL;
>>
>> BEGIN {
>> if ($^O =~ /Win32/) {
>> @@ -827,6 +828,11 @@ sub gotoNext {
>> # connection to the client.
>> dropStreamingConnection($client);
>>
>> + # send xpl to tell them we're done
>> + if
>> (Slim::Utils::Prefs::get('xplsupport')) {
>> + Slim::Control::xPL::sendXplStatusMsg($client,"end of list");
>> + }
>> +
>> $client->update();
>>
>> return 0;
>> @@ -1472,6 +1478,11 @@ sub openSong {
>> binmode($client->audioFilehandle());
>> }
>>
>> + # force xpl msg for new song
>> + if (Slim::Utils::Prefs::get('xplsupport')) {
>> + Slim::Control::xPL::sendXplHBeatMsg($client, 1);
>> + }
>> +
>> # keep track of some stats for this track
>> $track->set('playCount' => ($track->playCount() || 0)
>> + 1);
>> $track->set('lastPlayed' => time());
>>
>>
>>
>>
>> [john@mandrake Desktop]$ diff -upB xPLold.pm xPL.pm
>> --- xPLold.pm 2005-05-26 13:05:22.628748304 +0100
>> +++ xPL.pm 2005-05-26 12:47:28.000000000 +0100
>> @@ -17,6 +17,7 @@ use strict;
>> use IO::Socket;
>> use Slim::Utils::Prefs;
>> use Sys::Hostname;
>> +use Slim::DataStores::DBI::DBIStore;
>>
>> my $xpl_source = "slimdev-slimserv";
>> my $localip;
>> @@ -245,27 +248,42 @@ sub sendXplHBeatMsg {
>> my $clientName = validInstance($client->name);
>> my $playmode = $client->playmode;
>> my $song = $client->currentplayingsong();
>> - my $prevline1 = $client->prevline1();
>> + my $prevline1 = $client->prevline1();
>> my $prevline2 = $client->prevline2();
>>
>> + my $album = " ";
>> + my $artist = " ";
>> + my $trackname = " ";
>> + my $power = $client->power();
>> +
>> if ($playmode eq 'play') {
>> - $playmode = "playing";
>> + $playmode = "playing";
>> + my $currentDB = Slim::DataStores::DBI::DBIStore->new();
>> + my $url = Slim::Player::Playlist::song($client);
>> + my $track = ref $url ? $url :
>> $currentDB->objectForUrl($url, 1, 1);
>> + $album = $track->album()->title();
>> + $artist = $track->artist()->name();
>> + $trackname = Slim::Music::Info::getCurrentTitle($client,
>> Slim::Player::Playlist::song($client));
>> + # if the song name has the track number at the beginning,
>> remove it
>> + $trackname =~ s/^[0-9]*\.//g;
>> + $trackname =~ s/^ //g;
>> } elsif ($playmode eq 'stop') {
>> - $playmode = "stopped";
>> - } elsif ($playmode eq 'pause') {
>> - $playmode = "paused";
>> - }
>> + $playmode = "stopped";
>> + } elsif ($playmode eq 'pause') {
>> + $playmode = "paused";
>> + }
>>
>> if (defined($_[1])) {
>> $msg = "status=$playmode";
>> - $msg =
>> "$msg\nsong=$song\nline1=$prevline1\nline2=$prevlin e2";
>> + $msg =
>> "$msg\nARTIST=$artist\nALBUM=$album\nTRACK=$trackna me\nPOWER=$power";
>> sendxplmsg("xpl-stat",
>> - "*","audio.slimserv",
>> + "*","audio.basic",
>> $msg,
>> $clientName);
>> } else {
>> $msg =
>> "interval=$xpl_interval\nport=$xpl_port\nremote-ip=$localip\nschema=audio.slimserv\nstatus=$playmo de";
>>
>> - $msg =
>> "$msg\nsong=$song\nline1=$prevline1\nline2=$prevlin e2";
>> + $msg =
>> "$msg\nsong=$song\nline1=$prevline1\nline2=$prevlin e2";
>> + $msg =
>> "$msg\nARTIST=$artist\nALBUM=$album\nTRACK=$trackna me\nPOWER=$power";
>> sendxplmsg("xpl-stat",
>> "*","hbeat.app",
>> $msg,
>> @@ -283,6 +301,19 @@ sub sendxplhbeat {
>>
>> Slim::Utils::Timers::setTimer("", Time::HiRes::time() +
>> ($xpl_interval*60), \&sendxplhbeat);
>> }
>> +sub sendXplStatusMsg {
>> + my $msg;
>> + my $client = $_[0];
>> + my $status = $_[1];
>> + my $clientName = validInstance($client->name);
>> + my $playmode = $client->playmode;
>> + $msg = "status=$playmode";
>> + $msg = "$msg\nupdate=$status";
>> + sendxplmsg("xpl-stat",
>> + "*","audio.slimserv",
>> + $msg,
>> + $clientName);
>> +}
>>
>> # Generic routine for sending an xPL message.
>> sub sendxplmsg {

kdf
2005-05-26, 10:16
Quoting John Gorst <john_gorst (AT) hotmail (DOT) com>:

>
> The bug described below occurs with all streams (alienbbc or ordinary
> mp3 radio streams). It only occurs when xpl support it switched on.
>
> Can anyone see how the line $album = $track->album()->title(); would
> cause this problem with any type of radio stream. Is there a work around?

radio streams arent' stored in the database, so using track->album will not be
defined. Its an unbelievably harmful downfall of using objects and methods in
Perl. try a method on an undefined value and its crash city, no way around it.
You either check to be sure the object is defined first, or don't call the
method.

For radio streams, use: Slim::Music::Info::getCurrentTitle()
and avoid trying to get anything from an album object on radio streams.

$album = $track->album() ? $track->album()->title() : undef;
might work.

-kdf

John Gorst
2005-05-26, 11:49
kdf wrote:
> Quoting John Gorst <john_gorst (AT) hotmail (DOT) com>:
>
>
>>The bug described below occurs with all streams (alienbbc or ordinary
>>mp3 radio streams). It only occurs when xpl support it switched on.
>>
>>Can anyone see how the line $album = $track->album()->title(); would
>>cause this problem with any type of radio stream. Is there a work around?
>
>
> radio streams arent' stored in the database, so using track->album will not be
> defined. Its an unbelievably harmful downfall of using objects and methods in
> Perl. try a method on an undefined value and its crash city, no way around it.
> You either check to be sure the object is defined first, or don't call the
> method.
>
> For radio streams, use: Slim::Music::Info::getCurrentTitle()
> and avoid trying to get anything from an album object on radio streams.
>
> $album = $track->album() ? $track->album()->title() : undef;
> might work.

Apparently this problem has been sorted

The updated copy of xPL.pl is at
http://kjsdoghouse.com/autohouse/scripts/slimxpl.zip works fine with
radio streams.
(ignore source.pm and command.pm and use the diffs I have posted in this
thread).

Would it be possible to integrate these changes into the nightly
release? (all of the errors we see so far have been corrected and only
affect people if they have xpl enabled)

Cheers

kdf
2005-05-26, 23:35
I'll be happy to merge it in for you, but I'd be much happier if you could
resend the diffs as an attachment. Its safer than going back through the
thread keeping track of instuctions from each post (especially since I dont use
XPL, so cannot test :)

-kdf

John Gorst
2005-05-27, 01:35
kdf wrote:
> I'll be happy to merge it in for you, but I'd be much happier if you could
> resend the diffs as an attachment. Its safer than going back through the
> thread keeping track of instuctions from each post (especially since I dont use
> XPL, so cannot test :)
>
> -kdf

Attached are my first attempt at .diff files (very useful program!)

Updated features
- send xpl message when power toggles (web interface or remote)
- send xpl message when new song starts playing with artist,album and
title info
- send xpl message at the end of a playlist

Bugs
- crashing slimserver when playing radiostreams (resolved)
- doesnt send artist/album/title info when skipping songs (resolved)
- sends multiple xpl messgaes when changing songs (unresolved)

John Gorst
2005-05-27, 01:52
John Gorst wrote:
> kdf wrote:
>
>> I'll be happy to merge it in for you, but I'd be much happier if you
>> could
>> resend the diffs as an attachment. Its safer than going back through the
>> thread keeping track of instuctions from each post (especially since I
>> dont use
>> XPL, so cannot test :)
>>
>> -kdf

And some changes to the included xPL documentation in the web interface...

kdf
2005-05-27, 02:12
Thanks, merged to 6.1 at change 3308. This will be in the 6.1 nightlies only at
this point.

cheers,
kdf

John Gorst
2005-05-27, 02:20
kdf wrote:
> Thanks, merged to 6.1 at change 3308. This will be in the 6.1 nightlies only at
> this point.

Cheers.
Just a quick note that most of this has come from rleong1 from the xPL
mailing list rather than written by myself!

kdf
2005-05-27, 02:41
Quoting John Gorst <john_gorst (AT) hotmail (DOT) com>:

> Just a quick note that most of this has come from rleong1 from the xPL
> mailing list rather than written by myself!

cool. You should encourage rleongl to join this list/forum.

-k

Marc Sherman
2005-05-27, 06:53
John Gorst wrote:
>
> Attached are my first attempt at .diff files (very useful program!)

FYI, you can generate a single diff file containing the entire changeset
using either:

diff -upBr orig-root-dir modified-root-dir > mychanges.diff

or, if you're working from an svn working copy,

svn diff > mychanges.diff

run from the root directory of your working copy.

- Marc

John Gorst
2005-05-27, 07:03
Marc Sherman wrote:
> John Gorst wrote:
>
>>
>> Attached are my first attempt at .diff files (very useful program!)
>
>
> FYI, you can generate a single diff file containing the entire changeset
> using either:
>
> diff -upBr orig-root-dir modified-root-dir > mychanges.diff
>
> or, if you're working from an svn working copy,
>
> svn diff > mychanges.diff
>
> run from the root directory of your working copy.
>
> - Marc

I was 'cheating' and using 'kompare'.

So to do the above I would make a copy of my slimserver directory e.g.
/usr/slimserverdevel

I would then make all the changes to the slimserverdevel as I was going
along (and I would still be able to go back to the 'clean' copy).

I would then run the command:

diff -upBr /usr/local/slimserver/Slim /usr/local/slimserverdevel/Slim >
mychanges.diff

????

kdf
2005-05-27, 07:43
As Moser suggested, you may want to look into installing Eclipse with Subclipse
in windows. then you can download an up-to-the-minute copy of slimserver and
can create a diff from the subversion server and your local copy at any time.

-kdf

John Gorst
2005-05-28, 07:54
kdf wrote:
> Thanks, merged to 6.1 at change 3308. This will be in the 6.1 nightlies only at
> this point.


Slight bug with this update. When a mp3 client connects to slimserver
(e.g. winamp) the server crashes withe the following error:

Can't locate object method "power" via package "Slim::Player::Client" at
/usr/local/slimserver/Slim/Control/xPL.pm line 257.

The offending line is:
my $power = $client->power();

I assume the problem here lies with the fact that an mp3 stream client
does not have a power state defined.

I have tried to correct the problem by trying to establish whether the
variable $client->power() exists before calling it but have not had any
success with the following:

my $power = " ";
if (exists($client->power())) {
$power = $client->power();
}

or

my $power = " ";
if (defined($client->power())) {
$power = $client->power();
}

I think I am showing my complete lack of understading of perl and need
to get a book on this! Does anyone else have any ideas to resolve this
issue?

Cheers

Triode
2005-05-28, 08:01
> Can't locate object method "power" via package "Slim::Player::Client" at
> /usr/local/slimserver/Slim/Control/xPL.pm line 257.
>
> The offending line is:
> my $power = $client->power();
>
> I assume the problem here lies with the fact that an mp3 stream client
> does not have a power state defined.
>

Try something like:
if (defined $client && $client->isPlayer())

This should avoid mp3 clients.

Adrian

kdf
2005-05-28, 08:10
Quoting Triode <triode1 (AT) btinternet (DOT) com>:

> > Can't locate object method "power" via package "Slim::Player::Client" at
> > /usr/local/slimserver/Slim/Control/xPL.pm line 257.
> >
> > The offending line is:
> > my $power = $client->power();
> >
> > I assume the problem here lies with the fact that an mp3 stream client
> > does not have a power state defined.
> >
>
> Try something like:
> if (defined $client && $client->isPlayer())
>
> This should avoid mp3 clients.

Other option, as has been done for other problematic methods, is a dummy
function in Player/Client.pm around line 1122:

sub power {}

-kdf

-kdf

John Gorst
2005-05-28, 08:51
kdf wrote:
> Quoting Triode <triode1 (AT) btinternet (DOT) com>:
>
>
>>>Can't locate object method "power" via package "Slim::Player::Client" at
>>>/usr/local/slimserver/Slim/Control/xPL.pm line 257.
>>>
>>>The offending line is:
>>>my $power = $client->power();
>>>
>>>I assume the problem here lies with the fact that an mp3 stream client
>>>does not have a power state defined.
>>>
>>
>>Try something like:
>> if (defined $client && $client->isPlayer())
>>
>>This should avoid mp3 clients.
>
>
> Other option, as has been done for other problematic methods, is a dummy
> function in Player/Client.pm around line 1122:
>
> sub power {}

Works a treat! Thanks
Not quite sure why we needed this line though as it is already present
in /Player/HTTP.pm but for some reason it wasnt accepting its knowledge
there!

Would there be a way to use the sub power line (included below) that is
already in HTTP.pm as I think that would be cleaner. And putting sub
power {} in Client.pm seems to break (or atleast create errors) with the
PowerSave.pm plugin.

Sub Power { Slim::Web::HTTP::clearOutputBuffer(shift); 1 }

Use of uninitialized value in string ne at
/usr/local/slimserverdevel/Plugins/PowerSave.pm line 227.

Attached is the .diff file for the change to Client.pm

kdf
2005-05-28, 13:43
Quoting John Gorst <john_gorst (AT) hotmail (DOT) com>:


> Sub Power { Slim::Web::HTTP::clearOutputBuffer(shift); 1 }
>
> Use of uninitialized value in string ne at
> /usr/local/slimserverdevel/Plugins/PowerSave.pm line 227.
>
> Attached is the .diff file for the change to Client.pm
if what you have written above is exactly what is in http.pm, then it should be
sub power, not sub Power. the differing case would be the problem

-kdf

John Gorst
2005-05-29, 10:27
kdf wrote:
> Quoting John Gorst <john_gorst (AT) hotmail (DOT) com>:
>
>
>
>>Sub Power { Slim::Web::HTTP::clearOutputBuffer(shift); 1 }
>>
>>Use of uninitialized value in string ne at
>>/usr/local/slimserverdevel/Plugins/PowerSave.pm line 227.
>>
>>Attached is the .diff file for the change to Client.pm
>
> if what you have written above is exactly what is in http.pm, then it should be
> sub power, not sub Power. the differing case would be the problem

You are right it is wirtten sub power.
Odd that it does not pick up the version in HTTP.PM

Anyhow attached is a diff file which corrects xPL.pm instead of
Client.pm to correct the borken mp3 stream crashing problem. I think
this is safer as not so many people use xPL.pm!

Would be grateful if someone could apply.

Update notes:

-stops slimserver from crashing when a localhost:9000/stream.mp3 cleint
connects due to undefined variable in xPL.pm
-returns power value of "1" when polling the status of stream.mp3 clients

Thanks!

kdf
2005-05-29, 13:49
Hi John,

Thanks for looking into the fix. I'll be happy to commit it myself, and have
saved it in my inboc for when I'm able to get back to svn. I'm on the road
right now and until tuesday. If no one else gets this in before then, I'll
make sure it is in then.

-kdf

gorstk
2005-05-31, 01:14
kdf wrote:
> Hi John,
>
> Thanks for looking into the fix. I'll be happy to commit it myself, and have
> saved it in my inboc for when I'm able to get back to svn. I'm on the road
> right now and until tuesday. If no one else gets this in before then, I'll
> make sure it is in then.
>

Attached is another .diff file which replaces the one in my previous
post. Fix one thing and another breaks!

Update notes:

-stops slimserver from crashing when a localhost:9000/stream.mp3 cleint
connects due to undefined variable in xPL.pm
-returns power value of "1" when polling the status of stream.mp3 clients
- Fixed sending xPl messages when tracks change (was broke after change
to send xPL message when tracks skipped)

Cheers

gorstk
2005-05-31, 01:51
John Gorst wrote:

> Attached is another .diff file which replaces the one in my previous
> post. Fix one thing and another breaks!
>
> Update notes:
>
> -stops slimserver from crashing when a localhost:9000/stream.mp3 cleint
> connects due to undefined variable in xPL.pm
> -returns power value of "1" when polling the status of stream.mp3 clients
> - Fixed sending xPl messages when tracks change (was broke after change
> to send xPL message when tracks skipped)
>
> Cheers

Please note deliberate mistake in .diff file - I have an excuse I have
just finished a night shift. Attached is correct version.

Also I am trying to figure out how to just return the tackname rather
than 'trackname - artist -album' in xPL.pm

We currently get the trackname using:

$trackname = Slim::Music::Info::getCurrentTitle($client,
Slim::Player::Playlist::song($client));
# if the song name has the track number at the beginning, remove it
$trackname =~ s/^[0-9]*\.//g;
$trackname =~ s/^ //g;

I have treid adjusting the setting in server setup -> formatting ->
title format with no success. Any ideas?

We get the artist and album in a different method completely but no
amount of fiddling has helped me get the title in a same way:

my $currentDB = Slim::DataStores::DBI::DBIStore->new();
my $url = Slim::Player::Playlist::song($client);
my $track = ref $url ? $url : $currentDB->objectForUrl($url, 1, 1);
if (defined($track->album())) {
if (defined($track->album()->title())) {
$album = $track->album()->title();
}
}
if (defined($track->artist())) {
if (defined($track->artist()->name())) {
$artist = $track->artist()->name();
}
}

Thanks for any help!

kdf
2005-05-31, 03:33
thanks, John.

Looks like this diff has been made in reverse. The lines I think you intended
to have added are marked as -. Make sure that when you create diffs, that you
use your custom version is the second argument.

I've applied manually this time and merged it in at change 3315.
-kdf