{"id":16557543,"url":"https://github.com/nk-o/video-worker","last_synced_at":"2025-03-16T20:30:29.611Z","repository":{"id":30551883,"uuid":"125279249","full_name":"nk-o/video-worker","owner":"nk-o","description":"API wrapper for Youtube, Vimeo and Self-Hosted videos","archived":false,"fork":false,"pushed_at":"2024-01-27T19:36:07.000Z","size":1371,"stargazers_count":22,"open_issues_count":0,"forks_count":8,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-11T15:51:53.579Z","etag":null,"topics":["api","javascript","mp4","video","vimeo","webm","youtube"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/nk-o.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"custom":"https://www.buymeacoffee.com/nkdev"}},"created_at":"2018-03-14T22:04:48.000Z","updated_at":"2024-06-15T20:09:44.000Z","dependencies_parsed_at":"2024-06-18T15:44:08.664Z","dependency_job_id":null,"html_url":"https://github.com/nk-o/video-worker","commit_stats":null,"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nk-o%2Fvideo-worker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nk-o%2Fvideo-worker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nk-o%2Fvideo-worker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nk-o%2Fvideo-worker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nk-o","download_url":"https://codeload.github.com/nk-o/video-worker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243826798,"owners_count":20354221,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["api","javascript","mp4","video","vimeo","webm","youtube"],"created_at":"2024-10-11T20:07:46.292Z","updated_at":"2025-03-16T20:30:29.297Z","avatar_url":"https://github.com/nk-o.png","language":"JavaScript","funding_links":["https://www.buymeacoffee.com/nkdev"],"categories":[],"sub_categories":[],"readme":"# Video Worker \u003c!-- omit in toc --\u003e\n\n![video-worker.min.js](https://img.badgesize.io/nk-o/video-worker/master/dist/video-worker.min.js?compression=gzip)\n\nAPI wrapper for Youtube, Vimeo and Self-Hosted videos\n\n## Table of Contents \u003c!-- omit in toc --\u003e\n\n- [Import VideoWorker](#import-videoworker)\n  - [ESM](#esm)\n  - [ESM CDN](#esm-cdn)\n  - [UMD](#umd)\n  - [UMD CDN](#umd-cdn)\n  - [CJS (Bundlers like Webpack)](#cjs-bundlers-like-webpack)\n- [Use VideoWorker](#use-videoworker)\n- [Options](#options)\n- [Events](#events)\n- [Methods](#methods)\n- [Video Providers](#video-providers)\n- [For Developers](#for-developers)\n\n## Import VideoWorker\n\nUse one of the following examples to import script.\n\n### ESM\n\nWe provide a version of VideoWorker built as ESM (video-worker.esm.js and video-worker.esm.min.js) which allows you to use VideoWorker as a module in your browser, if your [targeted browsers support it](https://caniuse.com/es6-module).\n\n```html\n\u003cscript type=\"module\"\u003e\n  import VideoWorker from \"video-worker.esm.min.js\";\n\u003c/script\u003e\n```\n\n### ESM CDN\n\n```html\n\u003cscript type=\"module\"\u003e\n  import VideoWorker from \"https://cdn.jsdelivr.net/npm/video-worker@2/+esm\";\n\u003c/script\u003e\n```\n\n### UMD\n\nVideoWorker may be also used in a traditional way by including script in HTML and using library by accessing `window.VideoWorker`.\n\n```html\n\u003cscript src=\"video-worker.min.js\"\u003e\u003c/script\u003e\n```\n\n\n### UMD CDN\n\n```html\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/video-worker@2/dist/video-worker.min.js\"\u003e\u003c/script\u003e\n```\n\n### CJS (Bundlers like Webpack)\n\nInstall VideoWorker as a Node.js module using npm\n\n```\nnpm install video-worker\n```\n\nImport VideoWorker by adding this line to your app's entry point (usually `index.js` or `app.js`):\n\n```javascript\nimport VideoWorker from 'video-worker';\n```\n\n## Use VideoWorker\n\n```javascript\nimport VideoWorker from 'video-worker';\n\nconst videoObject = new VideoWorker('https://www.youtube.com/watch?v=ab0TSkLe-E0');\n\nif (videoObject.isValid()) {\n  // retrieve iframe/video dom element.\n  videoObject.getVideo((video) =\u003e {\n    const $parent = video.parentNode;\n\n    // insert video in the body.\n    document.body.appendChild(video);\n\n    // remove temporary parent video element (created by VideoWorker).\n    $parent.parentNode.removeChild($parent);\n  });\n}\n```\n\nVideo URLs examples:\n\n* YouTube `https://www.youtube.com/watch?v=ab0TSkLe-E0`\n* Vimeo `https://vimeo.com/110138539`\n* Self Hosted `mp4:./self-hosted-video.mp4,webm:./self-hosted-video.webm,ogv:./self-hosted-video.ogv`\n\nNote: for self-hosted videos required only 1 video type, not necessary use all mp4, webm and ogv. This need only for maximum compatibility with all browsers.\n\n## Options\n\nName | Type | Default | Description\n:--- | :--- | :------ | :----------\nautoplay | bool | `false` | Video autoplay.\nloop | bool | `false` | Video playing loop.\nshowControls | bool | `true` | Video controls.\naccessibilityHidden | bool | `false` | Add accessibility attributes for videos used on backgrounds.\nmute | bool | `false` | Mute sound.\nvolume | int | `100` | Volume level from 0 to 100.\nstartTime | float | `0` | Start time in seconds when video will be started (this value will be applied also after loop).\nendTime | float | `0` | End time in seconds when video will be ended.\n\n### Example \u003c!-- omit in toc --\u003e\n\n```javascript\nnew VideoWorker('\u003cURL_TO_YOUR_VIDEO\u003e', {\n  autoplay: true,\n  loop: true,\n  startTime: 10,\n});\n```\n\n## Events\n\nName | Parameters | Description\n:--- | :----- | :----------\nready | `event` | Fires only once, when the video is ready to play.\nvolumechange | `event` | Fires when video volume changed.\ntimeupdate | `event` | Fires when video current time changed.\nstarted | `event` | Fires only once, when the video is started playing.\nplay | `event` | Fires on video play start.\npause | `event` | Fires on video paused.\nended | `event` | Fires on video ended.\nerror | `error` | Fires on video error\n\n### Example \u003c!-- omit in toc --\u003e\n\n```javascript\nvideoObject.on('ready', (event) =\u003e {\n  console.log('video ready', event);\n});\n```\n\n## Methods\n\nName | Result | Description\n:--- | :----- | :----------\nisValid | bool | Check if the video is successfully determined and ready to use.\nplay | - | Play video.\npause | - | Pause video.\nmute | - | Mute sound.\nunmute | - | Unmute sound.\ngetMuted | int | Get mute state. `videoObject.getMuted((muted) =\u003e { ... })`\nsetVolume | - | Set volume level (takes integer value from 0 to 100). `videoObject.setVolume(40);`\ngetVolume | int | Get volume level. `videoObject.getVolume((volume) =\u003e { ... })`\nsetCurrentTime | - | Set current time in seconds. `videoObject.setCurrentTime(40);`\ngetCurrentTime | int | Get current time in seconds. `videoObject.getCurrentTime((currentTime) =\u003e { ... })`\ngetImageURL | string | Retrieves Youtube/Vimeo video poster image URL. `videoObject.getImageURL((url) =\u003e { ... })`\ngetVideo | dom | Retrieves iframe/video dom element. `videoObject.getVideo((video) =\u003e { ... })`\n\n### Example \u003c!-- omit in toc --\u003e\n\n```javascript\nvideoObject.mute();\n```\n\n## Video Providers\n\nBy default VideoWorker provides support for Youtube, Vimeo and Self-Hosted videos. There is a possibility to extend providers list and add support for different platform.\n\nExample:\n\n```javascript\nVideoWorker.providers.MyVideoProvider = class MyVideoProvider extends VideoWorker.BaseClass {\n  type = 'my-video-provider';\n  ...\n}\n```\n\nAll available methods for custom provider class you can find in existing providers - \u003chttps://github.com/nk-o/video-worker/tree/master/src/providers\u003e\n\n## For Developers\n\n### Installation \u003c!-- omit in toc --\u003e\n\n* Run `npm install` in the command line. Or if you need to update some dependencies, run `npm update`\n\n### Building \u003c!-- omit in toc --\u003e\n\n* `npm run build` to run build\n\n### Linting \u003c!-- omit in toc --\u003e\n\n* `npm run js-lint` to show eslint errors\n* `npm run js-lint-fix` to automatically fix some of the eslint errors\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnk-o%2Fvideo-worker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnk-o%2Fvideo-worker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnk-o%2Fvideo-worker/lists"}