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
https://forums.phpfreaks.com/topic/204578-divide-result-by-60/#findComment-1071162
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
https://forums.phpfreaks.com/topic/204578-divide-result-by-60/#findComment-1071170
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
https://forums.phpfreaks.com/topic/204578-divide-result-by-60/#findComment-1071176
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
https://forums.phpfreaks.com/topic/204578-divide-result-by-60/#findComment-1071195
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.