{"id":18377175,"url":"https://github.com/bbc/media-sequence","last_synced_at":"2025-04-06T20:32:19.025Z","repository":{"id":57293938,"uuid":"20927859","full_name":"bbc/media-sequence","owner":"bbc","description":"HTML5 media sequenced playback API: play one or multiple sequences of a same audio or video with plain JavaScript.","archived":false,"fork":false,"pushed_at":"2024-11-27T15:12:42.000Z","size":819,"stargazers_count":23,"open_issues_count":1,"forks_count":2,"subscribers_count":24,"default_branch":"master","last_synced_at":"2025-03-22T06:51:17.960Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://npmjs.org/package/media-sequence","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bbc.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}},"created_at":"2014-06-17T14:59:43.000Z","updated_at":"2025-03-04T10:53:47.000Z","dependencies_parsed_at":"2022-08-31T09:21:50.608Z","dependency_job_id":null,"html_url":"https://github.com/bbc/media-sequence","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbc%2Fmedia-sequence","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbc%2Fmedia-sequence/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbc%2Fmedia-sequence/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbc%2Fmedia-sequence/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bbc","download_url":"https://codeload.github.com/bbc/media-sequence/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247548145,"owners_count":20956673,"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":[],"created_at":"2024-11-06T00:26:56.672Z","updated_at":"2025-04-06T20:32:18.636Z","avatar_url":"https://github.com/bbc.png","language":"JavaScript","readme":"# media-sequence\n\n\u003e HTML5 media sequenced playback API: play one or multiple sequences of a same audio or video with plain JavaScript.\n\n![](demo.gif?raw=1)\n\n# Installation\n\n\u003ctable\u003e\n  \u003cthead\u003e\n    \u003ctr\u003e\n      \u003cth\u003e\u003ca href=\"https://npmjs.org/\"\u003enpm\u003c/a\u003e\u003c/th\u003e\n      \u003cth\u003e\u003ca href=\"https://github.com/bower/bower\"\u003ebower\u003c/a\u003e\u003c/th\u003e\n      \u003cth\u003eold school\u003c/th\u003e\n    \u003c/tr\u003e\n  \u003c/thead\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e\u003ccode\u003enpm install --save media-sequence\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003ebower install --save media-sequence\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ca href=\"https://github.com/oncletom/media-sequence/archive/master.zip\"\u003edownload zip file\u003c/a\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\n# Usage\n\n```js\nvar sequences = [{start: 0, end: 5}, {start: 12, end: 13}, {start: 21, end: 31}];\nvar sequencer = new MediaSequence(new Audio('path/to/audio.ogg'), sequences);\n\nsequencer.playAll();\n```\n\n# API\n\n## `new MediaSequence(el, sequences)`\n\n## `sequencer.add(sequences)`\n\nAdds new sequences to the actual stack.\n\n```js\nvar sequencer = new MediaSequence(new Audio('path/to/audio.ogg'));\n\nsequencer.add([{ start: 0, end: 10 }, { start: 3, end: 6}]);\nsequencer.add([{ start: 11, end: 12 }]);\n```\n\n## `sequencer.playAll()`\n\nStarts the playback of all the sequences in a row.\n\n## `sequencer.playFrom(start, end)`\n\nStarts the playback from a `start` time and stops automatically at an `end` time.\n\n```js\nvar sequencer = new MediaSequence(new Audio('path/to/audio.ogg'));\n\nsequencer.playFrom(10, 12); // will play from 10 seconds to 12 seconds\n```\n\n## `sequencer.playNext()`\n\nPlays the next consecutive sequence based on the current playback time.\n\n```js\nvar el = new Audio('path/to/audio.ogg');\nvar sequencer = new MediaSequence(el, sequences);\n\nel.currentTime = 12;\nsequencer.playNext(); // will play the next sequence starting after 12 seconds\n```\n\n## `sequencer.getNext(referenceTime, options)`\n\nReturns the next sequence from a `referenceTime` numbered value.\n\n```js\nvar ms = new MediaSequencer(…, [{ start: 3, end: 5 }, { start: 12, end: 13 }]);\n\nms.getNext(0);\n// { start: 3, end: 5 }\n\nms.getNext(3);\n// { start: 12, end: 13 }\n```\n\nIf the `options.overlap` value is set to `true`, the returned sequence is allowed to overlap:\n\n```js\nvar ms = new MediaSequencer(…, [{ start: 3, end: 5 }, {start: 3, end: 10 }, { start: 12, end: 13 }]);\n\nms.getNext(3);\n// { start: 12, end: 13 }\n\nms.getNext(3, { overlap: true });\n// {start: 3, end: 5 }\n```\n\n# Licence\n\n\u003e Copyright 2014 British Broadcasting Corporation\n\u003e\n\u003e Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at\n\u003e\n\u003e http://www.apache.org/licenses/LICENSE-2.0\n\u003e\n\u003e Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbbc%2Fmedia-sequence","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbbc%2Fmedia-sequence","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbbc%2Fmedia-sequence/lists"}