Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ A collection of HTMLMediaElement compatible elements and add-ons.
| [`<jwplayer-video>`](packages/jwplayer-video-element) | A custom video element for JW Player. |
| [`<twitch-video>`](packages/twitch-video-element) | A custom video element for Twitch player. |
| [`<cloudflare-video>`](packages/cloudflare-video-element) | A custom video element for Cloudflare Stream. |
| [`<peertube-video>`](packages/peertube-video-element) | A custom video element for PeerTube player. |
27 changes: 27 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file.
57 changes: 57 additions & 0 deletions packages/peertube-video-element/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# `<peertube-video>`

[![NPM Version](https://img.shields.io/npm/v/peertube-video-element?style=flat-square&color=informational)](https://www.npmjs.com/package/peertube-video-element)
[![NPM Downloads](https://img.shields.io/npm/dm/peertube-video-element?style=flat-square&color=informational&label=npm)](https://www.npmjs.com/package/peertube-video-element)
[![jsDelivr hits (npm)](https://img.shields.io/jsdelivr/npm/hm/peertube-video-element?style=flat-square&color=%23FF5627)](https://www.jsdelivr.com/package/npm/peertube-video-element)
[![npm bundle size](https://img.shields.io/bundlephobia/minzip/peertube-video-element?style=flat-square&color=success&label=gzip)](https://bundlephobia.com/result?p=peertube-video-element)

A [custom element](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements)
for the PeerTube player with an API that matches the
[`<video>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video) API.

- 🏄‍♂️ Compatible [`HTMLMediaElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement) API
- 🕺 Seamlessly integrates with [Media Chrome](https://github.com/muxinc/media-chrome)


<!-- prettier-ignore -->
```html
<script type="module" src="https://cdn.jsdelivr.net/npm/peertube-video-element@1.0/+esm"></script>
<peertube-video controls src="https://video.mshparisnord.fr/w/7r2FxoQdYjun6tYWJfHUCa"></peertube-video>
```

## Install

First install the NPM package:

```bash
npm install peertube-video-element
```

Import in your app javascript (e.g. src/App.js):

```js
import 'peertube-video-element';
```

Optionally, you can load the script directly from a CDN using [JSDelivr](https://www.jsdelivr.com/):

<!-- prettier-ignore -->
```html
<script type="module" src="https://cdn.jsdelivr.net/npm/peertube-video-element@1.0/+esm"></script>
```

This will register the custom elements with the browser so they can be used as HTML.

## Related

- [Media Chrome](https://github.com/muxinc/media-chrome) Your media player's dancing suit. 🕺
- [`<youtube-video>`](https://github.com/muxinc/media-elements/tree/main/packages/youtube-video-element) A custom element for the YouTube player.
- [`<spotify-audio>`](https://github.com/muxinc/media-elements/tree/main/packages/spotify-audio-element) A custom element for the Spotify player.
- [`<jwplayer-video>`](https://github.com/muxinc/media-elements/tree/main/packages/jwplayer-video-element) A custom element for the JW player.
- [`<videojs-video>`](https://github.com/muxinc/media-elements/tree/main/packages/videojs-video-element) A custom element for Video.js.
- [`<wistia-video>`](https://github.com/muxinc/media-elements/tree/main/packages/wistia-video-element) A custom element for the Wistia player.
- [`<cloudflare-video>`](https://github.com/muxinc/media-elements/tree/main/packages/cloudflare-video-element) A custom element for the Cloudflare player.
- [`<hls-video>`](https://github.com/muxinc/media-elements/tree/main/packages/hls-video-element) A custom element for playing HTTP Live Streaming (HLS) videos.
- [`castable-video`](https://github.com/muxinc/media-elements/tree/main/packages/castable-video) Cast your video element to the big screen with ease!
- [`<mux-player>`](https://github.com/muxinc/elements/tree/main/packages/mux-player) The official Mux-flavored video player custom element.
- [`<mux-video>`](https://github.com/muxinc/elements/tree/main/packages/mux-video) A Mux-flavored HTML5 video element w/ hls.js and Mux data builtin.
48 changes: 48 additions & 0 deletions packages/peertube-video-element/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!doctype html>
<html>
<head>
<title>&lt;twitch-video&gt;</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/water.css" />
<style>
body {
text-align: center;
}
media-controller,
twitch-video {
display: block;
width: 100%;
aspect-ratio: 16 / 9;
background: #000;
}
</style>
<script type="module" src="./peertube-video-element.js"></script>
<script type="module" src="https://cdn.jsdelivr.net/npm/media-chrome/+esm"></script>
</head>
<body>
<h1>&lt;twitch-video&gt;</h1>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CSS selector targets wrong element in demo page

Medium Severity

The index.html was copied from the Twitch element but not updated. The <title> (line 4), CSS selector (line 12), and <h1> (line 23) all reference twitch-video instead of peertube-video. Most critically, the CSS selector twitch-video means the <peertube-video> elements won't receive proper styling — no block display, no 100% width, no 16/9 aspect ratio, and no black background.

Additional Locations (1)

Fix in Cursor Fix in Web

<br />

<peertube-video id="t1" muted controls src="https://video.mshparisnord.fr/w/7r2FxoQdYjun6tYWJfHUCa"></peertube-video>

<br />

<br />

<h2>With <a href="https://github.com/muxinc/media-chrome" target="_blank">Media Chrome</a></h2>

<media-controller>
<peertube-video id="t2" src="https://video.mshparisnord.fr/w/7r2FxoQdYjun6tYWJfHUCa" slot="media"></peertube-video>
<media-control-bar>
<media-play-button></media-play-button>
<media-seek-backward-button seek-offset="15"></media-seek-backward-button>
<media-seek-forward-button seek-offset="15"></media-seek-forward-button>
<media-mute-button></media-mute-button>
<media-volume-range></media-volume-range>
<media-time-range></media-time-range>
<media-time-display show-duration remaining></media-time-display>
<media-fullscreen-button></media-fullscreen-button>
</media-control-bar>
</media-controller>
</body>
</html>
72 changes: 72 additions & 0 deletions packages/peertube-video-element/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"name": "peertube-video-element",
"version": "1.0.0",
"description": "A custom element for the PeerTube player with an API that matches the `<video>` API",
"author": "@muxinc",
"publishConfig": {
"access": "public"
},
"license": "MIT",
"homepage": "https://github.com/muxinc/media-elements#readme",
"bugs": {
"url": "https://github.com/muxinc/media-elements/issues"
},
"repository": {
"type": "git",
"url": "git+https://github.com/muxinc/media-elements.git",
"directory": "packages/peertube-video-element"
},
"files": [
"peertube-video-element.d.ts",
"dist"
],
"type": "module",
"types": "./dist/peertube-video-element.d.ts",
"main": "./dist/peertube-video-element.js",
"exports": {
".": {
"types": "./dist/peertube-video-element.d.ts",
"import": "./dist/peertube-video-element.js",
"require": "./dist/cjs/peertube-video-element.js",
"default": "./dist/peertube-video-element.js"
},
"./react": {
"types": "./dist/react.d.ts",
"import": "./dist/react.js",
"require": "./dist/cjs/react.js",
"default": "./dist/react.js"
}
},
"typesVersions": {
"*": {
"react": [
"./dist/react.d.ts"
],
"*": [
"./dist/peertube-video-element.d.ts"
]
}
},
"scripts": {
"lint": "eslint *.js",
"test": "wet run",
"serve": "wet serve --cors",
"build:react": "build-react-wrapper",
"build": "run-s build:*"
},
"dependencies": {
"media-played-ranges-mixin": "^0.1.0"
},
"devDependencies": {
"build-react-wrapper": "^0.2.4",
"npm-run-all": "^4.1.5",
"wet-run": "^1.2.5"
},
"keywords": [
"peertube",
"video",
"player",
"web component",
"custom element"
]
}
10 changes: 10 additions & 0 deletions packages/peertube-video-element/peertube-video-element.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export default class CustomVideoElement extends HTMLVideoElement {
static readonly observedAttributes: string[];
attributeChangedCallback(
attrName: string,
oldValue?: string | null,
newValue?: string | null
): void;
connectedCallback(): void;
disconnectedCallback(): void;
}
Loading