Languages

Menu
Sites
Language
FMedialPlayer incorrect state at ENDOFCLIP (Bug?)

Hi,

I'm using MediaPlayer to play some audio files and I'm getting an unusual error when I attemp to stop a player in the PLAYER_STATE_ENDOFCLIP state. When I call the Stop() function the player believe that it is in state 2 (PLAYER_STATE_OPENED)

The code look something like this:

void TizenMediaPlayer::OnPlayerEndOfClip(void) {
    Stop();
}

void TizenMediaPlayer::Stop(void) {
    AppLog("Before Stop. State %d", mPlayer.GetState());
    mPlayer.Stop();
    AppLog("After Stop. State %d", mPlayer.GetState());
    mPlayer.Close();
    AppLog("After Close. State %d", mPlayer.GetState());
}

 

The output looks like this:

void TizenMediaPlayer::Stop()(264) > Before Stop. State 3
result Tizen::Media::_PlayerImpl::Stop()(875) > [E_INVALID_STATE] Player state is in an invalid state. State is 2
result Tizen::Media::Player::Stop()(224) > [E_INVALID_STATE] Failed to perform Stop operation.
void TizenMediaPlayer::Stop()(266) > After Stop. State 3
void TizenMediaPlayer::Stop()(268) > After Close. State 7

As you can see I check the state right before calling stop and it confirms it's in state 3 (PLAYER_STATE_ENDOFCLIP) but during the Stop operation it throw and error indicating that the state is 2 (PLAYER_STATE_OPENED).

Is this a bug in the API or am I missing something?

Thanks

 

 

Responses

6 Replies
Stefano Zanetti

I found another place in the code where the state value is inconsistent. The code looks like this:

 

PlayerState pState = mPlayer.GetState();
if (pState == PLAYER_STATE_OPENED || pState == PLAYER_STATE_PLAYING || pState == PLAYER_STATE_PAUSED || pState == PLAYER_STATE_STOPPED) {
        AppLog("before get duration player state is %d", pState);
        dur = mPlayer.GetDuration();
        AppLog("after get duration player state is %d", pState);

 

And the output looks like this:

void TizenMediaPlayer::get_play_position(int &, double &, double &)(161) > before get duration player state is 6
long int Tizen::Media::_PlayerImpl::GetDuration()(1002) > [E_INVALID_STATE] Player state is in an invalid state. State is 3
void TizenMediaPlayer::get_play_position(int &, double &, double &)(165) > after get duration player state is 6

 

Is there more than one internal state to the player? 

 

hgw7

Hi,
As the player would've already stopped on EndOfClip, it can be closed directly. Please refer the Figure "Player state changes" in the link given below that shows the possible state transitions for Player: 

https://developer.tizen.org/help/index.jsp?topic=%2Forg.tizen.native.appprogramming%2Fhtml%2Fguide%2Fmedia%2Fplaying_audio.htm

To get clip duration, player reaches end of clip. Please check the table containing methods for state changes in the following link:    

https://developer.tizen.org/help/index.jsp?topic=%2Forg.tizen.native.appprogramming%2Fhtml%2Fguide%2Fmedia%2Fplaying_audio.htm

Stefano Zanetti

Thanks for the suggestions hgw7.

 

The major problem tho is the fact that I cannot read the correct state of the player using GetState. As you can see in the the second code example when I call GetState it returns 6 which is PLAYING. Whilst in reality the player state is ENDOFCLIP and to me this looks like a bug.

 

On a slightly different note the documentation about the GetDuration is inconsistent between these two references as the first reference indicate that PLAYER_STATE_OPENED is also a valid state for GetDuration. It would be nice to fix the incorrect one to avoid confusion.

https://developer.tizen.org/help/index.jsp?topic=%2Forg.tizen.native.apireference%2FclassTizen_1_1Media_1_1Player.html

https://developer.tizen.org/help/index.jsp?topic=%2Forg.tizen.native.appprogramming%2Fhtml%2Fguide%2Fmedia%2Faudio_video_player_state.htm

 

Thanks

Sergei Melikhov

Hi Stefano,

Try after:

       m_player.Construct    ( *this );

set:

       m_player.Stop ();
       m_player.Close ();

 

hgw7

Hi Stefano Zanetti,

When you are playing the file, and as shown in the log, the state is same(6) before and after the GetDuration(). The transition to EndOfClip is probably the internal implementation to get the last position value(for obtaining duration).