语言

Menu
Sites
Language
How to play a simple .mp3 or .wav file in samsung gear 2?

Hi,

I am trying to play a simple .wav file in samsung gear 2 programmattically, but still with no luck.I just referred the voice Recoder but it's too complex an I was not able to integrate it to do the function.So is there any method to play the file simply (like mediplayer in android) or any sample projects will be of great help.

 

Regards,

Sunil Sunny

编辑者为: sunil sunny 17 6月, 2014
查看选择的答案

响应

5 回复
Mark as answer
sunil sunny

I got the answer it was simple silly me..

just add a <audio> tag in index.html and call a new audio object like audio=new Audio() 

 set the path and audio.play() will play the sound.

Stefano Accorsi

Hi! I got the same problem and I don't understand your answer.

I got something like:

<audio id="audio" src="media/xxx.mp3" controls preload="auto" loop>

and want to stop through js code. I tried a simple:

var audio = document.getElementById("audio");
audio.stop();

but "audio.stop()" is "undefined" at run time ...

But I see you wrote one needs to create a "new" audio object like audio=new Audio(); so how to link this new object with the one displayed in html? TY

 

Stefano Accorsi

Forgive me: stop don't exists :) I used pause instead.

But the problem is quite the same: when the page with the audio control opens I'd like to let the audio autoplay but neighter:

<audio id="audio" src="media/xxx.mp3" controls autoplay preload="auto" loop>

nor:

var audio = document.getElementById("audio");
audio.play();

works.

AVSukhov

Hello,

You can use HTML5 audio and video tags

Stefano Accorsi

Ty! I used <audio> tag but I shouldn't play or pause it through code. But it wasn't a widget addressing problem: it was an application lifecycle issue: I tried to stop it before the widget was drawed on the screen ...

Really thank you anyway!