You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tauri-plugins-workspace/plugins/notification/test/sound-notification.html

115 lines
3.3 KiB

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tauri Notification Sound Test</title>
<style>
body {
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
padding: 20px;
max-width: 800px;
margin: 0 auto;
background-color: #f5f5f5;
}
.container {
background-color: white;
padding: 20px;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}
h1 {
color: #0066cc;
}
button {
background-color: #0066cc;
color: white;
border: none;
padding: 10px 15px;
border-radius: 4px;
margin: 5px;
cursor: pointer;
transition: background-color 0.2s;
}
button:hover {
background-color: #004999;
}
.info {
background-color: #e6f7ff;
border-left: 4px solid #0066cc;
padding: 10px;
margin-bottom: 20px;
}
pre {
background-color: #f1f1f1;
padding: 10px;
border-radius: 4px;
overflow-x: auto;
}
</style>
</head>
<body>
<div class="container">
<h1>Tauri Notifications with Sound</h1>
<div class="info">
<p>This demo shows how to use sound with Tauri notifications across different platforms.</p>
<p>Make sure you have the notification plugin installed and configured correctly.</p>
</div>
<h2>Test Notifications</h2>
<button id="systemSound">Show Notification with System Sound</button>
<button id="customSound">Show Notification with Custom Sound</button>
<button id="platformSpecific">Show Platform-Specific Sound Notification</button>
<h2>Example Code</h2>
<pre>
// Example with system sound (mainly for macOS)
await sendNotification({
title: 'Notification with System Sound',
body: 'This notification uses a system sound on macOS.',
sound: 'Ping' // macOS system sound
});
// Example with custom sound file
await sendNotification({
title: 'Notification with Custom Sound',
body: 'This notification uses a custom sound file.',
sound: 'notification.wav' // path to your sound file
});
// Example with different sounds based on platform
const platform = await import('@tauri-apps/api/os').then(os => os.platform());
let soundPath;
if (platform === 'darwin') {
soundPath = 'Blow'; // macOS system sound
} else if (platform === 'linux') {
soundPath = 'message-new-instant'; // XDG theme sound
} else {
soundPath = 'notification.wav'; // Custom sound file for Windows
}
await sendNotification({
title: 'Platform-specific Sound',
body: `This notification uses platform-specific sound settings for ${platform}.`,
sound: soundPath
});</pre>
</div>
<script src="sound-notification.js"></script>
<script>
document.getElementById('systemSound').addEventListener('click', () => {
window.showNotificationWithSystemSound();
});
document.getElementById('customSound').addEventListener('click', () => {
window.showNotificationWithCustomSound();
});
document.getElementById('platformSpecific').addEventListener('click', () => {
window.showNotificationWithPlatformSpecificSound();
});
</script>
</body>
</html>