CameraContext.startRecord

解释:开始录像

方法参数

Object object

object参数说明

示例

在开发者工具中预览效果

扫码体验

请使用百度APP扫码

图片示例

代码示例

-

  1. <div class="camera"> <camera device-position="{{device}}" flash="off" binderror="error" style="width: 100%; height: 500rpx;"></camera> <button type="primary" bind:tap="startRecord">开始录像</button> <button type="primary" bind:tap="stopRecord">结束录像</button> <video s-if="videoSrc" class="video" src="{{videoSrc}}"></video></div>

-

  1. Page({
  2. data: {
  3. videoSrc: ''
  4. },
  5. startRecord() {
  6. const cameraContext = swan.createCameraContext();
  7. cameraContext.startRecord({
  8. success: res => {
  9. swan.showToast({
  10. title: 'startRecord'
  11. });
  12. }
  13. });
  14. },
  15. stopRecord() {
  16. const cameraContext = swan.createCameraContext();
  17. cameraContext.stopRecord({
  18. success: res => {
  19. swan.showModal({
  20. title: '提示',
  21. content: res.tempVideoPath
  22. });
  23. this.setData({
  24. videoSrc: res.tempVideoPath
  25. });
  26. }
  27. });
  28. }
  29. });