Languages

Menu
Sites
Language
FM Radio is stopped when in-app sound is played

Hello, everyone.
I have some sounds in my app. The thing is that when FM Radio is turned on and a sound (which has SOUND_TYPE_RINGTONE) is played with wav_player_start, the FM Radio turns off. I decided not to play sound at all if radio is turned on so radio won't be stopped by system. 
I've tried to to track radio state with code below, but it actually creates another object "radio" which has state "READY". 

    radio_h radio;
    radio_state_e state;
    radio_create(&radio);
    radio_get_state(radio, &state);

    return state;

Could anyone help me to track system radio's state if it's possible?
Thanks.

Responses

2 Replies
Nafisul Islam Kiron

Please try like this

// declare this global
static radio_h radio = NULL;


// Callback function invoked when the radio was interrupted.
static void on_radio_interrupted(radio_interrupted_code_e code, void *user_data)
{
    // Check the current state of the radio.
    radio_state_e state;

    int error_code = radio_get_state(radio, &state);
    if (RADIO_ERROR_NONE != error_code) {
        dlog_print(DLOG_ERROR, LOG_TAG, "radio_get_state() failed! Error: %s (code = %d)",
                   get_error_message(error_code), error_code);
        return;
    }

    if (RADIO_INTERRUPTED_COMPLETED != code) {
        if (RADIO_STATE_PLAYING == state) {
            // Stop playing the radio.
            error_code = wav_player_stop(wav_player_id);
            // Do other stuffs
    		// . . . . . . . .
        }
    }
}

 

Pavel Andreev

Thanks, but this didnt help. callback doesnt work, I guess it is because radio is NULL as it wasn't created by radio_create()