Wikitude
play_for_work
Forum
FAQ
Documentation
Download
wikitude.com
How can we help you today?
Enter your search term here...
Search
Start a new topic
Discussions
Wikitude SDK (Android, iOS, UWP)
Wikitude SDK Questions or Problems
OnClick stop the sound if already playing
F
Fadi Eddine
started a topic
almost 9 years ago
OnClick stop the sound if already playing
3 Comments
Oldest First
Popular
Newest First
Sorted by
Oldest First
F
Fadi Eddine
said
almost 9 years ago
Hi,
I have created a marker that will play music upon click. I would like the music to pause on the second click and so on.
How to check the state of the sound if it's playing or not and do the pause accordingly?
Thanks
M
Martin Lechner
said
almost 9 years ago
Hi,
You can check the status of the sound file using the state property:
http://www.wikitude.com/external/doc/documentation/latest/Reference/JavaScript%20Reference/classes/Sound.html#property_state
Best,
Martin
F
Fadi Eddine
said
almost 9 years ago
Thanks Martin.
The marker is responding to the click by checking the state.
Regards,
markerclick_musicfn = function(marker)
{ return function() {
try {
//sound.onFinishedPlaying = function(){alert("Playing finished");};
if(! sound){
sound = new AR.Sound("assets/music.mp3", {
onLoaded : function(){ //alert("playing");
sound.play();
},
onError : function(){
// alert the user that the sound file could not be loaded
alert("errrrror");
},
});
sound.load();
}
else
{
//alert(sound.state);
if (sound.state == 3)
sound.pause();
else
sound.resume();
}
}
catch (err) {
alert(err);
}
}
}
Login
or
Signup
to post a comment
More topics in
Wikitude SDK Questions or Problems
Instatiation of WTArchitectView compile errors
Point of interest - native iOS
Slider
Camera lagging / slow in native Swift application
Create a web service
N-th ImageDrawable not displayed
Radar Example
stop defaultlocationmanager and use architectview.injectlocation ios 10
WTC Size Limit
AngularJS and wikitude
See all 3869 topics
© 2021 Wikitude, a Qualcomm company
Fadi Eddine