-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #489 from shiguredo/feature/mp4-media-stream-vite
MP4 から MediaStream を作成するためのパッケージを追加する
- Loading branch information
Showing
22 changed files
with
1,829 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,3 +42,6 @@ yarn.lock | |
|
||
# Ignore typedoc output | ||
apidoc/ | ||
|
||
# Rust | ||
/target/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[workspace] | ||
members = ["packages/mp4-media-stream/wasm/"] | ||
resolver = "2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Media Processors: MP4 メディアストリームサンプル</title> | ||
</head> | ||
<body> | ||
<h1>Media Processors: MP4 メディアストリームサンプル</h1> | ||
|
||
<h3>入力 MP4 ファイル</h3> | ||
ファイル選択後に「再生開始」ボタンを押してください。 | ||
<br /><br /> | ||
<input id="input" type="file" accept="video/mp4" /> | ||
<br /><br /> | ||
<input id="play" type="button" value="再生開始" /> | ||
<input id="stop" type="button" value="再生停止" /> | ||
|
||
<br /><br /> | ||
<input id="repeat" type="checkbox"> リピート再生を有効にする | ||
<br /> | ||
|
||
<h3>出力映像</h3> | ||
<video id="output" autoplay playsinline></video> | ||
|
||
<script type="module" src="./main.mts"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { Mp4MediaStream } from '@shiguredo/mp4-media-stream' | ||
|
||
document.addEventListener('DOMContentLoaded', async () => { | ||
let mp4MediaStream | ||
|
||
if (!Mp4MediaStream.isSupported()) { | ||
alert('Unsupported platform') | ||
throw Error('Unsupported platform') | ||
} | ||
|
||
async function load() { | ||
const input = document.getElementById('input') | ||
const files = input.files | ||
if (files === null || files.length === 0) { | ||
return | ||
} | ||
const file = files[0] | ||
|
||
if (mp4MediaStream !== undefined) { | ||
await mp4MediaStream.stop() | ||
} | ||
|
||
try { | ||
mp4MediaStream = await Mp4MediaStream.load(file) | ||
} catch (e) { | ||
alert(e.message) | ||
throw e | ||
} | ||
} | ||
|
||
function play() { | ||
if (mp4MediaStream === undefined) { | ||
alert('MP4 ファイルが未選択です') | ||
return | ||
} | ||
|
||
const options = { | ||
repeat: document.getElementById('repeat').checked, | ||
} | ||
const stream = mp4MediaStream.play(options) | ||
|
||
const output = document.getElementById('output') | ||
output.srcObject = stream | ||
} | ||
|
||
async function stop() { | ||
if (mp4MediaStream === undefined) { | ||
return | ||
} | ||
|
||
await mp4MediaStream.stop() | ||
} | ||
|
||
document.getElementById('input').addEventListener('change', load) | ||
document.getElementById('play').addEventListener('click', play) | ||
document.getElementById('stop').addEventListener('click', stop) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.