An open API service indexing awesome lists of open source software.

https://github.com/dimensiondev/media-viewer

Media Viewer
https://github.com/dimensiondev/media-viewer

Last synced: 7 months ago
JSON representation

Media Viewer

Awesome Lists containing this project

README

          

# Media Viewer

## Usage

### HTML

```html

```

### JavaScript

```typescript
const frame = document.createElement('iframe')

frame.addEventListener('load', () => {
frame.contentWindow.postMessage({
type: '[media_type]', // optional
url: '[media_link]',
controls: true, // optional, allow user-control audio/video
})
})
frame.src = 'https://media-viewer.r2d2.to/index.html'
document.body.appendChild(frame)
```

## Examples

| Media Type | Example |
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `image/svg` | |
| `modle/gltf+binary` | |
| `image/jpeg` | |
| `video/mp4` | |
| `audio/mp3` | |

## NFT JSON Schema

| Schema | Example |
| ------------------ | ------------------------------------------------------------------------------------------- |
| ERC721 JSON Schema | |

## Parameters

| Name | Type | Description |
| ------------- | ----------- | -----------------------------------------------------------------------------------------------------------------------
| `url` | string | Resource url, or tokenURI if `source === 'erc721'`. |
| `type` | string | Predefined content type of the resource to determine which html element to render, if it is absent *Media-Viewer* will get the content type from response header through an extra query, so recommand add one if you know what type of resource is in advance. |
| `source` | 'erc721' | if `source === 'erc721'`, *Media-Viewer* will treat `url` as a tokenURI. |
| `controls` | boolean | html5 video option. |
| `autoPlay` | boolean | html5 video option. |
| `playsInline` | boolean | html5 video option. |
| `loop` | boolean | html5 video option. |
| `muted` | boolean | html5 video option. |
| `erc721Token` | ERC721Token | if `url` is provided, *Media-Viewer* will ignore this parameter, otherwise it will fetch the NFT resource by the `tokenId` and `address` of `erc721Token` through its `rpc`. |

```typescript
interface ERC721Token {
contractAddress: string
tokenId: string
rpc: string // the rpc url to send request to the relative chain.
}
```

## LICENSE

[MIT](LICENSE)