{"id":26721235,"url":"https://github.com/tj-mc/mediakit","last_synced_at":"2025-10-14T19:38:02.751Z","repository":{"id":57293957,"uuid":"277231725","full_name":"tj-mc/mediakit","owner":"tj-mc","description":"A powerful and simple interface for controlling media on web pages.","archived":false,"fork":false,"pushed_at":"2020-09-06T08:25:12.000Z","size":899,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-07T02:05:54.930Z","etag":null,"topics":["audio","control","developer-tools","iframes","javascript","js","media","mediakit","players","video","vimeo","web","youtube-iframe"],"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/tj-mc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-05T04:36:53.000Z","updated_at":"2021-05-03T21:19:03.000Z","dependencies_parsed_at":"2022-08-29T08:01:33.711Z","dependency_job_id":null,"html_url":"https://github.com/tj-mc/mediakit","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/tj-mc/mediakit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tj-mc%2Fmediakit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tj-mc%2Fmediakit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tj-mc%2Fmediakit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tj-mc%2Fmediakit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tj-mc","download_url":"https://codeload.github.com/tj-mc/mediakit/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tj-mc%2Fmediakit/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266769764,"owners_count":23981432,"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","status":"online","status_checked_at":"2025-07-23T02:00:09.312Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"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":["audio","control","developer-tools","iframes","javascript","js","media","mediakit","players","video","vimeo","web","youtube-iframe"],"created_at":"2025-03-27T19:37:34.494Z","updated_at":"2025-10-14T19:37:57.729Z","avatar_url":"https://github.com/tj-mc.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![npm version](https://img.shields.io/npm/v/mediakitjs?style=flat-square)  ![size](https://badgen.net/bundlephobia/minzip/mediakitjs?style=flat-square) ![licence](https://img.shields.io/npm/l/mediakitjs?style=flat-square)\n![mediakit](img/mediakitLogo.png)\nStop media elements from playing all at once. Control them with a set of universal functions.\n[Try it out.](https://tj-mc.github.io/mediakit/)\n\n#### 💭 Problem\nMany websites require embedded audio and video, either through HTML5 players or third party iFrames. However, managing these players can be difficult. Many audio players and iFrames can play at once, and each type of media has a different API, leading to an unpleasent experience for the user and developer.\n\n#### ✨ Solution\nmediakit aims to provide a simple interface for controlling all the media item on your page. Simply register the name and type of each item, and you'll have access to a universal control centre for your media. \n__By default, mediakit ensures that only one item can play at a time.__\n### 💾 Installation\n#### 📦 Packager\nInstall with package manager:\n```\nnpm i mediakitjs\n```\nThen import as needed.\n```$xslt\nimport { create, play, pauseAll } from 'mediakitjs';\n```\n\n\n#### 🌐 CDN\n\nLoad from CDN: \n```$xslt\n\u003cscript type=\"module\" src=\"https://cdn.jsdelivr.net/npm/mediakitjs@1.2.2/dist/mediakit.min.js\u003c/script\u003e\n```\nThen grab `mediakit` from `window`.\n```\nconst mk = window.mediakit;\n```\n\n### 🚀 Usage\nYou need to give mediakit an object containing a [query selector](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector), type and name for each media item.\n`type` and `selector` are required. If no name is supplied, the selector string becomes the name (including `#`'s and `.`'s).\n\n```$xslt\n\n\u003caudio id=\"audio1\" src=\"resources/music.m4a\" controls\u003e\u003c/audio\u003e\n\u003cvideo id=\"video1\" src=\"resources/video.mp4\" controls\u003e\u003c/video\u003e\n\u003ciframe id=\"vimeo1\" src=\"{vimeo url}\" width=\"640\" height=\"360\"\u003e\u003c/iframe\u003e\n\nmk.create([\n    { type: 'audio', selector: '#audio1' },\n    { type: 'video', selector: '#video1' },\n    { type: 'vimeo', selector: '#vimeo1' },\n])\n```\n\n### 📺 YouTube Usage\nFor Vimeo, Video, and Audio, mediakit receives a reference to the existing iFrame or media element on the page.\nTo include a YouTube video, you must pass a selector to an empty `div` or `span` that you want to be replaced with the YouTube iFrame.\nThis is due to the design of the YouTube iFrame API, which requires us to register the iFrame on creation. Provide the videoId in the `config` property.\n```\n\u003cdiv id=\"#youtube1\"\u003e\u003c/div\u003e\n\n...\n\nmk.create([\n    { type: 'youtube', selector: '#youtube1', config: { videoId: '4eM12LJi_rg' } },\n])\n```\n\n### 📖 Methods\n\n#### `play(name: string)`\nPlay an element. If `config.playExclusive === true`, this method will pause all registered elements before playing the \ntarget element.\n\n#### `pause(name: string)`\nPause an element. \n\n#### `stop(name: string)`\nStop an element. Currently identical to `pause()`. In future versions, this method will pause the target element, then\nset its playback time to `0:00`. \n\n#### `pauseAllExcept(name: string)`\nPause all elements, except one. \n\n#### `pauseAll(name: string)`\nPause all elements.\n\n### ⚙️ Configuration\n`create()` accepts a second argument for configuration. The example below shows the default values of these properties.\n```$xslt\nmk.create(\n    [\n        {type: 'audio', selector: '#audio1'},\n        {type: 'video', selector: '#video2'},\n        {type: 'vimeo', selector: '#vimeo2'},\n        {type: 'youtube', selector: '#youtube1', config: {videoId: '4eM12LJi_rg'}},\n    ],\n    {\n        playExclusive: true,\n        log: false,\n    }\n)\n```\n#### Supported \n- ✅ HTML5 Audio\n- ✅ HTML5 Video\n- ✅ YouTube\n- ✅ Vimeo \n\n\n### 🛣️ Roadmap\n- Add support for `seek()`\n- Implement `stop()`. Current version mirrors `pause()`\n- Emit mediakit events. eg: `mkPaused`, `mkPlayed` \n- Add tests\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftj-mc%2Fmediakit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftj-mc%2Fmediakit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftj-mc%2Fmediakit/lists"}