0
ビデオをキャプチャしたい。その後、ボタンをクリックしてビデオを再生したい。私はiOSとAndroidアプリのコードバで作業しています。 私はcordova-plugin-media-capture
とcordova-plugin-streaming-media
プラグインを使っています。iOSでビデオを作成してコードワイヤでキャプチャする
ビデオ作品を提供しています。私は「プレイ動画」ボタンをクリックしていた場合でも、私は、コンソールにエラーが表示されます。
ReferenceError: Can't find variable: playVideo
いただきましたの?ここに私の機能は次のとおりです。
//cordova media caputre plugin
document.addEventListener("deviceready", init, false);
function init() {
document.querySelector("#takeVideo").addEventListener("touchend", function() {
console.log("Take video");
navigator.device.capture.captureVideo(captureSuccess, captureError, {limit: 1});
}, false);
}
function captureError(e) {
console.log("capture error: "+JSON.stringify(e));
}
// capture callback
var captureSuccess = function(mediaFiles) {
var i, path, len;
for (i = 0, len = mediaFiles.length; i < len; i += 1) {
path = mediaFiles[i].fullPath;
console.log(mediaFiles[i].fullPath);
function playVideo(videoUrl) {
// Play a video with callbacks
var options = {
mustWatch: true,
successCallback: function() {
console.log("Video was closed without error.");
},
errorCallback: function(errMsg) {
console.log("Error! " + errMsg);
}
};
window.plugins.streamingMedia.playVideo(path, options);
}
}
};
マイボタン(HTML)
<button id="takeVideo">Take Video</button>
<input type="url" size="60" value="" id="vidUrl"/><br/>
<button type="button" onclick="playVideo(document.getElementById('vidUrl').value);">Play Video</button>
あなた自身の関数playVideoの名前を変更しようとしましたか?名前の衝突があるようです。そしておそらく、これはちょうど、あなたが関数の中で関数を宣言してからあなたのHTMLから呼び出すことができないからです。 – Kris