diff --git a/frameworks/bridge/declarative_frontend/jsview/js_video.cpp b/frameworks/bridge/declarative_frontend/jsview/js_video.cpp index 996d93cc2d8fc74891ba6e06582e627768dc920a..19ec1cc35c5e249c9152d3a2816b5236ef6131b3 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_video.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_video.cpp @@ -74,7 +74,7 @@ void JSVideo::Create(const JSCallbackInfo& info) // Parse the rate, if it is invalid, set it as 1.0. double currentProgressRate = 1.0; - if (ParseJsDouble(currentProgressRateValue, currentProgressRate)) { + if (!ParseJsDouble(currentProgressRateValue, currentProgressRate)) { LOGW("Video parse currentProgressRate failed."); } VideoModel::GetInstance()->SetProgressRate(currentProgressRate); diff --git a/frameworks/core/components/video/video_element.cpp b/frameworks/core/components/video/video_element.cpp index 614696958785673c20b46ae9774dea72b9c1e740..56f3514bc7847c5de39a9023819b6edadf6257af 100644 --- a/frameworks/core/components/video/video_element.cpp +++ b/frameworks/core/components/video/video_element.cpp @@ -502,6 +502,10 @@ void VideoElement::SetMediaSource(std::string& filePath, int32_t& fd) return; } } else { + // relative path + if (StringUtils::StartWith(filePath, "/")) { + filePath = filePath.substr(1); + } RelativePathPlay(filePath); } } diff --git a/frameworks/core/components_ng/render/adapter/rosen_media_player.cpp b/frameworks/core/components_ng/render/adapter/rosen_media_player.cpp index 004da88e6ca6495e22391d33cc08cfb72ddce036..59794543536c2b01d6c9c3ea982fc06876edd3f7 100644 --- a/frameworks/core/components_ng/render/adapter/rosen_media_player.cpp +++ b/frameworks/core/components_ng/render/adapter/rosen_media_player.cpp @@ -272,6 +272,9 @@ bool RosenMediaPlayer::SetMediaSource(std::string& filePath, int32_t& fd) } } else { // relative path + if (StringUtils::StartWith(filePath, "/")) { + filePath = filePath.substr(1); + } RelativePathPlay(filePath); } return true; @@ -356,4 +359,4 @@ int32_t RosenMediaPlayer::Seek(int32_t mSeconds, OHOS::Ace::SeekMode mode) return mediaPlayer_->Seek(mSeconds, ConvertToMediaSeekMode(mode)); } -} // namespace OHOS::Ace::NG \ No newline at end of file +} // namespace OHOS::Ace::NG