Search in sources :

Example 1 with AudioRequest

use of com.quran.labs.androidquran.dao.audio.AudioRequest in project quran_android by quran.

the class PagerActivity method updatePlayOptions.

public boolean updatePlayOptions(int rangeRepeat, int verseRepeat, boolean enforceRange) {
    if (lastAudioRequest != null) {
        final AudioRequest updatedAudioRequest = new AudioRequest(lastAudioRequest.getStart(), lastAudioRequest.getEnd(), lastAudioRequest.getQari(), verseRepeat, rangeRepeat, enforceRange, lastAudioRequest.getShouldStream(), lastAudioRequest.getAudioPathInfo());
        Intent i = new Intent(this, AudioService.class);
        i.setAction(AudioService.ACTION_UPDATE_REPEAT);
        i.putExtra(AudioService.EXTRA_PLAY_INFO, updatedAudioRequest);
        startService(i);
        lastAudioRequest = updatedAudioRequest;
        audioStatusBar.setRepeatCount(verseRepeat);
        return true;
    } else {
        return false;
    }
}
Also used : AudioRequest(com.quran.labs.androidquran.dao.audio.AudioRequest) Intent(android.content.Intent)

Example 2 with AudioRequest

use of com.quran.labs.androidquran.dao.audio.AudioRequest in project quran_android by quran.

the class PagerActivity method setRepeatCount.

@Override
public void setRepeatCount(int repeatCount) {
    if (lastAudioRequest != null) {
        final AudioRequest updatedAudioRequest = new AudioRequest(lastAudioRequest.getStart(), lastAudioRequest.getEnd(), lastAudioRequest.getQari(), repeatCount, lastAudioRequest.getRangeRepeatInfo(), lastAudioRequest.getEnforceBounds(), lastAudioRequest.getShouldStream(), lastAudioRequest.getAudioPathInfo());
        Intent i = new Intent(this, AudioService.class);
        i.setAction(AudioService.ACTION_UPDATE_REPEAT);
        i.putExtra(AudioService.EXTRA_PLAY_INFO, updatedAudioRequest);
        startService(i);
        lastAudioRequest = updatedAudioRequest;
    }
}
Also used : AudioRequest(com.quran.labs.androidquran.dao.audio.AudioRequest) Intent(android.content.Intent)

Example 3 with AudioRequest

use of com.quran.labs.androidquran.dao.audio.AudioRequest in project quran_android by quran.

the class AudioService method handleIntent.

private void handleIntent(Intent intent) {
    final String action = intent.getAction();
    if (ACTION_CONNECT.equals(action)) {
        if (State.Stopped == state) {
            processStopRequest(true);
        } else {
            int sura = -1;
            int ayah = -1;
            int repeatCount = -200;
            int state = AudioUpdateIntent.PLAYING;
            if (State.Paused == this.state) {
                state = AudioUpdateIntent.PAUSED;
            }
            if (audioQueue != null && audioRequest != null) {
                sura = audioQueue.getCurrentSura();
                ayah = audioQueue.getCurrentAyah();
                repeatCount = audioRequest.getRepeatInfo();
            }
            Intent updateIntent = new Intent(AudioUpdateIntent.INTENT_NAME);
            updateIntent.putExtra(AudioUpdateIntent.STATUS, state);
            updateIntent.putExtra(AudioUpdateIntent.SURA, sura);
            updateIntent.putExtra(AudioUpdateIntent.AYAH, ayah);
            updateIntent.putExtra(AudioUpdateIntent.REPEAT_COUNT, repeatCount);
            updateIntent.putExtra(AudioUpdateIntent.REQUEST, audioRequest);
            broadcastManager.sendBroadcast(updateIntent);
        }
    } else if (ACTION_PLAYBACK.equals(action)) {
        AudioRequest playInfo = intent.getParcelableExtra(EXTRA_PLAY_INFO);
        if (playInfo != null) {
            audioRequest = playInfo;
            final SuraAyah start = audioRequest.getStart();
            audioEventPresenter.onAyahPlayback(start);
            final boolean basmallah = !playInfo.isGapless() && SuraAyahExtensionKt.requiresBasmallah(start);
            audioQueue = new AudioQueue(quranInfo, audioRequest, new AudioPlaybackInfo(start, 1, 1, basmallah));
            Timber.d("audio request has changed...");
            if (player != null) {
                player.stop();
            }
            state = State.Stopped;
            Timber.d("stop if playing...");
        }
        processTogglePlaybackRequest();
    } else if (ACTION_PLAY.equals(action)) {
        processPlayRequest();
    } else if (ACTION_PAUSE.equals(action)) {
        processPauseRequest();
    } else if (ACTION_SKIP.equals(action)) {
        processSkipRequest();
    } else if (ACTION_STOP.equals(action)) {
        processStopRequest();
    } else if (ACTION_REWIND.equals(action)) {
        processRewindRequest();
    } else if (ACTION_UPDATE_REPEAT.equals(action)) {
        final AudioRequest playInfo = intent.getParcelableExtra(EXTRA_PLAY_INFO);
        if (playInfo != null && audioQueue != null) {
            audioQueue = audioQueue.withUpdatedAudioRequest(playInfo);
            audioRequest = playInfo;
        }
    } else {
        MediaButtonReceiver.handleIntent(mediaSession, intent);
    }
}
Also used : AudioRequest(com.quran.labs.androidquran.dao.audio.AudioRequest) AudioPlaybackInfo(com.quran.labs.androidquran.dao.audio.AudioPlaybackInfo) SuraAyah(com.quran.data.model.SuraAyah) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) AudioQueue(com.quran.labs.androidquran.presenter.audio.service.AudioQueue)

Aggregations

Intent (android.content.Intent)3 AudioRequest (com.quran.labs.androidquran.dao.audio.AudioRequest)3 PendingIntent (android.app.PendingIntent)1 SuraAyah (com.quran.data.model.SuraAyah)1 AudioPlaybackInfo (com.quran.labs.androidquran.dao.audio.AudioPlaybackInfo)1 AudioQueue (com.quran.labs.androidquran.presenter.audio.service.AudioQueue)1