# lib-media-session

> a JavaScript Library To Show Cover

Latest version **1.0.0** (published 2018-05-15) · ISC license · 0 weekly downloads

## Install

```sh
npm install lib-media-session
pnpm add lib-media-session
yarn add lib-media-session
bun add lib-media-session
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2018-05-15 |
| First published | 2018-05-15 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 50.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | jack_pu |

## Links

- npm: https://www.npmjs.com/package/lib-media-session
- Repository: https://github.com/JackPu/lib-media-session
- Homepage: https://github.com/JackPu/lib-media-session#readme
- Issues: https://github.com/JackPu/lib-media-session/issues
- npm.io page: https://npm.io/package/lib-media-session

## Dependencies (1)

- [daycaca](https://npm.io/package/daycaca.md) ^1.0.2

## Recent versions

- 1.0.0 (latest) — 2018-05-15

## README

# lib-meida-session

A JavaScript Library To Show Cover

## Get started

### Npm

``` bash
$npm install lib-media-session --save
```

### CDN

``` html
<script src="./dist/lib-media-session.min.js"></script>
```

``` js
mediaSession.setCover({
    title: 'music', // 指定名称
    artwork: '....jpg' // 指定封面
})

```

## API

### init(options)

 `options` 可以传入的字段;

 + setTitle 是否设置页面标题 (document.title)
 + play/pause/seekbackward/seekforward 事件

### setCover(args)

args 必须为一个 Object

<table width="100%">
    <tr>
        <th>key</th>
        <th>描述</th>
        <th>类似</th>
    </tr>
    <tr>
        <td>title</td>
        <td>歌曲名称</td>
        <td>String</td>
    </tr>
    <tr>
        <td>artist</td>
        <td>作者</td>
        <td>String</td>
    </tr>
    <tr>
        <td>albums</td>
        <td>专辑</td>
        <td>String</td>
    </tr>
    <tr>
        <td>artwork</td>
        <td>封面</td>
        <td>String/Array/Object</td>
    </tr>
</table>

其中封面可以是一个字符串:

``` bash
http://img1.vued.vanthink.cn/vued0217b02c7c42b10f5e533b75bdef80de.jpeg
```

或者一个对象:

``` bash
{
    src: 'http://img1.vued.vanthink.cn/vued0217b02c7c42b10f5e533b75bdef80de.jpeg',
    type: 'image/jpeg',
    size: '168x168'
}
```

或者如上面代码所示的完整的 size 列表。

``` bash
[
    { src: 'https://dummyimage.com/96x96',   sizes: '96x96',   type: 'image/png' },
    { src: 'https://dummyimage.com/128x128', sizes: '128x128', type: 'image/png' },
    { src: 'https://dummyimage.com/192x192', sizes: '192x192', type: 'image/png' },
    { src: 'https://dummyimage.com/256x256', sizes: '256x256', type: 'image/png' },
    { src: 'https://dummyimage.com/384x384', sizes: '384x384', type: 'image/png' },
    { src: 'https://dummyimage.com/512x512', sizes: '512x512', type: 'image/png' },
]

```


## MIT License

---
_Source: https://npm.io/package/lib-media-session · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
