-
Notifications
You must be signed in to change notification settings - Fork 45
New PeerTube Video Element Integration PR #214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
younes200
wants to merge
3
commits into
muxinc:main
Choose a base branch
from
celluloid-camp:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| # `<peertube-video>` | ||
|
|
||
| [](https://www.npmjs.com/package/peertube-video-element) | ||
| [](https://www.npmjs.com/package/peertube-video-element) | ||
| [](https://www.jsdelivr.com/package/npm/peertube-video-element) | ||
| [](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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| <!doctype html> | ||
| <html> | ||
| <head> | ||
| <title><twitch-video></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><twitch-video></h1> | ||
| <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> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
10
packages/peertube-video-element/peertube-video-element.d.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.htmlwas copied from the Twitch element but not updated. The<title>(line 4), CSS selector (line 12), and<h1>(line 23) all referencetwitch-videoinstead ofpeertube-video. Most critically, the CSS selectortwitch-videomeans 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)
packages/peertube-video-element/index.html#L11-L12