From: bhutani.92 Date: Tue, 4 Oct 2016 09:36:47 +0000 (+0530) Subject: Multitasking feature X-Git-Tag: submit/tizen_mobile/20161009.144732~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F09%2F90809%2F4;p=profile%2Fmobile%2Fapps%2Fnative%2Fmusic-player.git Multitasking feature Change-Id: I3bed2cd21ecd5a31c9e9e5b5fbd06f18a6c3ebfe Signed-off-by: bhutani.92 --- diff --git a/src/core/mp-player-mgr.c b/src/core/mp-player-mgr.c index 610959d..7a0024c 100755 --- a/src/core/mp-player-mgr.c +++ b/src/core/mp-player-mgr.c @@ -24,6 +24,7 @@ #include "mp-play.h" /* #include "mp-player-drm.h" */ #include +#include #include "mp-ta.h" #include "mp-player-debug.h" @@ -860,7 +861,8 @@ mp_player_mgr_resume(void *data) startfunc; struct appdata *ad = data; MP_CHECK_FALSE(ad); - int err = -1,error = -1; + int err = -1; + int error = SOUND_MANAGER_ERROR_NONE; sound_stream_focus_state_e state_for_playback; sound_stream_focus_state_e state_for_recording; int ret = -1; @@ -1151,26 +1153,33 @@ void mp_player_focus_callback(sound_stream_info_h stream_info, sound_stream_focu sound_stream_focus_state_e state_for_playback; sound_stream_focus_state_e state_for_recording; - int ret = -1; + int ret = SOUND_MANAGER_ERROR_INVALID_PARAMETER; ret = sound_manager_get_focus_state(ad->stream_info, &state_for_playback, &state_for_recording); if(ret != SOUND_MANAGER_ERROR_NONE) { ERROR_TRACE("failed in sound_manager_get_focus_state"); } + + int req_flag = SOUND_BEHAVIOR_NONE; + sound_manager_focus_get_requested_behavior(ad->stream_info, &req_flag); + if (state_for_playback == SOUND_STREAM_FOCUS_STATE_RELEASED) { mp_player_mgr_pause(ad); + sound_manager_get_focus_reacquisition(ad->stream_info, &reacquire_state); DEBUG_TRACE("reason for change is %d", reason_for_change); if (reason_for_change != SOUND_STREAM_FOCUS_CHANGED_BY_ALARM && - reason_for_change != SOUND_STREAM_FOCUS_CHANGED_BY_NOTIFICATION) { - sound_manager_get_focus_reacquisition(ad->stream_info, &reacquire_state); + reason_for_change != SOUND_STREAM_FOCUS_CHANGED_BY_NOTIFICATION && + reason_for_change == SOUND_STREAM_FOCUS_CHANGED_BY_RINGTONE && + reason_for_change == SOUND_STREAM_FOCUS_CHANGED_BY_VOIP && + reason_for_change == SOUND_STREAM_FOCUS_CHANGED_BY_CALL) { if (!strcmp(additional_info, "cam_capture")) { sound_manager_set_focus_reacquisition(ad->stream_info, EINA_TRUE); - } else if ((reason_for_change == SOUND_STREAM_FOCUS_CHANGED_BY_RINGTONE) || (reason_for_change == SOUND_STREAM_FOCUS_CHANGED_BY_VOIP) || (reason_for_change == SOUND_STREAM_FOCUS_CHANGED_BY_CALL)) { - sound_manager_set_focus_reacquisition(ad->stream_info, EINA_TRUE); } else if (reacquire_state == EINA_TRUE) { sound_manager_set_focus_reacquisition(ad->stream_info, EINA_FALSE); } + } else if (req_flag & SOUND_BEHAVIOR_NO_RESUME) { + sound_manager_set_focus_reacquisition(ad->stream_info, EINA_FALSE); } } else { mp_play_control_play_pause(ad, true); diff --git a/src/include/music.h b/src/include/music.h index 3996922..87e4a30 100755 --- a/src/include/music.h +++ b/src/include/music.h @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -256,6 +257,11 @@ struct appdata unsigned int caller_win_id; #endif + /* For recorder API's */ + int recorder_id; + recorder_type_e recorder_type; + recorder_device_state_e recorder_state; + /* Layout for each view */ Evas_Object *conformant; Evas_Object *naviframe; diff --git a/src/mp-main.c b/src/mp-main.c index fe5f1df..cc7d778 100755 --- a/src/mp-main.c +++ b/src/mp-main.c @@ -126,6 +126,13 @@ _mp_main_exit_cb(void *data, Evas_Object * obj, void *event_info) mp_app_exit(data); } +void mp_recorder_state_cb(recorder_type_e type, recorder_device_state_e state, void *user_data) +{ + struct appdata *ad = (struct appdata *)user_data; + ad->recorder_state = state; + ad->recorder_type = type; +} + static bool _mp_main_init(struct appdata *ad) { @@ -133,6 +140,14 @@ _mp_main_init(struct appdata *ad) ad->paused_by_user = true; mp_media_info_connect(); + int state = RECORDER_DEVICE_STATE_IDLE; + recorder_get_device_state(RECORDER_TYPE_VIDEO, &state); + DEBUG_TRACE("Recorder state: %d", state); + + int ret = recorder_add_device_state_changed_cb(mp_recorder_state_cb, ad, &ad->recorder_id); + if (ret != RECORDER_ERROR_NONE) { + ERROR_TRACE("Unable to register callback for recorder state"); + } /* window focus in/out event */ evas_object_smart_callback_add(ad->win_main, "focused", _mp_main_win_focus_in_cb, ad); @@ -1336,6 +1351,11 @@ mp_terminate(void *data) mp_volume_finalize(); + int ret = recorder_remove_device_state_changed_cb(ad->recorder_id); + if (ret != RECORDER_ERROR_NONE) { + ERROR_TRACE("Unable to remove callback for recorder state"); + } + if(ad->stream_info) { int error = sound_manager_destroy_stream_information(ad->stream_info); if (error != SOUND_MANAGER_ERROR_NONE) { diff --git a/src/widget/mp-minicontroller.c b/src/widget/mp-minicontroller.c index 0ab9934..72bddab 100755 --- a/src/widget/mp-minicontroller.c +++ b/src/widget/mp-minicontroller.c @@ -29,6 +29,7 @@ #include "mp-player-view.h" #include #include +#include #define MINI_CONTROLLER_HEIGHT (93) #define WL_INDI_H 27 //Window Layout Indicator Height @@ -572,7 +573,6 @@ static void _mp_minicontroller_update_btn(struct appdata *ad) } else { elm_object_signal_emit(ad->minicontroller_layout, "set_play", "c_source"); } - } static Eina_Bool @@ -651,6 +651,11 @@ static void _mp_minicontroller_play_pause_btn_clicked_cb(void *data, Evas_Object struct appdata *ad = mp_util_get_appdata(); MP_CHECK(ad); + if (ad->recorder_state == RECORDER_DEVICE_STATE_RECORDING) { + DEBUG_TRACE("Cannot resume Music Player. Video Recorder is in Use"); + return; + } + if (ad->player_state == PLAY_STATE_PLAYING) { mp_play_control_play_pause(ad, false); } else { diff --git a/tizen-manifest.xml b/tizen-manifest.xml index af836cb..548414e 100644 --- a/tizen-manifest.xml +++ b/tizen-manifest.xml @@ -1,72 +1,73 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - org.tizen.music-player.png - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.tizen.music-player.png + - http://tizen.org/privilege/network.get http://tizen.org/privilege/mediastorage - http://tizen.org/privilege/notification - http://tizen.org/privilege/externalstorage.appdata - http://tizen.org/privilege/content.write - http://tizen.org/privilege/appmanager.launch http://tizen.org/privilege/telephony - http://tizen.org/privilege/display + http://tizen.org/privilege/network.get + http://tizen.org/privilege/appmanager.launch http://tizen.org/privilege/volume.set + http://tizen.org/privilege/notification + http://tizen.org/privilege/display + http://tizen.org/privilege/externalstorage.appdata + http://tizen.org/privilege/recorder http://tizen.org/privilege/externalstorage + http://tizen.org/privilege/content.write