How to add a music player to a php web page: 1. Define the mp3 file path on a disk; 2. Read the file size; 3. Set the media type of the file header; 4. Read the file.
The operating environment of this article: Windows 7 system, PHP version 7.4, DELL G3 computer
How to add a music player to the php webpage?
Add music playback code to the PHP web page
Define the mp3 file path under a disk, such as under d:/music
Read file size
Set the media type of the file header
Read file
<?php $path="d://music/"; $filesize=filesize($path.$file_name); header("Content-type:audio/mpeg"); header("Content-length:$filesize"); readfile($paht.$file_name); ?>
Play:
<object classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" width=300 height=300 hspace="0" vspace="0" align="top" id="MediaPlayer1" style="LEFT: 0px; TOP: 0px"> <param name="_ExtentX" value="5556"> <param name="ShowStatusBar" value="-1"> <param name="_ExtentY" value="1588"> <param name="AUTOSTART" value="-1"> <param name="SHUFFLE" value="0"> <param name="PREFETCH" value="0"> <param name="NOLABELS" value="0"> <param name="SRC" value="fileselect?file=曹操.mp3"> <param name="CONTROLS" value="Imagewindow,StatusBar,ControlPanel"> <param name="CONSOLE" value="RAPLAYER"> <param name="LOOP" value="0"> <param name="NUMLOOP" value="0"> <param name="CENTER" value="0"> <param name="MAINTAINASPECT" value="0"> <param name="BACKGROUNDCOLOR" value="#000000"> </object>
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to add a music player to a php web page. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SublimeText3 English version
Recommended: Win version, supports code prompts!

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function
