#endif
}
break;
+ case MM_MESSAGE_PLAY_POSITION:
+ LOGI("MM_MESSAGE_PLAY_POSITION (%d ms)", msg->time.elapsed);
+ handle->last_play_position = (int)msg->time.elapsed;
+ break;
case MM_MESSAGE_UNKNOWN: /* 0x00 */
case MM_MESSAGE_WARNING: /* 0x02 */
case MM_MESSAGE_CONNECTING: /* 0x100 */
int legacy_player_prepare_async(player_h player, player_prepared_cb callback, void *user_data)
{
+ int ret = MM_ERROR_NONE;
+ int visible = 0;
+ int value = 0;
+
LOGI("[%s] Start", __FUNCTION__);
PLAYER_INSTANCE_CHECK(player);
player_s *handle = (player_s *)player;
PLAYER_TRACE_ASYNC_BEGIN("MM:PLAYER:PREPARE_ASYNC", *(int *)handle);
PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
- int ret;
- int visible;
- int value;
-
+ handle->last_play_position = 0;
if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE]) {
LOGE("[%s] PLAYER_ERROR_INVALID_OPERATION (0x%08x) : preparing... we can't do any more ", __FUNCTION__, PLAYER_ERROR_INVALID_OPERATION);
return PLAYER_ERROR_INVALID_OPERATION;
int legacy_player_prepare(player_h player)
{
+ int ret = MM_ERROR_NONE;
+ int visible = 0;
+ int value = 0;
+
LOGI("[%s] Start", __FUNCTION__);
PLAYER_TRACE_BEGIN("MM:PLAYER:PREPARE");
PLAYER_INSTANCE_CHECK(player);
player_s *handle = (player_s *)player;
PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
- int ret;
- int visible;
- int value;
+ handle->last_play_position = 0;
ret = mm_player_set_message_callback(handle->mm_handle, __msg_callback, (void *)handle);
if (ret != MM_ERROR_NONE)
LOGW("[%s] Failed to set message callback function (0x%x)", __FUNCTION__, ret);
int legacy_player_get_play_position(player_h player, int *millisecond)
{
+ unsigned long pos = 0;
+
PLAYER_INSTANCE_CHECK(player);
PLAYER_NULL_ARG_CHECK(millisecond);
player_s *handle = (player_s *)player;
- if (!__player_state_validate(handle, PLAYER_STATE_READY)) {
+ if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) {
LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d", __FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state);
return PLAYER_ERROR_INVALID_STATE;
}
- unsigned long pos;
+
+ /* During playbak if a interrupt is occurred, the player can be destroyed internally.
+ libmm-player will post position msg with last playback position before destory pipeline */
+ if (handle->state == PLAYER_STATE_IDLE) {
+ if (handle->last_play_position > 0)
+ *millisecond = handle->last_play_position;
+ else
+ *millisecond = 0;
+ LOGD("position %d", *millisecond);
+ return PLAYER_ERROR_NONE;
+ }
+
int ret = mm_player_get_position(handle->mm_handle, MM_PLAYER_POS_FORMAT_TIME, &pos);
if (ret != MM_ERROR_NONE) {
return __player_convert_error_code(ret, (char *)__FUNCTION__);