Jump to content

why doesnt this work?


flemingmike

Recommended Posts

No, player-command is correct. Put the URL into a browser to see th XML being returned (Firefox, not Chrome). When I try the commands via PHP, the program hangs, so I have a feeling that the server is looking for some particular header.

 

Ken

Link to comment
Share on other sites

its not hanging for me.  im bassically trying to make a volume up button:

 

    $volup = $volume1->value +50;
$voldown = $volume1->value -50;[/

 

then link

 

<a target="control" href="http://www.durhamit.ca:8181/1.0/?method=player.setvolume&volume='.$volup.'">Volume Up</a>

 

 

thats my goal

Link to comment
Share on other sites

Here's what's returned in the browser:


<?xml version="1.0" encoding="UTF-8"?>
<hmm status="ok">
<player-command>
<command>volume</command>
<value>179</value>
<value2>0</value2>
<value3></value3>
</player-command>
</hmm>

 

Ken

Link to comment
Share on other sites

Here's what's returned in the browser:


<?xml version="1.0" encoding="UTF-8"?>
<hmm status="ok">
<player-command>
<command>volume</command>
<value>179</value>
<value2>0</value2>
<value3></value3>
</player-command>
</hmm>

 

Ken

 

PHP will throw a syntax error resulting in a blank page if error's are turned off and I assume they are as he doesn't tell us about any error. As PHP sees it as $hmm1->player - command where command is assumed to be a constant.

Link to comment
Share on other sites

there isnt any errors.  here is my whole page code.  everything works except for the getvolume.  the spot for '.$vol.' is just an empty field.

 

<?php

include("style.php");


$hmm1 = simplexml_load_file('http://www.durhamit.ca:8181/1.0/?method=player.getvolume');

foreach ($hmm1->player-command as $volume1) {
    $vol = $volume1->value; 
}



$hmm = simplexml_load_file('http://www.durhamit.ca:8181/1.0/?method=player.GetNowPlayingData');

foreach ($hmm->tracks as $tracks) {
    $artist = $tracks->track->artist;
    $title = $tracks->track->title;
    $album = $tracks->track->album;    
}



function decodeTime($seconds) {    
$mins = floor($seconds / 60);    
$secs = floor($seconds - ($mins * 60));    
if(strlen($secs) == 1) $secs = "0".$secs;    
return $mins.":".$secs;

}

$length = decodeTime($tracks->track->length);






echo '<div id="musicinfo" align="center">		




<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
	<td align="center">



<table border="0" width="455">
<tr>
	<td rowspan="4" width="100">
<img border="0" src="http://www.durhamit.ca:8181/1.0/?method=player.getNowPlayingPicture" width="100" height="100"></td>
	<td align="center" width="87"><b>Artist:</b></td>
	<td>'.$artist.'</td>
	<td rowspan="4" align="center" width="64">
	<table border="0" width="47%" cellspacing="0" cellpadding="0">
		<tr>
			<td align="center"><a href="parse.php">
			<img border="0" src="images/Button-Refresh-icon.bmp" width="64" height="64"></a></td>
		</tr>
		<tr>
			<td align="center">Update</td>
		</tr>
	</table>
	</td>
</tr>
<tr>
	<td align="center" width="87"><b>Title:</b></td>
	<td>'.$vol.'</td>
</tr>
<tr>
	<td align="center" width="87"><b>Album:</b></td>
	<td>'.$album.'</td>
</tr>
<tr>
	<td align="center" width="87"><b>Length:</b></td>
	<td>'.$length.'</td>
</tr>

</table>




	</td>
</tr>
<tr>
	<td align="center">
	<table border="0" width="455">
		<tr>
			<td align="center">
			<a target="control" href="http://www.durhamit.ca:8181/1.0/?method=player.play">
			<img border="0" src="images/Button-Play-icon.bmp" width="64" height="64"></a></td>
			<td align="center">
			<a target="control" href="http://www.durhamit.ca:8181/1.0/?method=player.pause">
			<img border="0" src="images/Button-Pause-icon.bmp" width="64" height="64"></a></td>
			<td align="center">
			<a target="control" href="http://www.durhamit.ca:8181/1.0/?method=player.previous">
			<img border="0" src="images/Button-Previous-icon.bmp" width="64" height="64"></a></td>
			<td align="center">
			<a target="control" href="http://www.durhamit.ca:8181/1.0/?method=player.next">
			<img border="0" src="images/Button-Next-icon.bmp" width="64" height="64"></a></td>
		</tr>
		<tr>
			<td align="center">Play</td>
			<td align="center">Pause</td>
			<td align="center">Previous</td>
			<td align="center">Next</td>
		</tr>
		<tr>
			<td align="center" colspan="4">
			<table border="0" width="100%" cellspacing="0" cellpadding="0">
				<tr>
					<td align="center">
					<img border="0" src="images/Button-Delete-icon.bmp" width="64" height="64"></td>
					<td align="center" width="20%"><font size="5">Volume</font></td>
					<td align="center">
					<img border="0" src="images/Button-Add-icon.bmp" width="64" height="64"></td>
				</tr>
			</table>
			</td>
		</tr>
		<tr>
			<td align="center"></td>
			<td align="center"> </td>
			<td align="center">



			<iframe name="control" width="1" height="1" scrolling="no" frameBorder="0"></iframe>




			</td>
			<td align="center"> </td>
		</tr>
	</table>
	</td>
</tr>
<tr>
	<td align="center"> </td>
</tr>
<tr>
	<td align="center"> </td>
</tr>
</table>




   
</div>';




?>

Link to comment
Share on other sites

I believe the problem is being caused by the string 'player-command', since the '-' is being interpreted as minus sign.

 

Try:

<?php
    $x = 'player-command';
    $vol = $hmm1->$x->value;
?>

 

You don't need the "foreach" since there is only one record being returned.

 

Ken

 

Link to comment
Share on other sites

ok, now i feel just dumb.  this would be so much easier in vb.  so my code is now:

 

$hmm1 = simplexml_load_file('http://www.durhamit.ca:8181/1.0/?method=player.getvolume');

  
    $x = 'player-command';    
    $vol = $hmm1->$x->value;
    $volup = $hmm1->$x->value +50;
    $voldown = $hmm1->$x->value -50;

 

but how can i refresh the value after going up or down?  it keeps the existing value from when the page originally loaded.  here is my current link:

 

http://www.durhamit.ca:8181/1.0/?method=player.setvolume&volume='.$voldown.'

 

Link to comment
Share on other sites

I believe the problem is being caused by the string 'player-command', since the '-' is being interpreted as minus sign.

 

Try:

<?php
    $x = 'player-command';
    $vol = $hmm1->$x->value;
?>

 

You don't need the "foreach" since there is only one record being returned.

 

Ken

 

 

Really?? LOL told you like 2 hours ago ;)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.