@@ -95,15 +95,10 @@ int64_t PlusPlayer::Create(const std::string &uri,
9595 }
9696 }
9797
98- char *appId = nullptr ;
99- int ret = app_manager_get_app_id (getpid (), &appId);
100- if (ret != APP_MANAGER_ERROR_NONE) {
101- LOG_ERROR (" [PlusPlayer] Fail to get app id: %s." , get_error_message (ret));
98+ if (!SetAppId ()) {
99+ LOG_ERROR (" [PlusPlayer] Fail to set app id" );
102100 return -1 ;
103101 }
104- plusplayer_set_app_id (player_, appId);
105- free (appId);
106-
107102 RegisterListener ();
108103
109104 int64_t drm_type = flutter_common::GetValue (create_message.drm_configs (),
@@ -170,6 +165,23 @@ void PlusPlayer::SetDisplayRoi(int32_t x, int32_t y, int32_t width,
170165 memento_->display_area .height = height;
171166}
172167
168+ bool PlusPlayer::SetAppId () {
169+ char *appId;
170+ int ret = app_manager_get_app_id (getpid (), &appId);
171+ if (ret != APP_MANAGER_ERROR_NONE) {
172+ LOG_ERROR (" [PlusPlayer] Fail to get app id: %s." , get_error_message (ret));
173+ return false ;
174+ }
175+
176+ if (plusplayer_set_app_id (player_, appId) != PLUSPLAYER_ERROR_TYPE_NONE) {
177+ LOG_ERROR (" [PlusPlayer] Fail to set app id" );
178+ free (appId);
179+ return false ;
180+ }
181+ free (appId);
182+ return true ;
183+ }
184+
173185bool PlusPlayer::Play () {
174186 LOG_INFO (" [PlusPlayer] Player starting." );
175187
@@ -184,12 +196,14 @@ bool PlusPlayer::Play() {
184196 LOG_ERROR (" [PlusPlayer] Player fail to start." );
185197 return false ;
186198 }
199+ SendIsPlayingState (true );
187200 return true ;
188201 } else if (state == PLUSPLAYER_STATE_PAUSED) {
189202 if (plusplayer_resume (player_) != PLUSPLAYER_ERROR_TYPE_NONE) {
190203 LOG_ERROR (" [PlusPlayer] Player fail to resume." );
191204 return false ;
192205 }
206+ SendIsPlayingState (true );
193207 return true ;
194208 }
195209 return false ;
@@ -233,7 +247,6 @@ bool PlusPlayer::Pause() {
233247 LOG_ERROR (" [PlusPlayer] Player fail to pause." );
234248 return false ;
235249 }
236-
237250 SendIsPlayingState (false );
238251 return true ;
239252}
@@ -305,7 +318,7 @@ bool PlusPlayer::IsLive() {
305318 }
306319 std::string is_live (value);
307320 free (value);
308- return is_live == " TRUE " ;
321+ return is_live == " 1 " ;
309322}
310323
311324std::pair<int64_t , int64_t > PlusPlayer::GetLiveDuration () {
@@ -799,12 +812,12 @@ bool PlusPlayer::StopAndClose() {
799812 return true ;
800813 }
801814
802- if (! plusplayer_stop (player_)) {
815+ if (plusplayer_stop (player_) != PLUSPLAYER_ERROR_TYPE_NONE ) {
803816 LOG_ERROR (" [PlusPlayer] Player fail to stop." );
804817 return false ;
805818 }
806819
807- if (! plusplayer_close (player_)) {
820+ if (plusplayer_close (player_) != PLUSPLAYER_ERROR_TYPE_NONE ) {
808821 LOG_ERROR (" [PlusPlayer] Player fail to close." );
809822 return false ;
810823 }
@@ -877,7 +890,7 @@ bool PlusPlayer::Suspend() {
877890 return true ;
878891 } else if (player_state != PLUSPLAYER_STATE_PAUSED) {
879892 LOG_INFO (" [PlusPlayer] Player calling pause from suspend." );
880- if (plusplayer_suspend (player_) == false ) {
893+ if (plusplayer_suspend (player_) != PLUSPLAYER_ERROR_TYPE_NONE ) {
881894 LOG_ERROR (
882895 " [PlusPlayer] Suspend fail, in restore player instance would be "
883896 " created newly." );
@@ -932,15 +945,21 @@ bool PlusPlayer::Restore(const CreateMessage *restore_message,
932945 case PLUSPLAYER_STATE_NONE:
933946 return RestorePlayer (restore_message, resume_time);
934947 break ;
935- case PLUSPLAYER_STATE_PAUSED:
936- if (!plusplayer_restore (player_, memento_->state )) {
948+ case PLUSPLAYER_STATE_PAUSED: {
949+ if (plusplayer_restore (player_, memento_->state ) !=
950+ PLUSPLAYER_ERROR_TYPE_NONE) {
937951 if (!StopAndClose ()) {
938952 LOG_ERROR (" [PlusPlayer] Player need to stop and close, but failed." );
939953 return false ;
940954 }
941955 return RestorePlayer (restore_message, resume_time);
942956 }
943- break ;
957+
958+ plusplayer_state_e state = plusplayer_get_state (player_);
959+ if (state == plusplayer_state_e::PLUSPLAYER_STATE_PLAYING) {
960+ SendIsPlayingState (true );
961+ }
962+ } break ;
944963 case PLUSPLAYER_STATE_PLAYING:
945964 // might be the case that widget has called
946965 // restore more than once, just ignore.
@@ -983,7 +1002,8 @@ bool PlusPlayer::RestorePlayer(const CreateMessage *restore_message,
9831002 return false ;
9841003 }
9851004 if (memento_->playing_time > 0 &&
986- !plusplayer_seek (player_, memento_->playing_time )) {
1005+ plusplayer_seek (player_, memento_->playing_time ) !=
1006+ PLUSPLAYER_ERROR_TYPE_NONE) {
9871007 LOG_ERROR (" [PlusPlayer] Fail to seek." );
9881008 }
9891009 SetDisplayRoi (memento_->display_area .x , memento_->display_area .y ,
0 commit comments