ARCameraContext

解释:swan.createARCameraContext 的返回值。

示例

在开发者工具中预览效果

扫码体验

ARCameraContext - 图1请使用百度APP扫码

图片示例

ARCameraContext - 图2

ARCameraContext - 图3

ARCameraContext - 图4

代码示例

  1. Page({
  2. data: {
  3. src: ''
  4. },
  5. onShow() {
  6. const cameraContext = swan.createCameraContext();
  7. this.cameraContext = cameraContext
  8. swan.showModal({
  9. title: '这是ARCameraContext创建的实例对象',
  10. content: JSON.stringify(cameraContext)
  11. })
  12. },
  13. takePhoto() {
  14. this.cameraContext.takePhoto({
  15. quality: 'high',
  16. success: res => {
  17. this.setData({
  18. src: res.tempImagePath
  19. });
  20. }
  21. });
  22. },
  23. startRecord() {
  24. this.cameraContext.startRecord({
  25. success: res => {
  26. swan.showToast({
  27. title: 'startRecord'
  28. });
  29. }
  30. });
  31. },
  32. stopRecord() {
  33. this.cameraContext.stopRecord({
  34. success: res => {
  35. swan.showModal({
  36. title: '提示',
  37. content: res.tempVideoPath
  38. });
  39. this.setData({
  40. videoSrc: res.tempVideoPath
  41. });
  42. }
  43. });
  44. }
  45. });