Problem playlist for() loop PHP

This forum is for questions / discussions regarding development of addons / tweaks for MediaMonkey for Windows 4.

Moderators: Gurus, Addon Administrators

Pater
Posts: 15
Joined: Fri Jun 03, 2011 12:45 pm

Problem playlist for() loop PHP

Post by Pater »

Hey guys

i got a problem with my scripting. i try to parse the CurrentSonglist into a array,
but the last item in the list always gives an error. Here is my code:

Code: Select all

public function getCurrentPlayList()
	{
		$firstItem 	= $this->MMPlayer->CurrentSongIndex;
		$numItems 	= $this->MMPlayer->CurrentPlaylist->Count;
		//$maxItems = 5;
		$secondPass = false;
		
		//($firstItem + 5) < $numItems ? $items = $firstItem + 5 : 
		$items = $numItems;
		print $items;
		for( $i = $firstItem; $i < $items; $i++ )
		{
			
			$song = $this->MMPlayer->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 );
			if( $this->MMPlayer->isRepeat && !$secondPass && $i == $items-1  )
			{
				$i = -1;
				//$items = ( $maxItems - count( $this->CPL ) );
				$secondPass = true;
			}
		}
	}
The error occurs when calling $this->getAlbumArt( $song->Artist->Name, $song->AlbumName );, the error states that the variables given are empty. When using

Code: Select all

 for( $i = $firstItem; $i < $items-1; $i++ )
so the last item is skipped, the error does not occur.

anyone got any clue what is wrong?? any suggestion would be appreciated!
Pater
Posts: 15
Joined: Fri Jun 03, 2011 12:45 pm

Re: Problem playlist for() loop PHP

Post by Pater »

problem solved on my own :D was part of problem http://www.mediamonkey.com/forum/viewto ... 19&t=59646

topic close
Post Reply