html学习笔记之2——多媒体

一:插件

   插件可以通过 <object> 标签或者 <embed> 标签添加在页面中。

<object width="400" height="50" data="插件路径"></object> 
<embed width="100%" height="500px" src="插件路径">

    插件可以是辅助应用程序,也可以是视频、音频、动画、图片等。

二:HTML中播放音频的几种解决办法

    1:使用插件

<embed height="50" width="100" src="xxx.mp3">
 <object height="50" width="100" data="xxx.mp3"></object>

    2:使用H5提供的audio标签

<audio controls>
   <source src="xxx.mp3" type="audio/mpeg">
   <source src="xxx.ogg" type="audio/ogg">
 </audio> 

    3:综合使用audio和插件

<audio controls height="100" width="100">
   <source src="xxx.mp3" type="audio/mpeg">
   <source src="xxx.ogg" type="audio/ogg">
   <embed height="50" width="100" src="xxx.mp3">
 </audio> 

    4:引入第三方JS组件

<script src="http://mediaplayer.yahoo.com/latest"></script>  //引入组件库

 <a href="xxx.mp3">Audio</a> //链接到音频文件即可

三:HTML中播放视频

    1:使用H5

<video width="320" height="240" controls>
   <source src="movie.mp4" type="video/mp4">
   <source src="movie.ogg" type="video/ogg">
   <source src="movie.webm" type="video/webm">
   <object data="movie.mp4" width="320" height="240">
     <embed src="movie.swf" width="320" height="240">
   </object> 
 </video> 

    HTML 5 <video> 元素会尝试播放以 mp4、ogg 或 webm 格式中的一种来播放视频。如果均失败,则回退到 <embed> 元素。

    2:引入视频链接

    可以把视频上传到一些视频网站,然后通过链接来播放视频。

<embed src="视频链接" width="480" height="400" type="application/x-shockwave-flash"> </embed> 

猜你喜欢

转载自www.cnblogs.com/ygj0930/p/9052832.html