GithubHelp home page GithubHelp logo

webchataudio's Introduction

中文 | English

##weixinAudio.js ####一个简单的微信样式播放器


播放器DOM及CSS是微信里内置的音频播放器的样式,重新创建了控制层js,方便在在公众号,APP等场景使用。

###例子

demo

###如何使用

通过以下demo来实现

###HTML模板

<p class="weixinAudo">
	<audio src="../sound/sound1.mp3" id="media" width="1" height="1" preload></audio>
	<span id="audio_area" class="db audio_area">
		<span class="audio_wrp db">
			<span class="audio_play_area">
				<i class="icon_audio_default"></i>
				<i class="icon_audio_playing"></i>
            </span>
			<span id="audio_length" class="audio_length tips_global">3:07</span>
			<span class="db audio_info_area">
                <strong class="db audio_title">标题1</strong>
                <span class="audio_source tips_global">来源1</span>
			</span>
			<span id="audio_progress" class="progress_bar" style="width: 0%;"></span>
	 	</span>
	</span>
</p>
<!-- 也可以多音频使用 -->
<!-- 注意使用同一类名,在js中进行初始化 -->
<p class="weixinAudo">
  <audio src="../sound/sound2.mp3" id="media" width="1" height="1" preload></audio>
  <span id="audio_area" class="db audio_area">
    <span class="audio_wrp db">
      <span class="audio_play_area">
        <i class="icon_audio_default"></i>
        <i class="icon_audio_playing"></i>
            </span>
      <span id="audio_length" class="audio_length tips_global">3:07</span>
      <span class="db audio_info_area">
                <strong class="db audio_title">标题2</strong>
                <span class="audio_source tips_global">来源2</span>
      </span>
      <span id="audio_progress" class="progress_bar" style="width: 0%;"></span>
    </span>
  </span>
</p>

###Js调用

//你需要先引入一个jQuery
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script src="js/weixinAudio.js"></script>
<script>
   $('.weixinAudo').weixinAudio(options);
</script>

###options/初始化参数

Option Type Default Description
autoplay Boolean false 播放器是否在初始化时自动播放
src String 如果audio标签上没设定src属性,可在初始化时设置

###API/执行方法

Method Parameters Description
play() 播放方法
pause() 暂停方法
changsrc() src,callback src:播放的地址;callback:回调函数

webchataudio's People

Contributors

warpcgd avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.