Jump to content

divide result by 60


flemingmike

Recommended Posts

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);

OR if you just want a decimal:

 

$length = $tracks->track->length / 60;

Link to comment
Share on other sites

thanks, i would never haver figured that out.  i had it with the /60, but thats ugly.

 

i have an update button, is there any way i can update just the field that are from the xml file, or do i have to refresh the whole page?  im more of a vb6 guy, and its much easier in there.

 

here is my code:

 

<?php

include("style.php");

$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">		


<table border="1" width="100%">
<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>'.$title.'</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"> </td>
			<td align="center"> </td>
			<td align="center"> </td>
			<td align="center"> </td>
		</tr>
		<tr>
			<td align="center"> </td>
			<td align="center"> </td>
			<td align="center">



			<iframe name="I1" 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

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

 

I'm not sure what you're doing with this here.  You are looping through an entire array just to populate a variable with what will end up being the last entry in the array.

Link to comment
Share on other sites

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);

OR if you just want a decimal:

 

$length = $tracks->track->length / 60;

 

echo date('i', $seconds), ' Minutes';

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.