Source for file Track.php
Documentation is available at Track.php
/** Represents a track and provides different methods to query track information.
* @package php-lastfm-api
* @author Felix Bruns <felixbruns@web.de>
/** The artist of this track.
/** The album of this track.
/** Indicates if this track is streamable.
/** Indicates if this track is a full streamable track.
/** The tracks wiki information.
/** The unix timestamp indicating when this track was last played.
/** Create an album object.
* @param mixed $artist An artist object or string.
* @param mixed $album An album object or string.
* @param string $name Name of this track.
* @param string $mbid MusicBrainz ID of this track.
* @param string $url Last.fm URL of this track.
* @param array $images An array of cover art images of different sizes.
* @param integer $listeners Number of listeners of this track.
* @param integer $playCount Play count of this album.
* @param integer $duration Duration of this track.
* @param array $topTags An array of top tags of this track.
* @param integer $id ID of this track.
* @param string $location Location of this track.
* @param boolean $streamable Track is streamable.
* @param boolean $fullTrack Track is a full streamable track.
* @param string $wiki Wiki data of this track.
* @param integer $lastPlayed When this track was last played.
public function __construct($artist, $album, $name, $mbid, $url,
array $images, $listeners, $playCount,
$duration, array $topTags, $id, $location,
$streamable, $fullTrack, $wiki, $lastPlayed){
parent::__construct($name, $mbid, $url, $images, $listeners, $playCount);
$this->duration =
$duration;
$this->topTags =
$topTags;
$this->location =
$location;
$this->streamable =
$streamable;
$this->fullTrack =
$fullTrack;
$this->lastPlayed =
$lastPlayed;
/** Returns the artist of this track.
* @return mixed An {@link de.felixbruns.lastfm.Artist Artist} object or the artists name.
/** Returns the album of this track.
* @return mixed An {@link de.felixbruns.lastfm.Album Album} object or the albums name.
/** Returns the duration of this track.
* @return integer The duration of this track.
/** Returns the tracks top tags.
* @return array An array of Tag objects.
/** Returns the ID of this track.
* @return integer The ID of this track.
/** Returns the location of this track.
* @return string The location of this track.
/** Returns if this track is streamable.
* @return boolean A boolean.
return $this->streamable;
/** Returns if this track is a full streamable track.
* @return boolean A boolean.
/** Returns the wiki data of this track.
* @return string Wiki data.
/** Returns the unix timestamp indication when this track was last played.
* @return integer A unix timestamp.
return $this->lastPlayed;
/** Tag an album using a list of user supplied tags.
* @param string $artist The artist name in question. (Required)
* @param string $track The track name in question. (Required)
* @param array $tags A comma delimited list of user supplied tags to apply to this track. Accepts a maximum of 10 tags. (Required)
* @param Session $session A session obtained by {@link de.felixbruns.lastfm.Auth#getSession Auth::getSession} or {@link de.felixbruns.lastfm.Auth#getMobileSession Auth::getMobileSession}. (Required)
public static function addTags($artist, $track, array $tags, $session){
CallerFactory::getDefaultCaller()->signedCall('track.addTags', array(
'tags' =>
implode(',', $tags)
/** Ban a track for a given user profile. This needs to be supplemented with a scrobbling submission containing the 'ban' rating (see the audioscrobbler API).
* @param string $artist An artist name. (Required)
* @param string $track A track name. (Required)
* @param Session $session A session obtained by {@link de.felixbruns.lastfm.Auth#getSession Auth::getSession} or {@link de.felixbruns.lastfm.Auth#getMobileSession Auth::getMobileSession}. (Required)
public static function ban($artist, $track, $session){
/** Get the metadata for a track on last.fm using the artist/track name or a MusicBrainz id.
* @param string $artist The artist name in question. (Optional)
* @param string $track The track name in question. (Optional)
* @param string $mbid The MusicBrainz ID for the track. (Optional)
* @return array A Track object.
public static function getInfo($artist, $track, $mbid =
null){
/** Get the similar tracks for this track on last.fm, based on listening data.
* @param string $artist The artist name in question. (Optional)
* @param string $track The track name in question. (Optional)
* @param string $mbid The MusicBrainz ID for the track. (Optional)
* @return array An array of Track objects.
public static function getSimilar($artist, $track, $mbid =
null){
foreach($xml->children() as $track){
/** Get the tags applied by an individual user to a track on last.fm.
* @param string $artist The artist name in question. (Required)
* @param string $track The track name in question. (Required)
* @param Session $session A session obtained by {@link de.felixbruns.lastfm.Auth#getSession Auth::getSession} or {@link de.felixbruns.lastfm.Auth#getMobileSession Auth::getMobileSession}. (Required)
* @return array An array of Tag objects.
public static function getTags($artist, $track, $session){
foreach($xml->children() as $tag){
/** Get the top fans for this track on last.fm, based on listening data. Supply either track & artist name or MusicBrainz id.
* @param string $artist The artist name in question. (Optional)
* @param string $track The track name in question. (Optional)
* @param string $mbid The MusicBrainz ID for the track. (Optional)
* @return array An array of User objects.
public static function getTopFans($artist, $track, $mbid =
null){
foreach($xml->children() as $user){
/** Get the top tags for this track on last.fm, ordered by tag count. Supply either track & artist name or mbid.
* @param string $artist The artist name in question. (Optional)
* @param string $track The track name in question. (Optional)
* @param string $mbid The MusicBrainz ID for the track. (Optional)
* @return array An array of Tag objects.
public static function getTopTags($artist, $track, $mbid =
null){
foreach($xml->children() as $tag){
/** Love a track for a user profile. This needs to be supplemented with a scrobbling submission containing the 'love' rating (see the audioscrobbler API).
* @param string $artist An artist name. (Required)
* @param string $track A track name. (Required)
* @param Session $session A session obtained by {@link de.felixbruns.lastfm.Auth#getSession Auth::getSession} or {@link de.felixbruns.lastfm.Auth#getMobileSession Auth::getMobileSession}. (Required)
public static function love($artist, $track, $session){
/** Remove a user's tag from a track.
* @param string $artist The artist name in question. (Required)
* @param string $track The track name in question. (Required)
* @param string $tag A single user tag to remove from this track. (Required)
* @param Session $session A session obtained by {@link de.felixbruns.lastfm.Auth#getSession Auth::getSession} or {@link de.felixbruns.lastfm.Auth#getMobileSession Auth::getMobileSession}. (Required)
public static function removeTag($artist, $track, $tag, $session){
/** Search for a track by track name. Returns track matches sorted by relevance.
* @param string $track The track name in question. (Required)
* @param string $artist Narrow your search by specifying an artist. (Optional)
* @param integer $limit Limit the number of tracks returned at one time. Default (maximum) is 30. (Optional)
* @param integer $page Scan into the results by specifying a page number. Defaults to first page. (Optional)
* @return PaginatedResult A PaginatedResult object.
public static function search($track, $artist =
null, $limit =
null, $page =
null){
foreach($xml->trackmatches->children() as $track){
$opensearch =
$xml->children('http://a9.com/-/spec/opensearch/1.1/');
/** Share a track twith one or more last.fm users or other friends.
* @param string $artist An artist name. (Required)
* @param string $track A track name. (Required)
* @param array $recipients A comma delimited list of email addresses or last.fm usernames. Maximum is 10. (Required)
* @param string $message An optional message to send with the recommendation. If not supplied a default message will be used. (Optional)
* @param Session $session A session obtained by {@link de.felixbruns.lastfm.Auth#getSession Auth::getSession} or {@link de.felixbruns.lastfm.Auth#getMobileSession Auth::getMobileSession}. (Required)
public static function share($artist, $track, array $recipients,
$message =
null, $session){
CallerFactory::getDefaultCaller()->signedCall('track.share', array(
'recipient' =>
implode(',', $recipients),
/** Get a track playlist for streaming. INOFFICIAL.
* @param string $artist An artist name. (Required)
* @param string $track A track name. (Required)
* @return mixed A Playlist object.
/** Create a Track object from a SimpleXMLElement.
* @param SimpleXMLElement $xml A SimpleXMLElement.
* @return Track A Track object.
if(count($xml->image) >
1){
foreach($xml->image as $image){
foreach($xml->toptags->children() as $tag){
if($xml->artist->name &&
$xml->artist->mbid &&
$xml->artist->url){
array(), 0, 0, 0, array(), array(), '', 0.0
// TODO: <extension application="http://www.last.fm">
$xml->wiki, // TODO: Wiki object
Documentation generated on Mon, 22 Dec 2008 16:57:48 +0100 by phpDocumentor 1.4.1