K
K
Konstantin_Pak_Swinburne2019-09-27 17:51:41
Java
Konstantin_Pak_Swinburne, 2019-09-27 17:51:41

Would you like to create an application so that when a button is pressed, the sound effect of sneezing and blowing your nose is played, or when the device is rotated?

In general, the task is this, when the Sneeze button is pressed, the android makes a sound (sneeze), immediately after it comes another Blowing sound (blowing). Now, when the orientation is changed from Portrait to Landscape, a Sneeze (sneeze) is performed. When back, from Landscape to Portrait, Blowing occurs. Everything is clear about the buttons, you just need to execute onclicklistener, but how to make the corresponding sounds come out when you change the orientation?
5d8e21e67003f539313785.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2019-09-27
@NeiroNx

I think even the application is not needed - you can get by with a regular local web page.

<script>
var a=new Audio, 
p= function(s){a.pause();a.currentTime = 0;a.volume =0.9;a.src=s;a.play();return true;};
window.addEventListener("onorientationchange" in window ? "orientationchange" : "resize", function(e) {
switch(e.orientation){
case "portrait": return p('sneeze.mp3');
case "landscape": return p('blow_nose.mp3');
}}, false);
</script><style>div{text-align:center;margin:20px;}button{padding:20px}</style>
<div><button onclick="p('sneeze.mp3')">SNEEZE</button></div>
<div><button onclick="p('blow_nose.mp3')">BLOW NOSE</button></div>
<div><button onclick="p('take.mp3')">TAKE MEDI</button></div>

The hardest part is finding the sounds.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question