{"id":13527559,"url":"https://github.com/video-dev/can-autoplay","last_synced_at":"2025-06-26T16:37:43.329Z","repository":{"id":26918581,"uuid":"110994253","full_name":"video-dev/can-autoplay","owner":"video-dev","description":"The auto-play feature detection in HTMLMediaElement (\u003caudio\u003e or \u003cvideo\u003e).","archived":false,"fork":false,"pushed_at":"2023-04-19T12:49:12.000Z","size":330,"stargazers_count":302,"open_issues_count":13,"forks_count":33,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-06-05T06:54:15.460Z","etag":null,"topics":["autoplay","detection","htmlmediaelement"],"latest_commit_sha":null,"homepage":"https://video-dev.github.io/can-autoplay/","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/video-dev.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2017-11-16T16:19:12.000Z","updated_at":"2025-06-05T02:55:42.000Z","dependencies_parsed_at":"2024-01-13T21:42:58.642Z","dependency_job_id":"6b802297-4af6-495d-9b1f-7e22b8009769","html_url":"https://github.com/video-dev/can-autoplay","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/video-dev/can-autoplay","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/video-dev%2Fcan-autoplay","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/video-dev%2Fcan-autoplay/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/video-dev%2Fcan-autoplay/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/video-dev%2Fcan-autoplay/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/video-dev","download_url":"https://codeload.github.com/video-dev/can-autoplay/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/video-dev%2Fcan-autoplay/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262103318,"owners_count":23259433,"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":["autoplay","detection","htmlmediaelement"],"created_at":"2024-08-01T06:01:51.395Z","updated_at":"2025-06-26T16:37:43.306Z","avatar_url":"https://github.com/video-dev.png","language":"JavaScript","readme":"# can-autoplay.js\n\nThe auto-play feature detection in HTMLMediaElement (`\u003caudio\u003e` or `\u003cvideo\u003e`).\n\n![FileSize](http://img.badgesize.io/video-dev/can-autoplay/master/build/can-autoplay.min.js#1?compression=gzip)\n![Version](https://img.shields.io/npm/v/can-autoplay.svg)\n\n[Demo page](https://video-dev.github.io/can-autoplay/)\n\nTable of contents:\n\n\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n\n\n- [Installation](#installation)\n- [Files](#files)\n- [API](#api)\n  - [`audio(options)`](#audiooptions)\n  - [`video(options)`](#videooptions)\n- [Example](#example)\n- [Media](#media)\n- [Implementation Details](#implementation-details)\n\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n\n## Installation\n\n```\nnpm install can-autoplay\n```\n\n## Files\n\nBuild files are available in the `build/` directory. Bundlers will choose get the correct file chosen for them but if you just want to include it on the page, grab the `build/can-autoplay.js` file.\n\n## API\n\n### `audio(options)`\n\nParameters:\n\n- options.inline `\u003cBoolean\u003e`, check if auto-play is possible for an inline playback, default value is `false`\n- options.muted `\u003cBoolean\u003e`, check if auto-play is possible for a muted content\n- options.timeout `\u003cNumber\u003e`, timeout for a check, default value is `250` ms\n\nReturns:\n\n- `\u003cPromise\u003e`, resolves to a `\u003cObject\u003e`:\n  - `result \u003cBoolean\u003e`, `true` - if auto-play is possible\n  - `error \u003cError\u003e`, internal or timeout Error object\n\n\n```js\ncanAutoplay.audio().then(({result}) =\u003e {\n  if (result === true) {\n    // Can auto-play\n  } else {\n    // Can not auto-play\n  }\n})\n```\n\n### `video(options)`\n\nParameters:\n\n- options.inline `\u003cBoolean\u003e`, check if auto-play is possible for an inline playback, default value is `false`\n- options.muted `\u003cBoolean\u003e`, check if auto-play is possible for a muted content\n- options.timeout `\u003cNumber\u003e`, timeout for a check, default value is `250` ms\n\nReturns:\n\n- `\u003cPromise\u003e`, resoles to a `\u003cObject\u003e`:\n  - `result \u003cBoolean\u003e`, `true` - if auto-play is possible\n  - `error \u003cError\u003e`, internal or timeout Error object\n\n```js\ncanAutoplay.video().then(({result}) =\u003e {\n  if (result === true) {\n    // Can autoplay\n  } else {\n    // Can not autoplay\n  }\n})\n```\n\n## Example\n\n```js\nimport canAutoPlay from 'can-autoplay';\n\ncanAutoPlay\n    .video({timeout: 100, muted: true})\n    .then(({result, error}) =\u003e {\n        if(result === false){\n            console.warn('Error did occur: ', error)\n        }\n    })\n```\n\n## Media\n\n- `audio.mp3`. Created by Weston Ruter (@westonruter). Smallest possible (\u003c0.000001 seconds long) audio file.\n- `video.mp4`. Source: https://github.com/mathiasbynens/small\n\n## Implementation Details\n\nIf it's required to have a legacy browser support you could use latest `v2.x.x` version of the library.\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvideo-dev%2Fcan-autoplay","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvideo-dev%2Fcan-autoplay","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvideo-dev%2Fcan-autoplay/lists"}