Digital Workshop

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

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: HTML5: How to add a sound with an alias name?
PostPosted: April 27th, 2016, 8:32 pm 
Offline

Joined: November 8th, 2004, 5:23 pm
Posts: 279
Opus: Opus Pro 9
OS: Win 10/64
I would like to trigger a sound via PlaySound() from the main script of a page.

The help file says that I can add sounds via the "additional resources" tab in the properties dialog of the page or the publication.
Unfortunately I cannot find this tab in the properties dialog boxes. Maybe because it is a HTML5 publication?

Is there another way to add sounds that can be triggered from a script?

Thanks in advance for your help.

_________________
Opus Pro 9.75, Win 10/64, 8 GB RAM, Intel(R) Core(TM) i5-3570K CPU @ 3.40GHz (4 CPUs), ~3.4GHz, NVIDIA GeForce GTX 660 Ti, Roland OctaCapture


For this message Tarantoga has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Re: HTML5: How to add a sound with an alias name?
PostPosted: April 28th, 2016, 8:52 am 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
You can tap directly in the HTML5 audio element with JavaScript.

Code:
myAudio = new Audio('music.mp3');
myAudio.play()


Note, that the play function belongs to JavaScript not Opus and therefore uses the lowercase 'p'. The Opus editor will auto-correct - so make sure to change it back.

Additionally, if you wish to use the audio as a publication resource rather than a page resource you will need to define myAudio as a publication variable.

</mack>

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject: Re: HTML5: How to add a sound with an alias name?
PostPosted: May 2nd, 2016, 3:11 pm 
Offline

Joined: November 8th, 2004, 5:23 pm
Posts: 279
Opus: Opus Pro 9
OS: Win 10/64
Great! Thanks a lot for your help :D

_________________
Opus Pro 9.75, Win 10/64, 8 GB RAM, Intel(R) Core(TM) i5-3570K CPU @ 3.40GHz (4 CPUs), ~3.4GHz, NVIDIA GeForce GTX 660 Ti, Roland OctaCapture


For this message Tarantoga has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Re: HTML5: How to add a sound with an alias name?
PostPosted: May 4th, 2016, 10:00 am 
Offline

Joined: November 8th, 2004, 5:23 pm
Posts: 279
Opus: Opus Pro 9
OS: Win 10/64
mackavi wrote:
You can tap directly in the HTML5 audio element with JavaScript.

Code:
myAudio = new Audio('music.mp3');
myAudio.play()


Note, that the play function belongs to JavaScript not Opus and therefore uses the lowercase 'p'. The Opus editor will auto-correct - so make sure to change it back.

Additionally, if you wish to use the audio as a publication resource rather than a page resource you will need to define myAudio as a publication variable.

</mack>


It seems that I do something wrong: I have used the code as above. Instead of 'music.mp3' I have used 'click30_snap.mp3' for example.
Unfortunately I always get an error message "Undefined identifier 'Audio'" in the script console.

Mack, do you have an idea what causes this?

_________________
Opus Pro 9.75, Win 10/64, 8 GB RAM, Intel(R) Core(TM) i5-3570K CPU @ 3.40GHz (4 CPUs), ~3.4GHz, NVIDIA GeForce GTX 660 Ti, Roland OctaCapture


For this message Tarantoga has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Re: HTML5: How to add a sound with an alias name?
PostPosted: May 4th, 2016, 11:28 am 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Audio is a JavaScript object. You cannot test JavaScript using Opus HTML5 preview.

In practice, it is a bad habit to use preview for any Opus HTML5 testing - you should always publish and view in a browser and occasional check in other browsers for compatibility differences.

</mack>

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 28 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