{"id":28426984,"url":"https://github.com/hoaian2/video-player","last_synced_at":"2025-08-16T22:33:24.241Z","repository":{"id":281129592,"uuid":"944279071","full_name":"HOAIAN2/video-player","owner":"HOAIAN2","description":"A lightweight 30KB JavaScript video player packed with features, including source switching, picture-in-picture (PiP), and automatic landscape mode on mobile.","archived":false,"fork":false,"pushed_at":"2025-03-24T02:52:29.000Z","size":556,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-05T11:49:49.418Z","etag":null,"topics":["css","javascript","video-player","video-player-library"],"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/HOAIAN2.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":"2025-03-07T04:37:08.000Z","updated_at":"2025-03-24T02:52:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"b5116e03-3088-48b3-abce-3c0d1fc4d924","html_url":"https://github.com/HOAIAN2/video-player","commit_stats":null,"previous_names":["hoaian2/video-player"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/HOAIAN2/video-player","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HOAIAN2%2Fvideo-player","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HOAIAN2%2Fvideo-player/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HOAIAN2%2Fvideo-player/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HOAIAN2%2Fvideo-player/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HOAIAN2","download_url":"https://codeload.github.com/HOAIAN2/video-player/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HOAIAN2%2Fvideo-player/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270781196,"owners_count":24643804,"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-08-16T02:00:11.002Z","response_time":91,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","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":["css","javascript","video-player","video-player-library"],"created_at":"2025-06-05T11:37:31.330Z","updated_at":"2025-08-16T22:33:24.233Z","avatar_url":"https://github.com/HOAIAN2.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# My Video Player\n\n## Overview\n\nThe `createVideoPlayer` function creates a custom video player with enhanced controls such as play, pause, skip, fullscreen, progress tracking, and more. This player supports multiple video sources, speed settings, and auto-hide controls for a seamless viewing experience.\n\n## Features\n\n- **Play \u0026 Pause**: Toggle between playing and pausing the video.\n- **Skip Forward \u0026 Backward**: Jump ahead or rewind by a specified number of seconds.\n- **Fullscreen Mode**: Supports fullscreen playback with optional auto-rotation to landscape mode.\n- **Volume Control**: Adjustable volume settings with mute/unmute options.\n- **Progress Tracking**: Displays and updates the video progress bar.\n- **Playback Speed Adjustment**: Supports custom speed settings for playback.\n- **Multiple Video Sources**: Allows switching between different video sources.\n- **Subtitle Support**: Easily toggle subtitles on and off.\n- **Auto-Hide Controls**: The controller auto-hides after a specified period of inactivity.\n- **Picture-in-Picture (PiP) Mode**: Allows the video to play in a small floating window while multitasking.\n\n## Installation\n\nTo use the custom video player, include the JavaScript function in your project and call it with the desired configuration.\n\n### Include Required Files\n\nMake sure to include both the JavaScript and CSS files in your project:\n\n```html\n\u003clink rel=\"stylesheet\" href=\"custom-video-player.css\"\u003e\n\u003cscript src=\"custom-video-player.js\"\u003e\u003c/script\u003e\n```\n\nIf you're using ES modules, add the `export` statement to the `createVideoPlayer` function and simply import the function:\n\n```js\nimport { createVideoPlayer } from './video-player.js';\n```\n\nFor TypeScript users, ensure that you have the appropriate type definitions. If needed, you can define a type for the function parameters or let TypeScript infer them based on usage. Or just tell the AI do it for you.\n\n## Usage\n\n```js\nconst player = createVideoPlayer({\n    // This is for switching the video source while playing. I'm not sure if it will cause errors under a slow internet connection.\n    sources: [\n        { src: \"your-video-1080.mp4\", label: \"1080p\" },\n        { src: \"your-video-720.mp4\", label: \"720p\" },\n        { src: \"your-video-480.mp4\", label: \"480p\" },\n    ],\n    poster: undefined,\n    skipSeconds: 5,\n    autoHideControllerAfter: 3000, // miliseconds\n    forceLandscape: true,\n    enablePIP: true,\n    defaultVolume: 1,\n    defaultTime: 0,\n    speedSettings: [0.5, 1, 1.5, 2],\n    // This is translate object, remember to fill all attributes\n    settingLabels: {\n        speed: 'Playback speed',\n        source: 'Quality',\n        caption: 'Subtitle',\n        off: 'Off',\n    },\n    // This is native html video caption in *.vtt format: https://developer.mozilla.org/en-US/docs/Web/Media/Guides/Audio_and_video_delivery/Adding_captions_and_subtitles_to_HTML5_video\n    // \"srclang\" is language code, not country code\n    captions: [\n        {\n            src: 'caption-en.vtt',\n            srclang: 'en',\n            default: true,\n        },\n        {\n            src: 'caption-ja.vtt',\n            srclang: 'ja',\n            default: false,\n        },\n        {\n            src: 'caption-vi.vtt',\n            srclang: 'vi',\n            default: false,\n        },\n    ]\n});\n\n// Append to a container in the DOM\ndocument.getElementById(\"video-container\").appendChild(player);\n```\n\n## Configuration Options\n\n| Option | Type | Default | Description |\n|--------|------|---------|-------------|\n| `sources` | Array\u003c{src: string, label: string}\u003e | Required | Video sources with labels. |\n| `poster` | string | undefined | Video poster. |\n| `skipSeconds` | Number | `5` | Number of seconds to skip forward or backward. |\n| `autoHideControllerAfter` | Number | `3000` | Time (ms) before the controls auto-hide. |\n| `forceLandscape` | Boolean | `true` | Auto-rotate to landscape mode in fullscreen. |\n| `enablePIP` | Boolean | `true` | Show PIP button. |\n| `defaultVolume` | Number | 1 | Default video volume. |\n| `defaultTime` | Number | 0 | Default video current time of video. (second) |\n| `speedSettings` | Array\u003cNumber\u003e | `[0.5, 1, 1.5, 2]` | Available speed options. |\n| `settingLabels` | Object | `{ source: \"Source\", speed: \"Speed\", subtitle: \"Subtitles\", off: \"Off\" }` | Custom labels for settings. |\n| `captions` | Array\u003c{src:string,srclang:string,default:boolean} | Required | Captions /subtitles in *.vtt format. |\n\n## Controls \u0026 Shortcuts\n\n- **Spacebar**: Play/Pause the video.\n- **Arrow Right/Left**: Skip forward/backward.\n- **Up/Down Arrow**: Adjust volume.\n\n## License\n\nThis project is licensed under the MIT License.\nI created this project just for fun after watching a Korean drama. You can do anything you want with this project.\n\n## Author\n\nLê Hoài Ân\n\n## Demo\n\n![video player demo](./video-player-demo.jpg)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhoaian2%2Fvideo-player","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhoaian2%2Fvideo-player","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhoaian2%2Fvideo-player/lists"}