Comparing version
@@ -1,1 +0,1 @@ | ||
'use strict';console.log('\n %c MetingJS v1.2.0 %c https://github.com/metowolf/MetingJS \n','color: #fadfa3; background: #030307; padding:5px 0;','background: #fadfa3; padding:5px 0;');var aplayers=[],loadMeting=function(){function a(a,b){var c={container:a,audio:b,mini:null,fixed:null,autoplay:!1,mutex:!0,lrcType:3,listFolded:!1,preload:'auto',theme:'#2980b9',loop:'all',order:'list',volume:null,listMaxHeight:null,customAudioType:null,storageName:'metingjs'};if(b.length){b[0].lrc||(c.lrcType=0);var d={};for(var e in c){var f=e.toLowerCase();(a.dataset.hasOwnProperty(f)||a.dataset.hasOwnProperty(e)||null!==c[e])&&(d[e]=a.dataset[f]||a.dataset[e]||c[e],('true'===d[e]||'false'===d[e])&&(d[e]='true'==d[e]))}aplayers.push(new APlayer(d))}}var b='https://api.i-meto.com/meting/api?server=:server&type=:type&id=:id&r=:r';'undefined'!=typeof meting_api&&(b=meting_api);for(var f=0;f<aplayers.length;f++)try{aplayers[f].destroy()}catch(a){console.log(a)}aplayers=[];for(var c=document.querySelectorAll('.aplayer'),d=function(){var d=c[e],f=d.dataset.id;if(f){var g=d.dataset.api||b;g=g.replace(':server',d.dataset.server),g=g.replace(':type',d.dataset.type),g=g.replace(':id',d.dataset.id),g=g.replace(':auth',d.dataset.auth),g=g.replace(':r',Math.random());var h=new XMLHttpRequest;h.onreadystatechange=function(){if(4===h.readyState&&(200<=h.status&&300>h.status||304===h.status)){var b=JSON.parse(h.responseText);a(d,b)}},h.open('get',g,!0),h.send(null)}else if(d.dataset.url){var i=[{name:d.dataset.name||d.dataset.title||'Audio name',artist:d.dataset.artist||d.dataset.author||'Audio artist',url:d.dataset.url,cover:d.dataset.cover||d.dataset.pic,lrc:d.dataset.lrc,type:d.dataset.type||'auto'}];a(d,i)}},e=0;e<c.length;e++)d()};document.addEventListener('DOMContentLoaded',loadMeting,!1); | ||
"use strict";function _objectSpread(a){for(var b=1;b<arguments.length;b++){var c=null==arguments[b]?{}:arguments[b],d=Object.keys(c);"function"==typeof Object.getOwnPropertySymbols&&(d=d.concat(Object.getOwnPropertySymbols(c).filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable}))),d.forEach(function(b){_defineProperty(a,b,c[b])})}return a}function _defineProperty(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}class MetingJSElement extends HTMLElement{connectedCallback(){window.APlayer&&window.fetch&&(this._init(),this._parse())}disconnectedCallback(){this.lock||this.aplayer.destroy()}_camelize(a){return a.replace(/^[_.\- ]+/,"").toLowerCase().replace(/[_.\- ]+(\w|$)/g,(a,b)=>b.toUpperCase())}_init(){let a={};for(let b=0;b<this.attributes.length;b+=1)a[this._camelize(this.attributes[b].name)]=this.attributes[b].value;let b=["server","type","id","api","auth","auto","lock","name","title","artist","author","url","cover","pic","lyric","lrc"];for(var c=0;c<b.length;c++){let d=b[c];this[d]=a[d],delete a[d]}this.config=a,this.api=this.api||window.meting_api||"https://api.i-meto.com/meting/api?server=:server&type=:type&id=:id&r=:r",this.auto&&this._parse_link()}_parse_link(){let a=[["music.163.com.*song.*id=(\\d+)","netease","song"],["music.163.com.*album.*id=(\\d+)","netease","album"],["music.163.com.*artist.*id=(\\d+)","netease","artist"],["music.163.com.*playlist.*id=(\\d+)","netease","playlist"],["music.163.com.*discover/toplist.*id=(\\d+)","netease","playlist"],["y.qq.com.*song/(\\w+).html","tencent","song"],["y.qq.com.*album/(\\w+).html","tencent","album"],["y.qq.com.*singer/(\\w+).html","tencent","artist"],["y.qq.com.*playsquare/(\\w+).html","tencent","playlist"],["y.qq.com.*playlist/(\\w+).html","tencent","playlist"],["xiami.com.*song/(\\w+)","xiami","song"],["xiami.com.*album/(\\w+)","xiami","album"],["xiami.com.*artist/(\\w+)","xiami","artist"],["xiami.com.*collect/(\\w+)","xiami","playlist"]];for(var b=0;b<a.length;b++){let c=a[b],d=new RegExp(c[0]),e=d.exec(this.auto);if(null!==e)return this.server=c[1],this.type=c[2],void(this.id=e[1])}}_parse(){if(this.url){let a={name:this.name||this.title||"Audio name",artist:this.artist||this.author||"Audio artist",url:this.url,cover:this.cover||this.pic,lrc:this.lrc||this.lyric||"",type:this.type||"auto"};return a.lrc||(this.lrcType=0),this.innerText&&(a.lrc=this.innerText,this.lrcType=2),void this._loadPlayer([a])}let a=this.api.replace(":server",this.server).replace(":type",this.type).replace(":id",this.id).replace(":auth",this.auth).replace(":r",Math.random());fetch(a).then(a=>a.json()).then(a=>this._loadPlayer(a))}_loadPlayer(a){let b={audio:a,mutex:!0,lrcType:this.lrcType||3,storageName:"metingjs"};if(a.length){let a=_objectSpread({},b,this.config);for(let b in a)("true"===a[b]||"false"===a[b])&&(a[b]="true"===a[b]);let c=document.createElement("div");a.container=c,this.appendChild(c),this.aplayer=new APlayer(a)}}}console.log("\n %c MetingJS v2.0.0 %c https://github.com/metowolf/MetingJS \n","color: #fadfa3; background: #030307; padding:5px 0;","background: #fadfa3; padding:5px 0;"),window.customElements&&!window.customElements.get("meting-js")&&(window.MetingJSElement=MetingJSElement,window.customElements.define("meting-js",MetingJSElement)); |
{ | ||
"name": "meting", | ||
"version": "1.2.0", | ||
"description": "Wow, such a beautiful html5 music player (with Meting API)", | ||
"main": "dist/Meting.min.js", | ||
"scripts": { | ||
"dev": "npm run development", | ||
"development": "babel src/Meting.js -o dist/Meting.min.js", | ||
"prod": "npm run production", | ||
"production": "BABEL_ENV=production babel src/Meting.js -o dist/Meting.min.js", | ||
"test": "npm run production" | ||
}, | ||
"repository": { | ||
"url": "git+https://github.com/metowolf/MetingJS.git", | ||
"type": "git" | ||
}, | ||
"keywords": [ | ||
"player", | ||
"music", | ||
"api", | ||
"meting", | ||
"html5" | ||
], | ||
"author": "metowolf", | ||
"license": "MIT", | ||
"homepage": "https://github.com/metowolf/MetingJS", | ||
"devDependencies": { | ||
"babel-cli": "^6.26.0", | ||
"babel-minify": "^0.4.3", | ||
"babel-preset-env": "^1.7.0", | ||
"babel-preset-minify": "^0.4.3" | ||
} | ||
"name": "meting", | ||
"version": "2.0.0", | ||
"description": "Wow, such a beautiful html5 music player (with Meting API)", | ||
"license": "MIT", | ||
"homepage": "https://github.com/metowolf/MetingJS", | ||
"repository": { | ||
"url": "git+https://github.com/metowolf/MetingJS.git", | ||
"type": "git" | ||
}, | ||
"author": { | ||
"name": "metowolf", | ||
"email": "i@i-meto.com", | ||
"url": "https://i-meto.com/" | ||
}, | ||
"main": "dist", | ||
"scripts": { | ||
"lint": "eslint source", | ||
"build": "del dist && mkdir dist && babel source/Meting.js -o dist/Meting.min.js", | ||
"test": "npm run build", | ||
"prepublishOnly": "npm run build" | ||
}, | ||
"files": [ | ||
"dist" | ||
], | ||
"keywords": [ | ||
"player", | ||
"music", | ||
"api", | ||
"meting", | ||
"html5" | ||
], | ||
"devDependencies": { | ||
"@babel/cli": "^7.2.3", | ||
"@babel/core": "^7.3.3", | ||
"@babel/preset-env": "^7.3.1", | ||
"babel-preset-minify": "^0.5.0", | ||
"del-cli": "^1.1.0", | ||
"eslint": "^5.14.0" | ||
} | ||
} |
111
README.md
@@ -18,9 +18,8 @@ <p align="center"> | ||
|---|---|---| | ||
|1.0.x|Deprecated|[](https://github.com/MoePlayer/APlayer/tree/1.6.0)| | ||
|1.1.x|Compatibility|[](https://github.com/MoePlayer/APlayer/tree/1.7.0)| | ||
|1.2.x|Latest|[](https://github.com/MoePlayer/APlayer)| | ||
|1.2.x|Supported|[](https://github.com/MoePlayer/APlayer)| | ||
|2.0.x|Latest|[](https://github.com/MoePlayer/APlayer)| | ||
## CDN | ||
- https://cdn.jsdelivr.net/npm/meting@1.2/dist/Meting.min.js | ||
- https://unpkg.com/meting@1.2/dist/Meting.min.js | ||
- https://cdn.jsdelivr.net/npm/meting@2/dist/Meting.min.js | ||
- https://unpkg.com/meting@2/dist/Meting.min.js | ||
@@ -30,12 +29,12 @@ ## Quick Start | ||
<!-- require APlayer --> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer@1.10/dist/APlayer.min.css"> | ||
<script src="https://cdn.jsdelivr.net/npm/aplayer@1.10/dist/APlayer.min.js"></script> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css"> | ||
<script src="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js"></script> | ||
<!-- require MetingJS --> | ||
<script src="https://cdn.jsdelivr.net/npm/meting@2/dist/Meting.min.js"></script> | ||
<div class="aplayer" | ||
data-id="60198" | ||
data-server="netease" | ||
data-type="playlist"> | ||
</div> | ||
<script src="dist/Meting.min.js"></script> | ||
<meting-js | ||
server="netease" | ||
type="playlist" | ||
id="60198"> | ||
</meting-js> | ||
``` | ||
@@ -45,21 +44,33 @@ https://music.163.com/#/playlist?id=60198 | ||
```html | ||
<div class="aplayer" | ||
data-name="rainymood" | ||
data-artist="rainymood" | ||
data-url="https://rainymood.com/audio1110/0.m4a" | ||
data-cover="https://rainymood.com/i/badge.jpg"> | ||
</div> | ||
<meting-js | ||
auto="https://y.qq.com/n/yqq/song/001RGrEX3ija5X.html"> | ||
</meting-js> | ||
``` | ||
https://y.qq.com/n/yqq/song/001RGrEX3ija5X.html | ||
```html | ||
<meting-js | ||
name="rainymood" | ||
artist="rainymood" | ||
url="https://rainymood.com/audio1110/0.m4a" | ||
cover="https://rainymood.com/i/badge.jpg"> | ||
</meting-js> | ||
``` | ||
for self-hosted media | ||
```html | ||
<div class="aplayer" | ||
data-name="广东珠江经济电台" | ||
data-artist="FM97.4" | ||
data-url="http://lhttp.qingting.fm/live/1259/64k.mp3" | ||
data-cover="http://pic.qingting.fm/2015/0209/20150209212831195.jpg!200" | ||
data-fixed="true"> | ||
</div> | ||
<meting-js | ||
name="rainymood" | ||
artist="rainymood" | ||
url="https://rainymood.com/audio1110/0.m4a" | ||
cover="https://rainymood.com/i/badge.jpg" | ||
fixed="true"> | ||
<pre hidden> | ||
[00:00.00]This | ||
[00:04.01]is | ||
[00:08.02]lyric | ||
</pre> | ||
</meting-js> | ||
``` | ||
Fixed mode | ||
Fixed mode with Lyric text | ||
@@ -71,19 +82,19 @@ | ||
|:--------------------|:------------:|:----------| | ||
|data-id |**require** |song id / playlist id / album id / search keyword| | ||
|data-server |**require** |music platform: `netease`, `tencent`, `kugou`, `xiami`, `baidu`| | ||
|data-type |**require** |`song`, `playlist`, `album`, `search`, `artist`| | ||
|data-fixed |`false` |enable fixed mode| | ||
|data-mini |`false` |enable mini mode| | ||
|data-autoplay |`false` |audio autoplay| | ||
|data-theme |`#2980b9` |main color| | ||
|data-loop |`all` |player loop play, values: 'all', 'one', 'none'| | ||
|data-order |`list` |player play order, values: 'list', 'random'| | ||
|data-preload |`auto` |values: 'none', 'metadata', 'auto'| | ||
|data-volume |`0.7` |default volume, notice that player will remember user setting, default volume will not work after user set volume themselves| | ||
|data-mutex |`true` |prevent to play multiple player at the same time, pause other players when this player start play| | ||
|data-lrctype |`0` |lyric type| | ||
|data-listfolded |`false` |indicate whether list should folded at first| | ||
|data-listmaxheight |`340px` |list max height| | ||
|data-storagename |`metingjs` |localStorage key that store player setting| | ||
|~~data-mode~~ |**deprecated**|Instead `data-loop`, `data-order` should be used| | ||
|id |**require** |song id / playlist id / album id / search keyword| | ||
|server |**require** |music platform: `netease`, `tencent`, `kugou`, `xiami`, `baidu`| | ||
|type |**require** |`song`, `playlist`, `album`, `search`, `artist`| | ||
|auto |options |music link, support: `netease`, `tencent`, `xiami`| | ||
|fixed |`false` |enable fixed mode| | ||
|mini |`false` |enable mini mode| | ||
|autoplay |`false` |audio autoplay| | ||
|theme |`#2980b9` |main color| | ||
|loop |`all` |player loop play, values: 'all', 'one', 'none'| | ||
|order |`list` |player play order, values: 'list', 'random'| | ||
|preload |`auto` |values: 'none', 'metadata', 'auto'| | ||
|volume |`0.7` |default volume, notice that player will remember user setting, default volume will not work after user set volume themselves| | ||
|mutex |`true` |prevent to play multiple player at the same time, pause other players when this player start play| | ||
|lrc-type |`0` |lyric type| | ||
|list-folded |`false` |indicate whether list should folded at first| | ||
|list-max-height |`340px` |list max height| | ||
|storage-name |`metingjs` |localStorage key that store player setting| | ||
@@ -104,2 +115,12 @@ Documentation for APlayer can be found at https://aplayer.js.org/#/home?id=options | ||
## Browser support | ||
Browsers without [native custom element support](https://caniuse.com/#feat=custom-elementsv1) require a [polyfill](https://github.com/webcomponents/custom-elements). | ||
- Chrome | ||
- Firefox | ||
- Safari | ||
- Internet Explorer 11 | ||
- Microsoft Edge | ||
## Author | ||
@@ -106,0 +127,0 @@ |
Sorry, the diff of this file is not supported yet
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
126
20%9911
-15.58%6
50%4
-42.86%13
-86.02%1
Infinity%