提交 2fc488ac 编写于 作者: Z z00421080

Discription:Fix player err for linux kernel

Signed-off-by: Nz00421080 <zhangjian112@huawei.com>
上级 9f239ddd
...@@ -110,7 +110,7 @@ class PlayerAbilitySlice : public AbilitySlice { ...@@ -110,7 +110,7 @@ class PlayerAbilitySlice : public AbilitySlice {
public: public:
PlayerAbilitySlice() = default; PlayerAbilitySlice() = default;
~PlayerAbilitySlice() override; ~PlayerAbilitySlice() override;
static std::shared_ptr<Player> CreatePlayer();
protected: protected:
void OnStart(const Want &want) override; void OnStart(const Want &want) override;
void OnInactive() override; void OnInactive() override;
......
...@@ -39,6 +39,15 @@ PlayerAbilitySlice::~PlayerAbilitySlice() ...@@ -39,6 +39,15 @@ PlayerAbilitySlice::~PlayerAbilitySlice()
printf("################ ~PlayerAbilitySlice exit\n"); printf("################ ~PlayerAbilitySlice exit\n");
} }
std::shared_ptr<Player> PlayerAbilitySlice::CreatePlayer()
{
static std::shared_ptr<Player> instance_ = nullptr;
if (instance_ == nullptr) {
instance_ = std::make_shared<Player>();
}
return instance_;
}
void PlayerAbilitySlice::Clear() void PlayerAbilitySlice::Clear()
{ {
printf("PlayerAbilitySlice::Clear | enter\n"); printf("PlayerAbilitySlice::Clear | enter\n");
...@@ -175,7 +184,7 @@ void PlayerAbilitySlice::SetUpVideoPlayer(const Want &want) ...@@ -175,7 +184,7 @@ void PlayerAbilitySlice::SetUpVideoPlayer(const Want &want)
} }
printf("------########### mp4 file path | %s\n", videoPlayer_->filePath); printf("------########### mp4 file path | %s\n", videoPlayer_->filePath);
videoPlayer_->adapter = std::make_shared<Player>(); videoPlayer_->adapter = PlayerAbilitySlice::CreatePlayer();
std::string uri(videoPlayer_->filePath); std::string uri(videoPlayer_->filePath);
std::map<std::string, std::string> header; std::map<std::string, std::string> header;
Source source(uri, header); Source source(uri, header);
...@@ -379,7 +388,7 @@ void PlayerAbilitySlice::OnStop() ...@@ -379,7 +388,7 @@ void PlayerAbilitySlice::OnStop()
if (videoPlayer_ != nullptr && videoPlayer_->adapter.get() != nullptr) { if (videoPlayer_ != nullptr && videoPlayer_->adapter.get() != nullptr) {
videoPlayer_->adapter->Stop(); videoPlayer_->adapter->Stop();
videoPlayer_->adapter->Release(); videoPlayer_->adapter->Reset();
delete videoPlayer_; delete videoPlayer_;
videoPlayer_ = nullptr; videoPlayer_ = nullptr;
} }
...@@ -392,9 +401,9 @@ void SliderAnimator::Callback(UIView* view) ...@@ -392,9 +401,9 @@ void SliderAnimator::Callback(UIView* view)
{ {
if (needRefreshPlayer_) { if (needRefreshPlayer_) {
videoPlayer_->adapter->Stop(); videoPlayer_->adapter->Stop();
videoPlayer_->adapter->Release(); videoPlayer_->adapter->Reset();
videoPlayer_->adapter = std::make_shared<Player>(); videoPlayer_->adapter = PlayerAbilitySlice::CreatePlayer();
std::string uri(videoPlayer_->filePath); std::string uri(videoPlayer_->filePath);
std::map<std::string, std::string> header; std::map<std::string, std::string> header;
Source source(uri, header); Source source(uri, header);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册