Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 12-23-2012, 01:52 PM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
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?
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #2  
Old 12-23-2012, 04:40 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Uh, they're probably in seconds if they work at all. Did you try just looking at their value as you play music?
__________________
Reply With Quote
  #3  
Old 12-23-2012, 06:51 PM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
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
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #4  
Old 12-24-2012, 04:42 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
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?
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #5  
Old 12-24-2012, 06:28 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Gunderak View Post
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.
__________________
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 10:36 PM.


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