Ask away

playing audio sounds in the nest application

Megan 05/16/17 11:19

79 views

Question CategoryComponent,Properties,Form Event

Number of completed projects0

Question StatusUnsolved

  • audio sounds
  • nest app
  • nest component

Question

I'm developing the nest components for playing audio sound in my nest application I tried many codes but I didn't figure out what I'm doing wrong at the bottom I put two pieces of code that I tried them the first component code (js code in a separate file) var app = { initialize: function() { this.bindEvents(); }, bindEvents: function() { document.addEventListener('deviceready', this.onDeviceReady, false); }, onDeviceReady: function() { var myMedia = new Media("../sounds/clapping.mp3"); myMedia.play(); } }; app.initialize(); the second code (js code in a script tag) : document.addEventListener("deviceready", function(){ var myMedia = null; function playAudio() { var src = "sounds/clapping.mp3"; if(myMedia === null) { myMedia = new Media(src, onSuccess, onError); function onSuccess() { console.log("playAudio Success"); } function onError(error) { console.log("playAudio Error: " + error.code); } } myMedia.play(); } document.getElementById("playAudio").addEventListener("click", playAudio); }); with a button : <button id ="playAudio">PLAY</button> How can I solve this problem?

Answers

1
Bev 05/23/17 11:26

I don't understand why did you try to develop your owns code. you can use the nest component on component palette or store. It works to play the audio file for your app

Answer

Project

Image

Comment