!5282 MediaPlayer使用前增加判空处理

Merge pull request !5282 from wangjincheng/master
This commit is contained in:
openharmony_ci 2023-07-11 13:07:47 +00:00 committed by Gitee
commit 6e2d5158b0
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -52,6 +52,10 @@ bool BootVideoPlayer::PlayVideo()
if (mediaPlayer_ == nullptr) {
mediaPlayer_ = Media::PlayerFactory::CreatePlayer();
}
if (mediaPlayer_ == nullptr) {
LOGE("PlayVideo SetPlayerCallback fail, mediaPlayer_ is nullptr");
return false;
}
std::shared_ptr<VideoPlayerCallback> cb = std::make_shared<VideoPlayerCallback>(shared_from_this());
int32_t ret = mediaPlayer_->SetPlayerCallback(cb);
if (ret != 0) {