{"id":13671638,"url":"https://github.com/IFmiss/wx-audio","last_synced_at":"2025-04-27T18:31:29.035Z","repository":{"id":89121727,"uuid":"102848806","full_name":"IFmiss/wx-audio","owner":"IFmiss","description":":evergreen_tree: 原生js实现微信公众号音乐播放器      A WeChat music player component ","archived":false,"fork":false,"pushed_at":"2024-03-10T14:18:56.000Z","size":15636,"stargazers_count":68,"open_issues_count":1,"forks_count":22,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-11-11T09:43:51.375Z","etag":null,"topics":["audio","music","weixin","weixin-audio","weixin-music","wx"],"latest_commit_sha":null,"homepage":"http://www.daiwei.org/components/wx-audio/html/audio.html","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/IFmiss.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-09-08T10:17:01.000Z","updated_at":"2024-03-19T16:50:19.000Z","dependencies_parsed_at":"2024-11-11T13:15:26.814Z","dependency_job_id":null,"html_url":"https://github.com/IFmiss/wx-audio","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IFmiss%2Fwx-audio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IFmiss%2Fwx-audio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IFmiss%2Fwx-audio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IFmiss%2Fwx-audio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IFmiss","download_url":"https://codeload.github.com/IFmiss/wx-audio/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251187208,"owners_count":21549602,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["audio","music","weixin","weixin-audio","weixin-music","wx"],"created_at":"2024-08-02T09:01:15.190Z","updated_at":"2025-04-27T18:31:28.606Z","avatar_url":"https://github.com/IFmiss.png","language":"JavaScript","readme":"# wx-audio\n微信公众号音乐播放器\n\n#### 基于原生js写的一款仿微信公众号的音乐组件\n\n## 演示地址\nhttp://www.daiwei.org/components/wx-audio/\n\n## 手机预览\n\n### 安装 \nnpm 安装\n```js\n  npm install @dw/wx-audio\n```\n\n### 引入\n```js\n  import WxAudio from '@dw/wx-audio/lib/wx-audio.css'\n  import WxAudio from '@dw/wx-audio'\n```\n\n普通资源引入,先将lib文件下的目录放到自己的项目中，然后根据路径引入\n```html\n\u003clink href=\"./wx-audio.css\" rel=\"stylesheet\"\u003e\n\u003cscript type=\"text/javascript\" src=\"wx-audio.js\"\u003e\u003c/script\u003e\n```\n\n### 实例化 音乐组件 \n```js\nvar wxAudio = new WxAudio({\n  ele: '#textaudio1',\n  title: '河山大好',\n  disc: '许嵩',\n  src: 'http://oiq8j9er1.bkt.clouddn.com/%E8%AE%B8%E5%B5%A9%20-%20%E6%B2%B3%E5%B1%B1%E5%A4%A7%E5%A5%BD1.mp3',\n  width: '320px',\n  autoplay: true,\n  loop: true,\n  ended: function () {\n    alert('播放结束')\n  }\n});\n```\n\n### 属性\n  - ele dom对象\n  - title 音乐标题\n  - disc 描述，可以当做显示歌手名称\n  - src 地址\n  - width 显示的宽度\n  - loop 是否循环（当循环状态下时候，ended事件不会执行）\n  - ended 方法，是一个回调，可在音乐播放结束之后执行其他的代码\n  - autoplay 属性， 是否自动播放，这个只能在微信浏览器以及只设置静态src才能自动播放\n### 方法\n```js\n // 实例化的wxAudio可以这样操作\nwxAudio.audioPlay()   // 播放\n\nwxAudio.audioPause()   // 暂停\n\nwxAudio.audioPlayPause()  // 播放暂停\n\nwxAudio.showLoading(bool)  //显示加载状态  参数bool\n \nwxAudio.audioCut(src,title,disc)  实现音频切换的效果\n```\n\n### 新增 音乐组件切歌方法 \n通过实例化的wxAudio的audioCut(src,title,disc)  实现音频切换的效果  示例代码如下\n```js\n  var src = 'http://oiq8j9er1.bkt.clouddn.com/%E6%9E%97%E4%BF%8A%E6%9D%B0%20-%20%E5%A5%B9%E8%AF%B41.mp3'\n  var title = '她说'\n  var disc = '林俊杰'\n  wxAudio.audioCut(src, title, disc)\n```\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FIFmiss%2Fwx-audio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FIFmiss%2Fwx-audio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FIFmiss%2Fwx-audio/lists"}