* @brief Prepares the media player for playback, asynchronously.
* @since_tizen @if WEARABLE 2.3.1 @else 2.3 @endif
* @remarks The mediastorage privilege(http://tizen.org/privilege/mediastorage) must be added if any video/audio files are used to play located in the internal storage.
- * @remarks The externalstorage privilege(http://tizen.org/privilege/externalstorage) must be added if any video/audio files are used to play located in the external storage.
- * @remarks The internet privilege(http://tizen.org/privilege/internet) must be added if any URLs are used to play from network.
+ * The externalstorage privilege(http://tizen.org/privilege/externalstorage) must be added if any video/audio files are used to play located in the external storage.
+ * The internet privilege(http://tizen.org/privilege/internet) must be added if any URLs are used to play from network. \n
+ * Since 5.0: To cancel the asynchronous preparing, call player_unprepare() even in #PLAYER_STATE_IDLE state.
* @param[in] player The handle to the media player
* @param[in] callback The callback function to register
* @param[in] user_data The user data to be passed to the callback function
* @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation
* @retval #PLAYER_ERROR_INVALID_STATE Invalid player state
- * @pre The player state must be higher than #PLAYER_STATE_IDLE.
+ * @pre Before 5.0: The player state must be one of: #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, #PLAYER_STATE_PAUSED. \n
+ * @pre Since 5.0: The player state must be one of: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, #PLAYER_STATE_PAUSED.
+ * #PLAYER_STATE_IDLE is allowed only if player preparation was started with player_prepare_async().
* @post The player state will be #PLAYER_STATE_IDLE.
* @see player_prepare()
*/
player_cli_s *pc = (player_cli_s *) player;
char *ret_buf = NULL;
int (*p_disp_evas_display_retrieve_all_packets)(void *, bool) = NULL;
+ player_state_e state = PLAYER_STATE_NONE;
LOGD("ENTER");
- if (!CALLBACK_INFO(pc))
- return PLAYER_ERROR_INVALID_STATE;
+ if (_get_current_state(pc, &state) != PLAYER_ERROR_NONE) {
+ LOGE("Failed to get state");
+ ret = PLAYER_ERROR_INVALID_OPERATION;
+ goto EXIT;
+ }
+
+ if (state < PLAYER_STATE_READY) {
+ if ((!CALLBACK_INFO(pc)) || (!CALLBACK_INFO(pc)->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE])) {
+ LOGE("Invalid state %d", state);
+ ret = PLAYER_ERROR_INVALID_STATE;
+ goto EXIT;
+ }
+ }
+
+ set_null_user_cb_lock(pc->cb_info, MUSE_PLAYER_EVENT_TYPE_SEEK);
+ set_null_user_cb_lock(pc->cb_info, MUSE_PLAYER_EVENT_TYPE_PREPARE);
#ifdef TIZEN_FEATURE_EVAS_RENDERER
if (EVAS_INFO(pc)->support_video && EVAS_HANDLE(pc)) {
PLAYER_SEND_MSG(api, pc, ret_buf, ret);
- set_null_user_cb_lock(pc->cb_info, MUSE_PLAYER_EVENT_TYPE_SEEK);
- set_null_user_cb_lock(pc->cb_info, MUSE_PLAYER_EVENT_TYPE_PREPARE);
_player_release_internal_memory(pc, false);
-
pc->cb_info->video_frame_pool_size = 0;
__player_remove_tsurf_list(pc);
pc->is_audio_only = FALSE;
g_free(ret_buf);
+EXIT:
LOGD("LEAVE 0x%X", ret);
return ret;
}