index.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. Component({
  2. properties: {
  3. title: {
  4. type: String,
  5. value: '',
  6. },
  7. intro: {
  8. type: String,
  9. value: '',
  10. },
  11. hint: {
  12. type: String,
  13. value: '',
  14. },
  15. code: {
  16. type: String,
  17. value: '',
  18. },
  19. json: {
  20. type: String,
  21. value: '',
  22. },
  23. js: {
  24. type: String,
  25. value: '',
  26. },
  27. showBackBtn: {
  28. type: Boolean,
  29. value: false,
  30. },
  31. recordState: 0,
  32. },
  33. data: {
  34. },
  35. lifetimes: {
  36. attached() {
  37. wx.xrTitle = this.data.title;
  38. }
  39. },
  40. captureQuality: {
  41. type: Number,
  42. value: 0.8,
  43. },
  44. captureType: {
  45. type: String,
  46. value: 'jpg',
  47. },
  48. recordFPS: {
  49. type: Number,
  50. value: 30,
  51. },
  52. methods: {
  53. recordStart() {
  54. console.log('recordStart')
  55. wx.updateShareMenu({
  56. withShareTicket: true,
  57. success () { }
  58. })
  59. this.scene.share.recordStart({
  60. fps: 15,
  61. videoBitsPerSecond: 10000,
  62. });
  63. },
  64. recordEnd() {
  65. console.log('recordEnd')
  66. const tempFilePath = this.scene.share.recordFinishToAlbum({
  67. fps: 15,
  68. videoBitsPerSecond: 10000,
  69. });
  70. wx.shareVideoMessage({
  71. videoPath: tempFilePath,
  72. });
  73. },
  74. onClickBack() {
  75. wx.navigateBack()
  76. },
  77. /**
  78. * 获取系统信息 设置相机的大小适应屏幕
  79. */
  80. setCameraSize() {
  81. //获取设备信息
  82. const res = wx.getSystemSetting();
  83. //获取屏幕的可使用宽高,设置给相机
  84. this.setData({
  85. cameraHeight: res.windowHeight,
  86. cameraWidth: res.windowWidth
  87. })
  88. console.log(res)
  89. },
  90. /**
  91. * 开始录像的方法
  92. */
  93. startShootVideo() {
  94. console.log("========= 调用开始录像 ===========")
  95. this.ctx.startRecord({
  96. success: (res) => {
  97. wx.showLoading({
  98. title: '正在录像',
  99. })
  100. },
  101. fail() {
  102. console.log("========= 调用开始录像失败 ===========")
  103. }
  104. })
  105. },
  106. /**
  107. * 结束录像
  108. */
  109. stopShootVideo() {
  110. console.log("========= 调用结束录像 ===========")
  111. this.ctx.stopRecord({
  112. success: (res) => {
  113. wx.hideLoading();
  114. this.setData({
  115. videoSrc: res.tempVideoPath,
  116. })
  117. },
  118. fail() {
  119. wx.hideLoading();
  120. console.log("========= 调用结束录像失败 ===========")
  121. }
  122. })
  123. }
  124. },
  125. options: {
  126. multipleSlots: true
  127. }
  128. })