首页 咨询中心 IT学堂
在网页里插入背景音乐视频的方法汇总,怎样在网页中播放背景音乐和视频

在网页里插入背景音乐视频的方法有两种分别用<bgsound>和<embed></embed>标签,当用<embed>插入背景音乐时可以设置宽度和高度为0,隐藏播放器。

■ <bgsound>:

  <bgsound> 是用来插入背景音乐,但只适用于 ie,其参数设定不多。如下

  <bgsound src="your.mid" autostart=true loop=infinite>

src="your.mid"
设定 midi 档案及路径,可以是相对或绝对。
autostart=true
是否在音乐档下载完之后就自动播放。true 是,false 否 (内定值)。
loop=infinite
是否自动反复播放。loop=2 表示重复两次,infinite 表示重复多次。

■ <embed>:

  <embed> 是用来插入各种多媒体,格式可以是 midi、wav、aiff、au 等等,netscape 及 新版的 ie 都支持。其参数设定较多。如下下

  <embed src="your.mid" autostart="true" loop="true" hidden="true">

src="your.mid"
设定 midi 档案及路径,可以是相对或绝对。
autostart=true
是否在音乐档下载完之后就自动播放。true 是,false 否 (内定值)。
loop="true"
是否自动反复播放。loop=2 表示重复两次,true 是, false 否。
hidden="true"
是否完全隐藏控制画面,true 为是,no 为否 (内定)。
starttime="分:秒"
设定歌曲开始播放的时间。如 starttime="00:30" 表示从第30秒处开始播放。
volume="0-100"
设定音量的大小,数值是0到100之间。内定则为使用系统本身的设定。
width="整数" 和 high="整数"
设定控制面板的高度和宽度。(若 hidden="no")
align="center"
设定控制面板和旁边文字的对齐方式,其值可以是 top、bottom、center、baseline、 left、right、texttop、middle、absmiddle、absbottom
controls="smallconsole"
设定控制面板的外观。预设值是 console。
console 一般正常面板   
smallconsole 较小的面板   
playbutton 只显示播放按钮   
pausecutton 只显示暂停按钮   
stopbutton 只显示停止按钮   
volumelever 只显示音量调节按钮

实例:

   1. <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
   2. <html xmlns="http://www.w3.org/1999/xhtml">
   3. <head>
   4. <meta http-equiv="content-type" content="text/html; charset=gb2312" />
   5. <title>无标题文档</title>
   6. </head>
   7.
   8. <body>
   9. <bgsound src="http://sj.cpgl.net/sjbbs/midi/md01.mid " autostart=true loop=infinite>
  10. </body>
  11. </html>

复制代码

   1. <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
   2. <html xmlns="http://www.w3.org/1999/xhtml">
   3. <head>
   4. <meta http-equiv="content-type" content="text/html; charset=gb2312" />
   5. <title>无标题文档</title>
   6. </head>
   7.
   8. <body>
   9. <embed src="http://www.bricklin.cn/zly/theone/2.wma" width="0" height="0"></embed>
  10. </body>
  11. </html>

复制代码

**********************************************************************************************************************************

(一)、基本语法:

  embed src=url

  说明:embed可以用来插入各种多媒体,格式可以是 midi、wav、aiff、au、mp3等等,

  netscape及新版的ie 都支持。url为音频或视频文件及其路径,可以是相对路径或绝对路径。

  示例:<embed src="your.mid">

  (二)、属性设置:

  1、自动播放:

  语法:autostart=true、false

  说明:该属性规定音频或视频文件是否在下载完之后就自动播放。

  true:音乐文件在下载完之后自动播放;

  false:音乐文件在下载完之后不自动播放。

  示例:<embed src="your.mid" autostart=true>

  <embed src="your.mid" autostart=false>

  2、循环播放:

  语法:lo
上一篇 flash按钮文字鼠标经过时变色感应区不对滑到边上才变色的解决方法
上一篇 QQ嵌套到网页在网页里加入qq根据在线情况变化图像,QQ的头像是亮的,不在线时QQ的头像是灰色的
本方链接: http://www.web258.cn/article/show/i460.html