1
0
Fork 0
mirror of https://github.com/kou029w/_.git synced 2025-01-31 06:18:07 +00:00

Add 'media/' from commit 'd58433f693528d7111b9221f550a1e521c7dbe36'

git-subtree-dir: media
git-subtree-mainline: 5423a81ecd
git-subtree-split: d58433f693
This commit is contained in:
Nebel 2020-07-21 00:34:00 +09:00
commit 5d936d154e
2 changed files with 53 additions and 0 deletions

53
media/index.html Normal file
View file

@ -0,0 +1,53 @@
<!DOCTYPE html>
<html lang="ja">
<title>media-example</title>
<h1 id="title">Media Devices - Video Test</h1>
<video id="player" controls autoplay></video>
<div id="devices"></div>
<h2 id="permission">デバイスを許可する方法 (Firefox)</h2>
<section>
<h3>方法1</h3>
<p>
<a href="permissions.sqlite">事前にカメラを許可したpermissions.sqlite</a>
をダウンロード後、プロファイルディレクトリ以下のpermissions.sqliteファイル
と置き換える。
</p>
</section>
<section>
<h3>方法2</h3>
<p>
あるいは、次のSQLをプロファイルディレクトリ以下のpermissions.sqliteファイル
に対して発行する。
</p>
<pre>
insert into moz_perms (origin, type, permission, expireType, expireTime, modificationTime)
values ("https://media-example.kou029w.now.sh", "camera", 1, 0, 0, 0);
</pre>
</section>
<script>
(async () => {
const devices = (await navigator.mediaDevices.enumerateDevices()).filter(
({ kind }) => kind === "videoinput"
);
const list = document.getElementById("devices");
devices.forEach(({ deviceId, label }) => {
const a = document.createElement("a");
a.href = `#${deviceId}`;
a.textContent = `${label} (${deviceId})`;
a.style.display = "block";
a.onclick = () => {
location.href = a.href;
location.reload();
};
list.appendChild(a);
});
})();
const play = async deviceId => {
const player = document.getElementById("player");
player.srcObject = await navigator.mediaDevices.getUserMedia({
video: { deviceId }
});
};
play(location.hash.slice(1));
</script>
</html>

BIN
media/permissions.sqlite Normal file

Binary file not shown.