Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   musicpos and musiclen (https://forums.graalonline.com/forums/showthread.php?t=134267632)

Gunderak 12-23-2012 01:52 PM

musicpos and musiclen
 
Hey, just trying to calculate the position of a song in seconds.
I'm assuming musiclen and musicpos are in bytes? not bits?
So it's either /1024 or /1000 not sure.
Anyway, iv'e tried a few things.
This seemed the most logical but failed.
PHP Code:

  temp.mp musicpos//Current position, assuming it's the current byte you're at.
  
temp.ml musiclen//Total bytes.
  
temp.bitrate 128//The bit rate of the song, needed to get seconds.
  
temp.mps musicpos/1024/bitrate/60//Should be the second you're at. 

Any advice?

cbk1994 12-23-2012 04:40 PM

Uh, they're probably in seconds if they work at all. Did you try just looking at their value as you play music?

xXziroXx 12-23-2012 06:51 PM

This is what I use for my jukebox on Era iPhone.

PHP Code:

  temp.songLengthInSeconds int(musiclen/1000);
  
temp.songPositionInSeconds int(musicpos/1000);
  
  if (
int(temp.songPositionInSeconds/60) == -1) {
    
temp.musicPosition "00:00";
    
temp.musicLength "??:??";
  }
  else {
    
temp.musicPosition = (int(temp.songPositionInSeconds/60) >= 10 int(temp.songPositionInSeconds/60) : "0" int(temp.songPositionInSeconds/60)) @ ":" @ (temp.songPositionInSeconds%60 >= 10 temp.songPositionInSeconds%60 "0" temp.songPositionInSeconds%60);
    
temp.musicLength = (int(temp.songLengthInSeconds/60) >= 10 int(temp.songLengthInSeconds/60) : "0" int(temp.songLengthInSeconds/60)) @ ":" @ (temp.songLengthInSeconds%60 >= 10 temp.songLengthInSeconds%60 "0" temp.songLengthInSeconds%60);
  }
  
  
this.chat temp.musicPosition SPC "/" SPC temp.musicLength


Gunderak 12-24-2012 04:42 AM

Cbk, I did look at them while playing music, but it just gives back a crazy integer.
It isn't even the total bytes of the song.
Thanks xXZiroXx for your example, but what exactly is musicpos and musiclen returning?

cbk1994 12-24-2012 06:28 AM

Quote:

Originally Posted by Gunderak (Post 1710395)
Cbk, I did look at them while playing music, but it just gives back a crazy integer.
It isn't even the total bytes of the song.
Thanks xXZiroXx for your example, but what exactly is musicpos and musiclen returning?

From that snippet he posted, it looks like milliseconds. Just add player.chat = musicpos; in a timeout and see what happens to it as a song plays.


All times are GMT +2. The time now is 02:05 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.