|
@@ -11,7 +11,7 @@ import { ConfirmDialogParams } from '../../viewmodel/ConfirmDialogParam';
|
|
|
import { ConfirmDialog } from '../ConfirmDialog';
|
|
|
import promptAction from '@ohos.promptAction';
|
|
|
|
|
|
-const 'hhtest' = "Process camera upload"
|
|
|
+const TAG = "Process camera upload"
|
|
|
|
|
|
@Component
|
|
|
export struct MultiMediaCollect {
|
|
@@ -84,34 +84,34 @@ export struct MultiMediaCollect {
|
|
|
createSubscriber = async () => {
|
|
|
this.subscriber = await CommonEventManager.createSubscriber(this.subscribeInfo);
|
|
|
if (this.subscriber) {
|
|
|
- console.info('hhtest', "创建订阅回调成功");
|
|
|
+ console.info(TAG, "创建订阅回调成功");
|
|
|
CommonEventManager.subscribe(this.subscriber, (err, data) => {
|
|
|
if (err?.code) {
|
|
|
- console.error('hhtest', "SubscribeCallBack err=" + JSON.stringify(err));
|
|
|
+ console.error(TAG, "SubscribeCallBack err=" + JSON.stringify(err));
|
|
|
return;
|
|
|
}
|
|
|
- console.info('hhtest', "SubscribeCallBack data=" + JSON.stringify(data));
|
|
|
+ console.info(TAG, "SubscribeCallBack data=" + JSON.stringify(data));
|
|
|
if (data?.code !== undefined) {
|
|
|
switch (data.code) {
|
|
|
case 2:
|
|
|
this.uploadPhoto(); // 拍照成功
|
|
|
break;
|
|
|
case 3:
|
|
|
- console.info('hhtest', "开始预览");
|
|
|
+ console.info(TAG, "开始预览");
|
|
|
this.startView(); // 连接成功
|
|
|
break;
|
|
|
case -1:
|
|
|
- console.info('hhtest','连接故障')
|
|
|
+ console.info(TAG,'连接故障')
|
|
|
break;
|
|
|
case 5:
|
|
|
- console.info('hhtest','暂停预览')
|
|
|
+ console.info(TAG,'暂停预览')
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
//0001:自动闪光 0002:关闭闪光 0003:开启闪光
|
|
|
if (data?.parameters?.flash_mode) {
|
|
|
const flashMode:string = data.parameters.flash_mode
|
|
|
- console.info('hhtest', `收到闪光模式: ${flashMode}`);
|
|
|
+ console.info(TAG, `收到闪光模式: ${flashMode}`);
|
|
|
switch (flashMode) {
|
|
|
case '0001':
|
|
|
this.selectedFlashMode = 0
|
|
@@ -123,7 +123,7 @@ export struct MultiMediaCollect {
|
|
|
this.selectedFlashMode = 1
|
|
|
break;
|
|
|
default:
|
|
|
- console.warn('hhtest', `未知闪光模式: ${flashMode}`);
|
|
|
+ console.warn(TAG, `未知闪光模式: ${flashMode}`);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
@@ -179,9 +179,9 @@ export struct MultiMediaCollect {
|
|
|
connectCamera = async () => {
|
|
|
CommonEventManager.publish("opensession", (err) => {
|
|
|
if (err?.code) {
|
|
|
- console.info('hhtest',"Publish openSession err=" + JSON.stringify(err))
|
|
|
+ console.info(TAG,"Publish openSession err=" + JSON.stringify(err))
|
|
|
} else {
|
|
|
- console.info('hhtest',"Publish openSession succeed ")
|
|
|
+ console.info(TAG,"Publish openSession succeed ")
|
|
|
}
|
|
|
})
|
|
|
}
|
|
@@ -189,9 +189,9 @@ export struct MultiMediaCollect {
|
|
|
queryFlashMode = async () => {
|
|
|
CommonEventManager.publish("queryflashmode", (err) => {
|
|
|
if (err?.code) {
|
|
|
- console.info('hhtest',"Publish openSession err=" + JSON.stringify(err))
|
|
|
+ console.info(TAG,"Publish openSession err=" + JSON.stringify(err))
|
|
|
} else {
|
|
|
- console.info('hhtest',"Publish openSession succeed ")
|
|
|
+ console.info(TAG,"Publish openSession succeed ")
|
|
|
}
|
|
|
})
|
|
|
}
|
|
@@ -200,7 +200,7 @@ export struct MultiMediaCollect {
|
|
|
startView=()=>{
|
|
|
CommonEventManager.publish("startview", (err) => {
|
|
|
if (err?.code) {
|
|
|
- console.error('hhtest', JSON.stringify(err));
|
|
|
+ console.error(TAG, JSON.stringify(err));
|
|
|
} else {
|
|
|
this.isCapturing = false;
|
|
|
this.isStopView =false;
|
|
@@ -213,7 +213,7 @@ export struct MultiMediaCollect {
|
|
|
stopView=async()=>{
|
|
|
CommonEventManager.publish("stopview", (err) => {
|
|
|
if (err?.code) {
|
|
|
- console.error('hhtest', JSON.stringify(err));
|
|
|
+ console.error(TAG, JSON.stringify(err));
|
|
|
} else {
|
|
|
this.isCapturing = false;
|
|
|
this.isStopView =true;
|
|
@@ -265,7 +265,7 @@ export struct MultiMediaCollect {
|
|
|
this.commodityPixelMap = this.previewManager!.getActiveBuffer();
|
|
|
}
|
|
|
} catch (error) {
|
|
|
- console.warn('hhtest', "预览更新失败:", error);
|
|
|
+ console.warn(TAG, "预览更新失败:", error);
|
|
|
}
|
|
|
}
|
|
|
}, 50);
|
|
@@ -275,14 +275,14 @@ export struct MultiMediaCollect {
|
|
|
disconnectCamera = () => {
|
|
|
CommonEventManager.publish("stopview", (err) => {
|
|
|
if (err?.code) {
|
|
|
- console.info('hhtest',"Publish stopview err=" + JSON.stringify(err))
|
|
|
+ console.info(TAG,"Publish stopview err=" + JSON.stringify(err))
|
|
|
} else {
|
|
|
- console.info('hhtest',"Publish stopview succeed ")
|
|
|
+ console.info(TAG,"Publish stopview succeed ")
|
|
|
CommonEventManager.publish("closesession", (err) => {
|
|
|
if (err?.code) {
|
|
|
- console.info('hhtest',"Publish closesession err=" + JSON.stringify(err))
|
|
|
+ console.info(TAG,"Publish closesession err=" + JSON.stringify(err))
|
|
|
} else {
|
|
|
- console.info('hhtest',"Publish closesession succeed ")
|
|
|
+ console.info(TAG,"Publish closesession succeed ")
|
|
|
}
|
|
|
})
|
|
|
}
|
|
@@ -295,16 +295,16 @@ export struct MultiMediaCollect {
|
|
|
this.isCapturing = true;
|
|
|
CommonEventManager.publish("stopview", (err) => {
|
|
|
if (err?.code) {
|
|
|
- console.info('hhtest',"Publish stopview err=" + JSON.stringify(err));
|
|
|
+ console.info(TAG,"Publish stopview err=" + JSON.stringify(err));
|
|
|
this.isCapturing = false;
|
|
|
} else {
|
|
|
- console.info('hhtest',"Publish Publish stopview succeed");
|
|
|
+ console.info(TAG,"Publish Publish stopview succeed");
|
|
|
CommonEventManager.publish("shootonly", (err) => {
|
|
|
if (err?.code) {
|
|
|
- console.info('hhtest',"Publish shootonly error=" + JSON.stringify(err));
|
|
|
+ console.info(TAG,"Publish shootonly error=" + JSON.stringify(err));
|
|
|
this.isCapturing = false;
|
|
|
} else {
|
|
|
- console.info('hhtest',"Publish Publish shootonly succeed");
|
|
|
+ console.info(TAG,"Publish Publish shootonly succeed");
|
|
|
}
|
|
|
});
|
|
|
}
|
|
@@ -316,22 +316,22 @@ export struct MultiMediaCollect {
|
|
|
this.isStopView = true;
|
|
|
CommonEventManager.publish("stopview", (err) => {
|
|
|
if (err?.code) {
|
|
|
- console.info('hhtest',"Publish stopview err=" + JSON.stringify(err));
|
|
|
+ console.info(TAG,"Publish stopview err=" + JSON.stringify(err));
|
|
|
} else {
|
|
|
- console.info('hhtest',"Publish Publish stopview succeed");
|
|
|
+ console.info(TAG,"Publish Publish stopview succeed");
|
|
|
CommonEventManager.publish(mode, (err) => {
|
|
|
if (err?.code) {
|
|
|
- console.info('hhtest',"Publish shootonly error=" + JSON.stringify(err));
|
|
|
+ console.info(TAG,"Publish shootonly error=" + JSON.stringify(err));
|
|
|
} else {
|
|
|
- console.info('hhtest',"Publish Publish shootonly succeed");
|
|
|
- CommonEventManager.publish("startview", (err) => {
|
|
|
- this.isStopView = false;
|
|
|
- if (err?.code) {
|
|
|
- console.info('hhtest',"Publish shootonly error=" + JSON.stringify(err));
|
|
|
- }else{
|
|
|
- console.info('hhtest',"Publish Publish shootonly succeed");
|
|
|
- }
|
|
|
- })
|
|
|
+ console.info(TAG,"Publish Publish shootonly succeed");
|
|
|
+ CommonEventManager.publish("startview", (err) => {
|
|
|
+ this.isStopView = false;
|
|
|
+ if (err?.code) {
|
|
|
+ console.info(TAG,"Publish shootonly error=" + JSON.stringify(err));
|
|
|
+ }else{
|
|
|
+ console.info(TAG,"Publish Publish shootonly succeed");
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
});
|
|
|
}
|
|
@@ -349,7 +349,7 @@ export struct MultiMediaCollect {
|
|
|
this.startView();//上传完恢复预览
|
|
|
})
|
|
|
} catch (error) {
|
|
|
- console.error('hhtest',"upload failed:", error.code);
|
|
|
+ console.error(TAG,"upload failed:", error.code);
|
|
|
}
|
|
|
}
|
|
|
async aboutToAppear() {
|
|
@@ -389,21 +389,21 @@ export struct MultiMediaCollect {
|
|
|
}
|
|
|
}
|
|
|
if(this.isUploading){
|
|
|
- Column() {
|
|
|
- Text('正在上传中...')
|
|
|
- .fontSize($r('app.float.fontSize_30'))
|
|
|
- .margin({bottom:'10%'})
|
|
|
- LoadingProgress()
|
|
|
- .color(Color.Blue)
|
|
|
- .width('25%')
|
|
|
- .width('25%')
|
|
|
- }
|
|
|
- .height('30%')
|
|
|
- .width('25%')
|
|
|
- .backgroundColor(Color.White)
|
|
|
- .borderRadius($r('app.float.virtualSize_16'))
|
|
|
- .justifyContent(FlexAlign.Center)
|
|
|
+ Column() {
|
|
|
+ Text('正在上传中...')
|
|
|
+ .fontSize($r('app.float.fontSize_30'))
|
|
|
+ .margin({bottom:'10%'})
|
|
|
+ LoadingProgress()
|
|
|
+ .color(Color.Blue)
|
|
|
+ .width('25%')
|
|
|
+ .width('25%')
|
|
|
}
|
|
|
+ .height('30%')
|
|
|
+ .width('25%')
|
|
|
+ .backgroundColor(Color.White)
|
|
|
+ .borderRadius($r('app.float.virtualSize_16'))
|
|
|
+ .justifyContent(FlexAlign.Center)
|
|
|
+ }
|
|
|
if(this.selectedPhotoIndex === -1){
|
|
|
Row() {
|
|
|
Image(
|
|
@@ -682,8 +682,8 @@ export struct MultiMediaCollect {
|
|
|
.justifyContent(FlexAlign.End)
|
|
|
.margin({right :'2%'})
|
|
|
}.width('98%')
|
|
|
- .height('10%')
|
|
|
- .position({x:'2%',y:'90%'})
|
|
|
+ .height('10%')
|
|
|
+ .position({x:'2%',y:'90%'})
|
|
|
}
|
|
|
}
|
|
|
.width('86%')
|
|
@@ -721,9 +721,9 @@ export struct MultiMediaCollect {
|
|
|
.alignItems(HorizontalAlign.Center)
|
|
|
.enabled(!this.isUploading)
|
|
|
.onClick(()=>{
|
|
|
- this.selectedPhotoIndex = index;
|
|
|
- this.resetImageTransform()
|
|
|
- this.stopView();
|
|
|
+ this.selectedPhotoIndex = index;
|
|
|
+ this.resetImageTransform()
|
|
|
+ this.stopView();
|
|
|
|
|
|
})
|
|
|
}.height('19%')
|
|
@@ -793,7 +793,7 @@ class PreviewManager {
|
|
|
this.lastFrameTime = now;
|
|
|
return true;
|
|
|
} catch (error) {
|
|
|
- console.warn('hhtest', "处理预览帧失败:", error);
|
|
|
+ console.warn(TAG, "处理预览帧失败:", error);
|
|
|
return false;
|
|
|
} finally {
|
|
|
this.isProcessing = false;
|