{"id":14979651,"url":"https://github.com/markcellus/youtube-video-js","last_synced_at":"2026-03-27T02:45:59.889Z","repository":{"id":25118337,"uuid":"28539942","full_name":"markcellus/youtube-video-js","owner":"markcellus","description":"A light-weight web component for YouTube videos","archived":false,"fork":false,"pushed_at":"2024-07-20T08:22:03.000Z","size":3063,"stargazers_count":45,"open_issues_count":19,"forks_count":17,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-02-27T05:35:29.434Z","etag":null,"topics":["es6","javascript","js","multiple-videos","video","video-element","video-events","webcomponent","youtube-api","youtube-player","youtube-video"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/markcellus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-12-27T15:36:29.000Z","updated_at":"2025-10-10T11:56:07.000Z","dependencies_parsed_at":"2024-06-18T19:52:55.636Z","dependency_job_id":"15957ebb-c317-4894-a145-115163c692cc","html_url":"https://github.com/markcellus/youtube-video-js","commit_stats":{"total_commits":562,"total_committers":10,"mean_commits":56.2,"dds":0.599644128113879,"last_synced_commit":"77a49b1edbac899054e35bd7442463a473802f97"},"previous_names":["mkay581/video","mkay581/video-player.js","mkay581/videoplayer","mkay581/youtube-video-js"],"tags_count":64,"template":false,"template_full_name":null,"purl":"pkg:github/markcellus/youtube-video-js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markcellus%2Fyoutube-video-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markcellus%2Fyoutube-video-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markcellus%2Fyoutube-video-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markcellus%2Fyoutube-video-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/markcellus","download_url":"https://codeload.github.com/markcellus/youtube-video-js/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markcellus%2Fyoutube-video-js/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30572302,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-16T06:02:37.763Z","status":"ssl_error","status_checked_at":"2026-03-16T06:02:14.913Z","response_time":96,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["es6","javascript","js","multiple-videos","video","video-element","video-events","webcomponent","youtube-api","youtube-player","youtube-video"],"created_at":"2024-09-24T14:00:26.864Z","updated_at":"2026-03-16T07:32:20.643Z","avatar_url":"https://github.com/markcellus.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/markcellus/youtube-video-js.svg?branch=master)](https://travis-ci.org/markcellus/youtube-video-js)\n[![npm version](https://badge.fury.io/js/youtube-video-js.svg)](https://badge.fury.io/js/youtube-video-js)\n\n# YouTube Video\n\nA `\u003cyoutube-video\u003e` web component that allows you to easily play and control YouTube videos, powered by the\n[YouTube IFrame Player API](https://developers.google.com/youtube/iframe_api_reference). In addition to simple\nrendering, videos can be played, stopped, paused, and more all with simple, native javascript.\n\nThis library aims to mimick the methods and properties of HTML5's\n[`\u003cvideo\u003e`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video) tag to offer a simple, standardized API\nthat is easy to use and adheres to the latest video tag specifications and supports all major\n[media events](https://html.spec.whatwg.org/multipage/media.html#mediaevents).\n\n## Installation\n\n```\nnpm i youtube-video-js\n```\n\nThen you can use reference before running your build script\n\n```javascript\nimport 'youtube-video-js';\n```\n\nOr you can load it using the `\u003cscript\u003e` tag in your html page\n\n```html\n\u003cscript\n    type=\"module\"\n    src=\"/node_modules/youtube-video-js/dist/youtube-video.js\"\n\u003e\u003c/script\u003e\n```\n\n## Usage\n\nTo render a YouTube video, just declare the component in your HTML. Once created (instantiated), the instance\ncan be accessed by JavaScript and will have the [same methods that are available on the\nHTMLMediaElement](https://html.spec.whatwg.org/multipage/media.html#htmlmediaelement).\n\n**Note: You MUST be requesting a YouTube video from a website that must be either a valid domain or localhost\n(NOT an IP address) or video wont work! YouTube's requirement, not mine** :)\n\n```html\n\u003c!-- index.html --\u003e\n\u003cscript\n    type=\"module\"\n    src=\"/node_modules/youtube-video-js/dist/youtube-video.js\"\n\u003e\u003c/script\u003e\n\u003cyoutube-video\n    width=\"640\"\n    height=\"360\"\n    src=\"https://www.youtube.com/watch?v=Wn9twYUXw6w\"\n    autoplay\n    controls\n/\u003e\n\n\u003cscript\u003e\n    const videoElement = document.querySelector('youtube-video');\n    // must wait for DOM to be ready and for component to be accessible\n    document.addEventListener('DOMContentLoaded', function () {\n        // wait for loading\n        videoElement.load().then(() =\u003e {\n            // pause video after two seconds\n            const timer = setTimeout(function () {\n                videoElement.pause();\n                clearTimeout(timer);\n            }, 2000);\n        });\n    });\n\u003c/script\u003e\n```\n\n### Listen to the video's events\n\nYou can also subscribe to [MediaEvents](https://www.w3.org/TR/2011/WD-html5-20110113/video.html#mediaevents) just as\nyou would with a native `\u003cvideo\u003e` element.\n\n```javascript\nconst video = document.querySelector('youtube-video');\n\nvideo.addEventListener('playing', function () {\n    // video has started playing!\n});\n\nvideo.addEventListener('pause', function () {\n    // video has been paused!\n});\n\nvideo.addEventListener('ended', function () {\n    // video has ended!\n});\n\nvideo.addEventListener('loadstart', function () {\n    // play video\n    video.play();\n    // pause video after four seconds\n    const timer = setTimeout(function () {\n        video.pause();\n        clearTimeout(timer);\n    }, 4000);\n});\n```\n\n### Multiple Videos\n\nWhen dealing with multiple videos that use this library (multiple videos on a single web page for instance),\nall other already-playing videos will automatically pause if a video is played. This ensures that no two YouTube videos\nwill ever be playing at the exact same time, ensuring the best possible experience for your users.\n\n```javascript\nconst [firstVideoElement, secondVideoElement] = document.querySelectorAll('youtube-video');\n\nfirstVideoElement.addEventListener('pause', function () {\n    // video has been paused because video2 started playing!\n});\n\n// load both videos\nPromise.all([firstVideoElement.load(), secondVideoElement.load()]\n    .then(() =\u003e firstVideoElement.play())\n    .then(() =\u003e {\n       // play video2 to trigger pausing of video1\n       secondVideoElement.play();\n    });\n\n```\n\n## Extending\n\nYou can also extend the youtube video element to create your own custom versions:\n\n```javascript\nimport { YoutubeVideoElement } from 'youtube-video-js/dist/youtube-video-element.js';\nclass CustomYoutubeElement extends YoutubeVideoElement {\n    // your custom code here\n}\ncustomElements.define('custom-youtube-element', CustomYoutubeElement);\n```\n\n## Examples\n\nCode samples can be found in the [examples](examples) folder. To run them, pull down this project\nand\n\n```bash\nnpm start\n```\n\n## Development\n\nRun tests:\n\n```\nnpm install\nnpm test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkcellus%2Fyoutube-video-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarkcellus%2Fyoutube-video-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkcellus%2Fyoutube-video-js/lists"}