Page 1 of 2

Audio autoplay in JS

Posted: Fri Dec 27, 2013 10:11 am
by Ivan6481911

Hello.
How can I set autoplay in js?
I tried this, but it didn't work:

Code: Select all

var player = Appery('audioComponent'); 
player.attr('autoplay', 1); 

Thanks!


Audio autoplay in JS

Posted: Fri Dec 27, 2013 10:31 am
by Ivan6481911

player.play(); - doesn't work


Audio autoplay in JS

Posted: Fri Dec 27, 2013 10:59 am
by Maryna Brodina

Hello! Try preAppery("mobileaudio_6").get(0).play();
Appery("mobileaudio_6").get(0).pause();/prewhere mobileaudio_6 - audion component name


Audio autoplay in JS

Posted: Fri Dec 27, 2013 12:55 pm
by Ivan6481911

M-m-m... It didn't work.
Here is my code:

var player = Appery('audioComponent');
player.attr('src', value.filePath);
player.attr('type', 'audio/mpeg');

Code: Select all

 player.get(0).play(); 
 // Appery('audioComponent').get(0).play(); - not working 
 // Appery('audioComponent').play(); - not working

Audio autoplay in JS

Posted: Fri Dec 27, 2013 12:56 pm
by Ivan6481911

Music is playing, when I tap play btn on component.


Audio autoplay in JS

Posted: Fri Dec 27, 2013 2:39 pm
by Maryna Brodina

1) Delete this line preplayer.attr('type', 'audio/mpeg');/pre2) There is no need to use additional variable, try this preAppery('audioComponent').attr('src', value.filePath);
Appery('audioComponent').get(0).play();/pre


Audio autoplay in JS

Posted: Mon Dec 30, 2013 11:53 am
by Ivan6481911

Hello again.
H-m-m... Strange, but it didn't help. Here is my code:

Code: Select all

 Appery('audioComponent').attr('src', value.filePath); 

 //if (value.autoplay === 1) { 

Appery('audioComponent').get(0).play();
//}

Can I test autoplay it in browser or on mobile only? For now it is now playing nor in browser neighter on simulator or device.


Audio autoplay in JS

Posted: Mon Dec 30, 2013 11:55 am
by Ivan6481911

Perhaps, I can get element with Tiggizi somehow?


Audio autoplay in JS

Posted: Mon Dec 30, 2013 12:10 pm
by Oleg Danchenkov

Hi Ivan.
Where do you use your code (action, mapping, etc...)?
Could you please clarify (or send us few screenshots).


Audio autoplay in JS

Posted: Mon Dec 30, 2013 2:03 pm
by Oleg Danchenkov

BTW you can use jplayer instead of audio component.
See http://jplayer.org/