From a1b1012a76ddacfd2c2d60077a54ed1b7879f8ef Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Mon, 11 Mar 2024 19:49:50 +0800 Subject: [PATCH] =?utf8?q?=E8=A1=A5=E4=BA=A4=E5=BD=95=E9=9F=B3Model?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/record/include/RecordingModel.h | 63 +++++++++---------- 1 file changed, 30 insertions(+), 33 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingModel.h b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingModel.h index aeafcbf19..d77dfcbcc 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingModel.h @@ -4,8 +4,6 @@ #include "stdio.h" #include "gfx_utils/list.h" #include "UiServersMsg.h" -#include "player.h" -#include "source.h" #include "audio_manager.h" #include "audio_base_type.h" #include "record/include/RecordingPresenter.h" @@ -16,6 +14,8 @@ #include #include #include +#include "../../../../../../middleware/services/media/foundation/utils/include/source.h" +#include "../../../../../../middleware/services/media/foundation/player/interfaces/kits/player.h" namespace OHOS { using OHOS::Media::Player; @@ -24,37 +24,21 @@ namespace OHOS using namespace ::Audio; using Audio::AudioManager; - // 播放器 - class RecordingPlayerInterruptListener : public InterruptListener + /* + * @brief 录音播放器状态 + */ + enum RecorderPlayerStatus { - public: - RecordingPlayerInterruptListener() {} - ~RecordingPlayerInterruptListener() {} - - void SetOwner(std::shared_ptr player); - void SetPaused(bool value); - void SetResumed(bool value); - void RestFlag(); - bool IsPaused(); - bool IsDelayed(); - bool IsResumed(); - bool IsBeginStopped(); - bool IsEndStopped(); - void OnInterrupt(int32_t type, int32_t hint) override; - void PausePlayer(void); - void ResumePlayer(void); - void StopPlayer(void); - std::shared_ptr GetPlayer(); - - private: - std::shared_ptr player_{nullptr}; - bool isPaused_{false}; - bool isDelayed_{false}; - bool isResumed_{false}; - bool isBeginStopped_{false}; - bool isEndStopped_{false}; + RECORDER_NORMAL, + RECORDER_ALREADY_PLAYING, // 录音播放中 + RECORDER_ALREADY_PAUSED, // 录音暂停 + RECORDER_ALREADY_STOPPED, // 录音停止 + RECORDER_PLAYBACK_COMPLETED, // 录音播放完成 + RECORDER_EXECUTE_FUNC_FAILED, // 函数执行失败 + RECORDER_RESPONSE_MAX, }; + class RecordingPlayerInterruptListener; class RecordingModel { public: @@ -62,7 +46,16 @@ namespace OHOS std::string GetRecordingPlayerUri(void); void SetRecordingPlayerUri(std::string src); void SetRecordingPlayButtonState(bool state); - int RecordingPlayerStat(); + void AudioInit(void); + void ConvertMillisecondToTime(int32_t milliseconds); + int RecordingPlayerInit(void); + int RecordingPlayerStat(void); + int BasePlayerStateOperate(int state); + int GetRecordingPlayerState(void); + bool HasRecordingPlayerPlayed(void); + int RecordingPlayerPlay(void); + int RecordingPlayerPause(void); + /* -------------------------------------------------------------------------- */ void InitRecordingListItem(); std::vector &GetRecordinglistItems(); @@ -73,7 +66,9 @@ namespace OHOS int GetClickRecordingIndex(void); std::vector &GetFileNames(void); void KeepTotalRecordDuration(std::string time); - const char *GetTotalRecordDuration(void); + std::string GetTotalRecordDuration(void) const; + std::string Getyyyymmhhh_date(void) const; + /* ----------------------------------- 定时器 ---------------------------------- */ void Recording_StartTimer(uint32_t interval); void Recording_StopTimer(void); @@ -96,7 +91,9 @@ namespace OHOS std::shared_ptr PlayerCallback{nullptr}; // 为媒体播放期间发生的事件和异常通知提供侦听器。 std::string Uri; // 唯一标识一个资源的字符串。 std::map Header; - std::shared_ptr Resource{nullptr}; + std::shared_ptr Resource{nullptr}; // 提供函数来实现与资源相关的操作。 + bool isStopAndReset{false}; // 判断是否是停止还是重置状态 + bool audioInitStatus{false}; /* -------------------------------------------------------------------------- */ std::vector fileNames; // 文件名 int RecordingMp3FileCount = 0; // 录音MP3数量 -- 2.17.1