W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
解釋:開始錄像
Object object
參數(shù) | 類型 | 必填 | 默認(rèn)值 | 說明 |
---|---|---|---|---|
progress | Function | 否 | 錄制進(jìn)度更新的回調(diào)函數(shù)。 | |
timeout | Function | 否 | 超過 10s 或頁(yè)面 onHide 時(shí)會(huì)結(jié)束錄像。 | |
success | Function | 否 | 接口調(diào)用成功的回調(diào)函數(shù) | |
fail | Function | 否 | 接口調(diào)用失敗的回調(diào)函數(shù) | |
complete | Function | 否 | 接口調(diào)用結(jié)束的回調(diào)函數(shù)(調(diào)用成功、失敗都會(huì)執(zhí)行) |
參數(shù)名 | 類型 | 說明 |
---|---|---|
progress | String | 視頻的臨時(shí)路徑 |
參數(shù)名 | 類型 | 說明 |
---|---|---|
tempVideoPath | String | 視頻的臨時(shí)路徑 |
<ar-camera ar-key="10298931" ar-type="5" flash="{{flashState}}" class="camera" bindload="loadCameraSuccess" bindmessage="message" binderror="error">
<cover-view s-if="ifRecord" class="cameraState" bindtap="startRecord">開始錄像</cover-view>
<cover-view s-else class="cameraState" bindtap="stopRecord">結(jié)束錄像</cover-view>
<cover-view>
<video src="{{VideoPath}}"></video>
</cover-view>
<!--重拍,保存 的按鈕 -->
<cover-view class="action-complete" s-if="isRecordComplete">
<cover-image class="giveup-img" src="https://b.bdstatic.com/miniapp_cl_ar_back.png" rel="external nofollow" bindtap="reset" />
<cover-image class="save-img" src="https://b.bdstatic.com/miniapp_cl_ar_save.png" rel="external nofollow" bindtap="save" />
</cover-view>
</ar-camera>
Page({
data: {
ifRecord: true,
VideoPath: '',
isRecordComplete: false
},
onReady() {
// 初始化ar相機(jī)
this.ARCameraContext = swan.createARCameraContext();
},
startRecord() {
let that = this;
this.ARCameraContext.startRecord({
success: res => {
that.setData({'ifRecord': false});
}
});
},
stopRecord() {
let that = this;
this.ARCameraContext.stopRecord({
success: res => {
that.setData({'ifRecord': true});
swan.showModal({
title: 'success',
content: JSON.stringify(res)
});
that.setData({
VideoPath: res.tempVideoPath,
isRecordComplete: true
})
}
});
},
reset() {
this.ARCameraContext.reset({
success: res => {
this.setData({
isRecordComplete: false,
VideoPath: ''
});
},
fail: e => {
swan.showToast({
title: JSON.stringify(e),
icon: 'none'
});
}
});
},
save() {
swan.saveVideoToPhotosAlbum({
filePath: this.data.VideoPath,
success: handleSaveSuccess.bind(this),
fail: handleSaveFail.bind(this)
});
function handleSaveSuccess(res) {
swan.showToast({
title: '保存成功'
});
this.setData({
isRecordComplete: true
});
}
function handleSaveFail(e) {
swan.showToast({title: '保存失敗'});
}
}
});
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: