An open API service indexing awesome lists of open source software.

https://github.com/brodazz/mp4-player

Estensione per Visual Studio Code che riproduce video .mp4 (video + audio) direttamente in una scheda dell'editor, affiancabile al codice. Player HTML5 nativo, scorciatoie da tastiera e Content-Security-Policy restrittiva. Scritta in TypeScript.
https://github.com/brodazz/mp4-player

custom-editor html5-video media mp4 typescript video video-player vscode vscode-extension webview

Last synced: 4 days ago
JSON representation

Estensione per Visual Studio Code che riproduce video .mp4 (video + audio) direttamente in una scheda dell'editor, affiancabile al codice. Player HTML5 nativo, scorciatoie da tastiera e Content-Security-Policy restrittiva. Scritta in TypeScript.

Awesome Lists containing this project

README

          

# Modern Video Player โ€” with Audio for VS Code

[![Version](https://badgen.net/vs-marketplace/v/Brodazz.mp4-player)](https://marketplace.visualstudio.com/items?itemName=Brodazz.mp4-player)
[![Installs](https://badgen.net/vs-marketplace/i/Brodazz.mp4-player)](https://marketplace.visualstudio.com/items?itemName=Brodazz.mp4-player)
[![Rating](https://badgen.net/vs-marketplace/rating/Brodazz.mp4-player)](https://marketplace.visualstudio.com/items?itemName=Brodazz.mp4-player)
[![CI](https://github.com/Brodazz/mp4-player/actions/workflows/ci.yml/badge.svg)](https://github.com/Brodazz/mp4-player/actions/workflows/ci.yml)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)

Extension that plays `.mp4`, `.mov` and `.m4v` videos (video **and** audio) in a
Visual Studio Code editor tab. You can keep the video open in one pane and keep
writing code in another by splitting the editor โ€” no external windows.

![Video, code and AI side by side in VS Code](https://raw.githubusercontent.com/Brodazz/mp4-player/main/assets/demo.gif)

*A modern workflow: a reference video (Modern Video Player), your code and your AI assistant โ€” all at once, in VS Code.*

![The player with its custom control bar](https://raw.githubusercontent.com/Brodazz/mp4-player/main/assets/screenshot.png)

## Why this one

Most video extensions for VS Code either **play MP4 without sound** (Chromium in
VS Code can't decode AAC audio) or **make you install `ffmpeg` yourself**. This one
just works: it **bundles `ffmpeg`**, so MP4/MOV/M4V play **with audio out of the
box** โ€” no setup, no local server, fully **offline**, in a single lightweight and
secure extension.

- ๐Ÿ”Š **Real audio** on MP4/MOV/M4V โ€” even AAC, which VS Code can't decode on its own
- โšก **Zero setup** โ€” `ffmpeg` is bundled; nothing to install
- ๐Ÿ”’ **Secure & offline** โ€” no network, no local server, read-only editor, strict CSP
- ๐ŸŽ›๏ธ **Modern control bar** โ€” seekable timeline, speed (0.25ร—โ€“2ร—), volume, Picture-in-Picture, fullscreen
- ๐Ÿชถ **Lightweight & focused** โ€” does one thing, well
- ๐Ÿ–ฅ๏ธ **Cross-platform** โ€” Windows, Linux, macOS (Intel & Apple Silicon)

| | This extension | Other VS Code video extensions |
|---|:--:|:--:|
| Audio on MP4/MOV (incl. AAC) | โœ… out of the box | โŒ silent โ€” or โš ๏ธ only if you install ffmpeg |
| Setup required | โœ… none (ffmpeg bundled) | โš ๏ธ often needs ffmpeg installed |
| Network / local server | โœ… none โ€” fully offline | โš ๏ธ some run a local HTTP server |
| Footprint | ๐Ÿชถ lightweight | ๐Ÿ˜ some ship large WASM decoders |
| Security | ๐Ÿ”’ strict CSP, read-only, no network | varies |
| Control bar (speed ยท PiP ยท fullscreen) | โœ… built-in | varies |

## How it works

VS Code is built on Electron (Chromium), so an HTML5 `` tag in a Webview
plays the **H.264** video of MP4/MOV/M4V files. The VS Code engine, however, does
not decode **AAC audio**: that's why the extension extracts the audio track and
transcodes it locally (with a bundled `ffmpeg`) into MP3, then plays it **in
sync** with the video. Everything happens offline, on your PC. The extension
registers a *Custom Editor* for `.mp4`, `.mov` and `.m4v` files.

## Installation

### From a `.vsix` file
1. Download the `.vsix` file (from the *Releases* page, or build it yourself, see below).
2. In VS Code: **Extensions** (`Ctrl+Shift+X`) โ†’ `...` menu โ†’ *Install from VSIX...*
3. Or from the terminal: `code --install-extension mp4-player-win32-x64.vsix`

### Usage
- Open a `.mp4`, `.mov` or `.m4v` file from the Explorer: the player starts.
- To place code and video side by side, use the editor split (`Ctrl+\` or drag the tab).
- A **custom control bar** appears at the bottom of the player on mouse move
(play/pause, seekable timeline, time, volume, playback speed, Picture-in-Picture,
fullscreen) and fades out during playback. Keyboard shortcuts work too (see below).

## Keyboard shortcuts

| Key | Action |
|---|---|
| `Space` / `K` | Play / Pause |
| `โ†` / `โ†’` | Back / Forward 5s |
| `โ†‘` / `โ†“` | Volume up / down |
| `<` / `>` | Slower / Faster (0.25ร—โ€“2ร—) |
| `M` | Mute |
| `P` | Picture-in-Picture |
| `F` | Fullscreen |

## Development

```bash
npm install
npm run compile # or: npm run watch
```

Press **F5** in VS Code to open the *Extension Development Host* test window.

### Packaging (.vsix)

```bash
npm run package
```

## Security

See [SECURITY.md](SECURITY.md). In short: restrictive Content-Security-Policy,
cryptographic nonce, file access limited to the video's folder, read-only editor,
no network connections.

## Supported codecs

- **Video**: **H.264** (the most common). Codecs such as **H.265/HEVC** may not
be supported by the VS Code engine: in that case the player shows an error.
- **Audio**: handled via local transcoding with `ffmpeg`, so it works even with
**AAC** (which VS Code does not decode on its own). The audio is converted to a
temporary MP3 file the VS Code engine plays reliably, then cached for instant
reopens. The cache **cleans itself up** (files older than 7 days, and a 1 GB cap).

## Platforms

Dedicated packages for **Windows (x64)**, **Linux (x64)**, **macOS Intel** and
**macOS Apple Silicon**: audio works on all of them thanks to a bundled `ffmpeg`
for each platform. The VS Code Marketplace automatically downloads the right
package for your system.

## License

[MIT](LICENSE) ยฉ Alessandro Broda