hai friends
How to paly song when page laod using php code?
I my php application when i load the home page automatically pale song
Its possible !! ??Please give me any idea
Thanks
vssp
hai friends
How to paly song when page laod using php code?
I my php application when i load the home page automatically pale song
Its possible !! ??Please give me any idea
Thanks
vssp
— the core point from is correct: PHP runs on the server and can only send HTML/JS to the browser; it can’t itself “play” sound after the page has been delivered. See the PHP manual for how server-side output works. (This means the solution is to have PHP emit client-side markup or script that the browser executes.) PHP manual. (php.net)
Modern, cross‑browser playback should use the HTML5 <audio> element rather than legacy tags or Flash; it offers built‑in controls, multiple source formats, and predictable behavior across devices. The basic approach is to have PHP output an <audio> element (or its sources) in the generated HTML, then handle play/unmute with JavaScript. MDN: <audio> element. (developer.mozilla.org)
Autoplay policies have tightened: most browsers block autoplay of audible media unless muted or allowed by user interaction or site engagement (muted autoplay is generally allowed). Chrome’s policy, the MDN autoplay guide, and WebKit’s iOS rules explain the exact conditions; iOS/Safari often needs playsinline + muted for inline autoplay. Because element.play() returns a Promise that can be rejected when autoplay is blocked, handle that rejection and fall back to showing controls or a play button. Chrome autoplay policy. (developer.chrome.com)
Practical example (emit from PHP and handle the play fallback in JS):
<audio id="bg" preload="auto" muted playsinline>
<source src="/media/song.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
<script>
const a = document.getElementById('bg');
a.play().catch(() => {
// Autoplay blocked: reveal controls or a visible play button
a.controls = true;
// Optionally show an "unmute/play" UI that calls a.play() after a user click
});
</script> For best UX, avoid forcing audible autoplay—mute + autoplay (with a clear unmute control) or require a user gesture. See MDN’s autoplay guide and the HTMLMediaElement.play() docs for promise behavior. (developer.mozilla.org)
Jump to Post— stymiee 111PHP only works on the server side. That means once it the page is sent to the browser PHP can't affect it anymore. You need to use HTML or JavaScript for this.
Jump to Post— digital-ether 399PHP only works on the server side. That means once it the page is sent to the browser PHP can't affect it anymore. You need to use HTML or JavaScript for this.
Or you can use flash. Even though I personally go against using flash as a substitute for html/javascript, …
PHP only works on the server side. That means once it the page is sent to the browser PHP can't affect it anymore. You need to use HTML or JavaScript for this.
PHP only works on the server side. That means once it the page is sent to the browser PHP can't affect it anymore. You need to use HTML or JavaScript for this.
Or you can use flash. Even though I personally go against using flash as a substitute for html/javascript, its the best when it comes to displaying multimedia online. It has the best scripting support for control of the media being played, and also is the most supported (or so they say).
You can use javascript to control media playing in a browser "plugin" such as quicktime or windows media player etc., but it can get quite complicated quite fast if you want to maximize browser support.
If you just want a simple you can just use the HTML tags <bgsound> or <embed>.
This will play a multimedia/sound file with the default supported player on your OS.
eg:
<bgsound src="soundfile.wav" autostart="true" loop="false" /> (not hundred percent sure of the syntax of that tag)
Thanks eather
<embed> is the right one
yes Good example
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.