ユーザーが自分のファイルシステムにアクセスするのを止めたいと思います。モバイル デバイスのカメラ ロールとビデオ。ライブ メディアのキャプチャを強制する。これは可能ですか?もしそうなら、これをどのように実装しますか?
1 に答える
2
userMedia
HTML5対応デバイスでは、 APIを使用できます(サポートされている場合) 。
これはあなたが始めるための優れたチュートリアルです。
基本的に、次のことができます。
<input type="file" accept="image/*;capture=camera"> <!-- Submit a new photo -->
<input type="file" accept="video/*;capture=camcorder"> <!-- Submit a new video -->
<input type="file" accept="audio/*;capture=microphone"> <!-- Submit a new audio track using the microphone -->
私が言ったように、これはサポートされている場合にのみ機能します。現在、iOS6のデバイスでさえAPIを部分的にサポートしていuserMedia
ます。
デバイスがAPIをサポートしているが、などはサポートしていないaccept="image/*;capture=camera" ...
場合は、同じことを行うように独自のボタンをプログラムできます。
<input type="button" id="newStream" value="Click me!">
<script>
// Following code adapted from the tutorial, not tested
document.getElementById('newStream').addEventListener('click', function(event){
// Not showing vendor prefixes or code that works cross-browser.
navigator.getUserMedia({video: true}, function(stream){
// Do something with stream or window.URL.createObjectURL(stream);
alert('Success!');
}, function(){ alert('Failed!'); });
});
</script>
于 2012-12-19T14:41:22.857 に答える