表盘:增加视频表盘在传输状态下的暂停 1324/1 1324/head 1325/target/1
authorCaisking <3449750381@qq.com>
Sun, 3 Nov 2024 03:27:57 +0000 (11:27 +0800)
committerCaisking <3449750381@qq.com>
Sun, 3 Nov 2024 03:27:57 +0000 (11:27 +0800)
code/sdk/application/wearable/fd230app/nativeui/main/include/MainModel.h
code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialViewGroup.h
code/sdk/application/wearable/fd230app/nativeui/main/src/MainModel.cpp
code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialViewGroup.cpp

index a5781cd..2686cae 100644 (file)
@@ -83,6 +83,8 @@ namespace OHOS
         void printDialStates();\r
         void UpdateDialState();\r
         void InitDialState();\r
+        bool getVideostate();\r
+        void setVideostate(bool state);\r
 \r
     private:\r
         void InitDialSettingDefault(int Id);\r
@@ -96,6 +98,7 @@ namespace OHOS
         DialSetting dialSetting;\r
         bool isFromSetCardView{false};\r
         uint8_t fromCardId{MAX_CARD};\r
+        bool video_state{false};\r
     };\r
 }\r
 \r
index 69a46cd..49a94cc 100644 (file)
@@ -112,9 +112,13 @@ public:
     * @brief  This function is invoked when the function SetHorCurrentPage() is called.
     */
     void OnActive(void) override;
-       
+
     void OnInactive(void) override;
 
+    /*外部接口对表盘进行调用*/
+    void StopDial();
+    void StartDial();
+
     MediaVideoPlay* GetVideoPlay();
 
 private:
index 863c5f0..c423869 100644 (file)
@@ -611,6 +611,13 @@ namespace OHOS
         if (MainViewSample::GetInstance() != nullptr)\r
             MainViewSample::GetInstance()->UpdateStateShow();\r
     }\r
+    //主界面获取视频频率\r
+    bool MainModel::getVideostate() {\r
+      return video_state;\r
+    }\r
+    void MainModel::setVideostate(bool state) {\r
+      video_state = state;\r
+    }\r
 \r
 }\r
 #if 0\r
index 5ca5633..f796bcb 100644 (file)
@@ -5,6 +5,8 @@
 #include "msg_center.h"
 #include "securec.h"
 #include "DialBinParser.h"
+#include "custom_runtime.h"
+#include "MainModel.h"
 #include "ModelDialDataFactory.h"
 #include "common/low_power_manager.h"
 #include "main/include/PullUpDownView.h"
@@ -254,24 +256,6 @@ namespace OHOS
         return period_;
     }
 
-    void DialViewGroup::UpdateViewsByPeriodicUpdateData()
-    {
-        ListNode<DialDataType> *node = periodicUpdateTypes_.Head();
-        while (node != periodicUpdateTypes_.End())
-        {
-            DialDataType type = node->data_;
-            auto iter = dataTypeMap_.find(static_cast<int16_t>(type));
-            if (iter != dataTypeMap_.end())
-            {
-                ProcessData(type, iter->second);
-            }
-            node = node->next_;
-        }
-        if (LowPowerManager::GetInstance()->IsLiteSurfaceInRootView())
-        {
-            Invalidate();
-        }
-    }
 
     void DialViewGroup::OnDialFloatDataUpdate(DialDataType type, float data)
     {
@@ -523,6 +507,38 @@ namespace OHOS
             kaleidoscope_->StopRotateAnimator();
             kaleidoscope_->ClearFocus();
         }
+    }
+void DialViewGroup::StopDial() {
+  if (MainModel::GetInstance().getVideostate() != false) {
+    return;
+  }
+  MainModel::GetInstance().setVideostate(true);
+  if (video_ != nullptr) {
+    if (!video_->IsStopped()) {
+      video_->StopPlay();
+    }
+    g_video = nullptr;
+  } else if (kaleidoscope_ != nullptr) {
+    kaleidoscope_->StopRotateAnimator();
+    kaleidoscope_->ClearFocus();
+  }
+}
+void DialViewGroup::StartDial() {
+  if (MainModel::GetInstance().getVideostate() != true) {
+    return;
+  }
+  MainModel::GetInstance().setVideostate(false);
+  if (video_ != nullptr) {
+    if (video_->IsPaused()) {
+      video_->ResumePlay();
+    } else if (!video_->IsPlayed()) {
+      video_->StartPlay();
+    }
+    g_video = video_;
+  } else if (kaleidoscope_ != nullptr) {
+    kaleidoscope_->RequestFocus();
+    kaleidoscope_->StartRotateAnimator();
+  }
 }
 MediaVideoPlay* DialViewGroup::GetVideoPlay()
 {
@@ -531,4 +547,27 @@ MediaVideoPlay* DialViewGroup::GetVideoPlay()
     }
     return nullptr;
 }
+//更新数据
+void DialViewGroup::UpdateViewsByPeriodicUpdateData() {
+  ListNode<DialDataType> *node = periodicUpdateTypes_.Head();
+  while (node != periodicUpdateTypes_.End()) {
+    DialDataType type = node->data_;
+    auto iter = dataTypeMap_.find(static_cast<int16_t>(type));
+    if (iter != dataTypeMap_.end()) {
+      ProcessData(type, iter->second);
+    }
+    node = node->next_;
+  }
+  if (LowPowerManager::GetInstance()->IsLiteSurfaceInRootView()) {
+    Invalidate();
+  }
+  // ota进行视频暂停
+  if (uapi_dev_runtime_get_transmitting_status() == 1) {
+    //暂停视频
+    StopDial();
+  } else {
+    //获取视频
+    StartDial();
+  }
+}
 }
\ No newline at end of file