How to play an audio file

Hi,

I work on a project to use the health sensor. And I want when the maximun of heart rate is reached then a music is playing. however I don’t know which function to use and how to play music. Can you help me ? thank

Hello ami1605959356,
Welcome to the community!
Would you please share the platform(Tizen Native/Tizen Web) of your project with us so that we can suggest you based on that?

Thank you!

1 Like

Hello,
Thank you for you answer, I succeded to play an audio file however now I would like to make a tag appear in java. In fact, I want to see when the myplay is run. In C I know that there is “dlog” function but in Java I don’t know. Could you help me ?
Thanks you

  function setLimitExceeded(exceeded) {
        if (exceeded) {
            page.classList.add('limit-excedeed');
            vibration.start();							// la montre vibre 
            myMedia.play();								//joue le morceau 
           // Log.i("Acachan", "music play");           //EXEMPLE  TAG
           
        } else {
            page.classList.remove('limit-excedeed');
            vibration.stop();
            /*setTimeout(function()				//stop le morceau apres tant de minute 
            		{
            		  myMedia.stop();           //on arrete le morceau 
            		}, 5000);					//5s après*/
            
			myMedia.pause();
        }
    }

First of all check your speaker system, download a ringtone then turn it on to see if your speakers are working properly?

In JavaScript you have to use console.debug() or console.info() functions to debug your code under device. You should run you code in Debug mode to see logs on console window in Tizen Studio.

For example console.debug(‘my sound is playing’);

Pls read more here: console - Web APIs | MDN