Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 22nd, 2024, 7:04 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: GetPosition() of Sound object
PostPosted: December 19th, 2004, 9:05 pm 
Offline

Joined: November 22nd, 2004, 7:26 pm
Posts: 119
Location: Austria
I have an MP3 loaded into a publication and want to display the running time of the sound in a variable. This works when I insert the variable into a text field and click on a button to display the variable. But what I want is that when the sound plays to constantly show the running time of the sound via GetPosition() in the text box. How can I do that ??


For this message Klaus Rosmanitz has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: December 20th, 2004, 5:57 pm 
Offline

Joined: October 25th, 2004, 12:27 pm
Posts: 526
Location: Digital Workshop
Hi,

Thank you for your enquiry.

You could achieve this using a script object for the sound file and a looped GetPosition() function to constantly update the position variable. For example, try adding a script object to the page containing the following:

Code:
mySound = OpenSound("test.mp3")
mySound.Play()

while (true) {
pos = mySound.GetPosition()
wait()
}


You will need to ensure that '"test.mp3" in line 1 is edited to match the name of your audio file and that this file resides in the same directory as your publication.

Now add a text object to the page and insert a new variable named 'pos' with a default blank text value.

Preview the publication. The sound should play and the position variable should advance.

Kind regards,

_________________
Robin Garrett
Digital Workshop Technical Support


For this message Robin Garrett has been thanked by : mackavi


Last edited by Robin Garrett on December 21st, 2004, 8:38 pm, edited 1 time in total.

Top
 Profile Visit website  
 
 Post subject:
PostPosted: December 21st, 2004, 7:11 pm 
Offline

Joined: November 22nd, 2004, 7:26 pm
Posts: 119
Location: Austria
Thank you Robin for your quick help , everything works perfectly, except for one thing. I put the looped GetPosition function in a script object attached to a page

I control the sound by adding buttons to Start(Reset),Pause and Continue the sound

I put the following scripts on the Left Mouse Down trigger:

Start Button :
mySound.SetPosition(0)
mySound.Play()

Pause Button
mySound.Stop(false)

Continue Button
mySound.Play()

The buttons control the sound correctly and the the position variable updates accordingly. When I pause the sound the position variable holds at the correct position but when I click on the continue button the variable doubles its value (for example when I stop at 10 and continue the variable is at 20). When I pause again the variable shows the correct value.

Any reason for this strange behaviour or is there something I've done wrong ?? :?

One more question : which is the best sound format to use , ensuring that all end users will be able to hear it correctly ??

_________________
Klaus Rosmanitz
Austria


________
XP Home , Opus Pro 5.5


For this message Klaus Rosmanitz has been thanked by : mackavi


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot] and 81 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group