Keeping in mind that I design very basic webpages using Dreamweaver, can anyone advise on including music. A client has asked me if I could do it. Of course, firstly copyright comes to mind but is there an easy way to insert music. I tried with a midi file in Dreamweaver but it gave me a message that it was in the wrong format or somesuch.

Dani AI

Generated

A short, modern follow‑up to the thread: the recommended way to add music now is the HTML5 <audio> element with visible controls and format fallbacks. Provide at least an MP3 (widely supported) and an Ogg/WebM fallback so browsers can pick a playable codec, and include a simple download link for really old clients. Example:

<audio controls preload="metadata">
  <source src="music.mp3" type="audio/mpeg">
  <source src="music.ogg" type="audio/ogg">
  Your browser does not support the audio element. <a href="music.mp3">Download</a>
</audio>

This is the standard, cross‑browser approach and pairs cleanly with the Web Audio API when more control or effects are needed. (developer.mozilla.org)

Practical best practices (addresses points from , and others): do not autoplay music by default — modern browsers block or restrict audible autoplay unless muted or user‑initiated, and autoplay annoys many visitors. Offer an explicit play/pause control (or let the browser show its controls), keep clips short and bitrate reasonable for web delivery, and always provide a transcript or media alternative for audio‑only content to meet accessibility guidance (WCAG). The old <bgsound>/IE trick mentioned earlier is obsolete and should be replaced. (developer.mozilla.org)

WordPress and Firefox notes (for ): WordPress core provides an [audio] shortcode and an Audio block that output an HTML5 player (and WP ships MediaElement.js for consistent UI), so embedding works in Firefox and other browsers if sources are provided in supported formats. To implement an on/off toggle (band‑site behavior suggested by ), use a small play/pause button wired to the <audio> API and persist the state in localStorage. Example pattern:

<button id="musicToggle">Play</button>
<audio id="musicPlayer" preload="none">
  <source src="music.mp3" type="audio/mpeg">
</audio>

<script>
const p = document.getElementById('musicPlayer');
const b = document.getElementById('musicToggle');
b.addEventListener('click', () => {
  if (p.paused) { p.play(); b.textContent='Pause'; localStorage.setItem('music','on'); }
  else { p.pause(); b.textContent='Play'; localStorage.setItem('music','off'); }
});
if (localStorage.getItem('music')==='on') p.play();
</script>

Use only properly licensed or royalty‑free music and keep UX in mind — ambient music rarely helps conversions or usability unless it's directly relevant to the site. (wordpress.org)

Recommended Answers

All 10 Replies

Thanks for that! I have read quite alot about the fact that many people do find music irritating...I think I will discourage my client.

Usually whenever I ask, people say the only time it's acceptable is on a band site type of thing, where you have an option to turn it off/on. I've never actually worked out how to do that one tho...

How abt real or windows media streaming? Unlike wav or mp3 format, it does not load too long.

thats simple dude ! its just a piece of code.....
but be sure u put ur file (audio format) very small, less than 20 - 50 kb.
coz it may take time to load when u put some big huge files such as mp3's.

ok here you go with the code ::

The Source Code is :

<bgsound="filename.midi" loop="2">

the filename.midi can be anything, but a valid file format, and loop is nuthing but how many times you want the the audio files to be played !

hope this might help you mate ! any thing else buzz me @ yahoo : go4inet

Oh ,Thanks for that information .
I was searched that information a lot of time and i just a wonder is there any info and i was searched the web , daniweb is like a database :D .


Oh ,i just sow the fire near a tread i hope that i did not cause any problem .

thats simple dude ! its just a piece of code.....
but be sure u put ur file (audio format) very small, less than 20 - 50 kb.
coz it may take time to load when u put some big huge files such as mp3's.

ok here you go with the code ::

hope this might help you mate ! any thing else buzz me @ yahoo : go4inet

I have tried that code but it works on IE. How to make it work on firefox? and also on wordpress?

Have look into , you will see various options like Windows Media Player, Quick Time or Real Player and it is up to you to choose from

It works me me and my clients, they love it. I'm not sure what the problem is. You can turn it on and off anytime the page is loaded. It may not be for everyone, but it does work for many. I also use it to let clients hear what Royalty-free music they can use for a web page I might be designing for them on their site. see: <URL SNIPPED>
Chuck

The trouble is that people looking for a product in a work environment do NOT want music blaring up in the middle of their cube farm. This causes prariedogging, as neighboring workers pop up to see what caused the disturbance.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.