Skip to content

Commit

Permalink
chore: add example link
Browse files Browse the repository at this point in the history
  • Loading branch information
ForeverSc committed Jun 2, 2024
1 parent 52ed311 commit 0bb4cde
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ WebCodecs only provide the ability to decode, but not to demux. mp4box.js is coo
- 📦 One-time support for a variety of media formats, such as mov/mp4/mkv/webm/flv/m4v/wmv/avi, etc.
- 🧩 Support for customized packaging, you can adjust the configuration, packaged in a specified format demuxer

### Install
## Install
```bash
npm install web-demuxer
```

### Usage
## Usage
```typescript
import { WebDemuxer } from "web-demuxer"

Expand Down Expand Up @@ -49,7 +49,11 @@ async function seek(time) {
}
```

### API
## Examples
- [Seek Video Frame](https://foreversc.github.io/web-demuxer/#example-seek): [code](https://github.com/ForeverSc/web-demuxer/blob/main/index.html#L96)
- [Play Video](https://foreversc.github.io/web-demuxer/#example-play): [code](https://github.com/ForeverSc/web-demuxer/blob/main/index.html#L123)

## API
TODO

## License
Expand Down
5 changes: 3 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,11 @@ <h3>Play Video</h3>
</main>
<script type="module">
(async () => {
const { WebDemuxer } = import.meta.env.DEV ? await import('./src') : await import('https://cdn.jsdelivr.net/npm/web-demuxer@latest/dist/web-demuxer.js')
const isDev = import.meta.env && import.meta.env.DEV
const { WebDemuxer } = isDEV ? await import('./src') : await import('https://cdn.jsdelivr.net/npm/web-demuxer@latest/dist/web-demuxer.js')

const demuxer = new WebDemuxer({
wasmLoaderPath: !import.meta.env.DEV ? "http://localhost:5173/src/lib/ffmpeg.js" : "https://cdn.jsdelivr.net/npm/[email protected]/dist/wasm-files/ffmpeg.js",
wasmLoaderPath: isDEV ? "http://localhost:5173/src/lib/ffmpeg.js" : "https://cdn.jsdelivr.net/npm/[email protected]/dist/wasm-files/ffmpeg.js",
})

document.getElementById('example-seek-btn').addEventListener('click', async (e) => {
Expand Down

0 comments on commit 0bb4cde

Please sign in to comment.