i'm creating a webinterface using PHP on the server side.
When using AlbumArtList->Count, i get an PHP-error stating:
Fatal error: Call to an member function count on a non-object.
I cant figure out where the problem lies.
I am using the following code:
Code: Select all
<?php
class player
{
public $CPL;
public $CurrentSong;
public $isPlaying;
function __construct()
{
global $comset;
$this->objSDB = new COM('SongsDB.SDBApplication', $comset);
$this->MMPlayer = $this->objSDB->Player;
$this->MMTools = new COM('SongsDB.SDBTools', $comset );
$this->objSDB->ShutdownAfterDisconnect = false;
}
public function getCurrentPlayList()
{
if( $this->objSDB->Player->CurrentPlaylist->Count > 5 )
{
$numItems = $this->objSDB->Player->CurrentPlaylist->Count;
} else {
$numItems = 5;
}
for( $i = 0; $i < $numItems; $i++ )
{
$song = $this->objSDB->Player->CurrentPlaylist->Item($i);
$this->CPL[$i]['songID'] = $song->SongID;
$this->CPL[$i]['Artist'] = $song->Artist->Name;
$this->CPL[$i]['Album'] = $song->AlbumName;
$this->CPL[$i]['Title'] = $song->Title;
$this->CPL[$i]['Image'] = $this->getAlbumArt( $song->Artist->Name, $song->AlbumName );
unset( $song );
}
}
public function getAlbumArt( $Artist, $AlbumName )
{
$file = "../ImageCache/".$Artist.DS.$AlbumName.'.jpg';
$Album = $this->MMTools->AlbumByName( $Artist, $AlbumName );//->AlbumArt->Count;
$AlbumArt = $Album->AlbumArt;
$numItems = $AlbumArt->Count(); //THE ERROR OCCURS ON THIS LINE
if( $numItems < 1 )
{
return "/ImageCache/NoAlbumArt.jpg";
} elseif( ! file_exists( $file ) )
{
$tools = new tools;
if( $image = $tools->createAlbumArtImage( $Artist, $AlbumName ) )
{
return $image;
}
} else {
return $file;
}
}
}
?>
Code: Select all
$player = new player();
$player->getCurrentPlaylist();