Calculator Tools Calculator Tools
Create

Piano com Som

Jan 5, 2024

About this app

Um piano virtual com som para tocar suas músicas favoritas.

Piano com Som Piano com Som

Related apps

Put this on your site

Source

                    <html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">

<title>Piano com Som</title>
<meta name="description" content="Um piano virtual com som para tocar suas músicas favoritas.">
<meta name="keywords" content="piano, teclado, música, som, instrumento">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">

<script type="text/javascript">
try {
// App Javascript Goes Here. Place your entire script content inside the try block for error handling.

// This will run when the DOM is ready.
document.addEventListener("DOMContentLoaded", function() {
// Define the piano keys and their corresponding sound files
const pianoKeys = [
{ key: 'C', sound: 'https://example.com/sounds/c.wav' },
{ key: 'D', sound: 'https://example.com/sounds/d.wav' },
{ key: 'E', sound: 'https://example.com/sounds/e.wav' },
{ key: 'F', sound: 'https://example.com/sounds/f.wav' },
{ key: 'G', sound: 'https://example.com/sounds/g.wav' },
{ key: 'A', sound: 'https://example.com/sounds/a.wav' },
{ key: 'B', sound: 'https://example.com/sounds/b.wav' },
];

// Create the piano keys dynamically
const pianoContainer = document.getElementById('piano-container');
pianoKeys.forEach(function(key) {
const keyElement = document.createElement('div');
keyElement.classList.add('piano-key');
keyElement.innerHTML = key.key;
keyElement.addEventListener('click', function() {
// Play the sound when the key is clicked
const audio = new Audio(key.sound);
audio.play();
});
pianoContainer.appendChild(keyElement);
});
});

} catch (error) {
// This will throw the error to the parent window.
throw error;
}
</script>

<style>
/* App CSS Goes Here */
.piano-key {
display: inline-block;
margin: 5px;
padding: 10px;
background-color: #ffcc00;
color: #fff;
border-radius: 5px;
cursor: pointer;
}
</style>
</head>
<body>
<div id="main-container" class="container">
<h1>Piano com Som</h1>
<div id="piano-container"></div>
</div>
</body>
</html>