Home > Backend Development > PHP Problem > How to add a music player to a php web page

How to add a music player to a php web page

藏色散人
Release: 2023-03-14 09:24:01
Original
3271 people have browsed it

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.

How to add a music player to a php web page

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);
?>
Copy after login

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>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template