Quran_android: gapless Audio

Created on 10 Apr 2013  Â·  9Comments  Â·  Source: quran/quran_android

Salam Alaikum,

The app is just impressive, may Allah bless you. I was just wondering why don't make all "التلاوات" to be gapless? Here is one way I am thinking of you can use to implement such feature:

  • When "التلاوة" starts, let the background threads to download the next 3 Ayahs.
  • When "التلاوة" reaches 3rd ayah for example, the background threads is permitted to download until Ayah 6. and so on.
  • You could maintain a queue of Ayah instances, and let the audio manager to pick-up ayahs from that queue. It's simple producer/consumer operation.

I am a Java developer and I can help in this part. Here is my twitter account: @EngineerFouad

Best Regards~

Minor Suggestions

Most helpful comment

today, all except 5 qaris are gapless. likely makes more sense to gapless those qaris instead at this point and remove gapped support completely.

i also have a branch that switches to exoplayer (as of the end of December 2019), though I didn’t plug any special transitioning logic for gapped audio into it. can consider pushing that as the primary player in the future in sha’ Allah.

All 9 comments

wa3laikum alsalam,
jazakAllah khairan. the download isn't the issue since "downloading" is the default mode (which means that all the files will be downloaded before we start streaming).

i think someone gave us a similar solution to what you suggested, but we didn't use it because in general, the MediaPlayer objects are fairly heavy. the solution i wanted to implement is to use setNextMediaPlayer methods in MediaPlayer, which was introduced as of api level 16.

so i think we should go with this approach insha'Allah since it's simpler and lighter weight.
walsalam 3alaikum.

Thanks for quick reply. First of all, I am not familiar with setNextMediaPlayer() in API 16 but I think it needs a data source which is the file of the next ayah, which is needed to be exist at the time of calling setNextMediaPlayer(). Second, can you use setNextMediaPlayer() while the app is running at level API 8?

Finally, as you said that the files are downloaded before streaming them, thus no concerns needed regarding the RAM since we deal with files only. In other words, the queue would contain instances of a wrapper class that holds information about the Ayah and the file path. You would only use one instance of MediaPlayer.

Thanks.

  1. yes, that shouldn't be a problem.
  2. yes, but it will only work on api level 16+.

i don't think a lot of processing is happening - the reason for the space (i think) is due to MediaPlayer itself and how it swaps out the files (since at that point, the file is already downloaded, so in theory, it should be very quick to start playing it, especially when not on an external-sdcard).

Possible duplicate of #231

Salam Alaikum,
I'm impressed by the work that has been done on the app.
I just want to suggest to use Exoplayer in order to get gapless audio it's really an advanced audio framework, I built Quran app inspired by Quran Android that uses Exoplayer to play multiple Ayat. The gape's almost not noticeable in recitation. I'll put a link to test the app, just click on Aya number in the app and press play button.
https://drive.google.com/file/d/1auO-B9aMJlSWd846CylRg9G-ciRnO1u0/view?usp=sharing

I can give the link to the app repository on GitHub if liked the result.

Thanks for your efforts.

Wa alaikum assalam @vipafattal.

Sounds like an awesome upgrade. Tested with "Maher Al Muaiqly", gaps are handled more graciously.

Please send PR.

wa3laikum alsalam,
masha'Allah this is awesome - if you have time to work on a PR, please feel free, otherwise in sha' Allah will try to do this.
walsalam 3alaikum.

Gald you liked it!
I'm really sorry, but currently, I don't have time to manage to create PR.
Anyway, I have decided to make Musahf open source here is a link to the repository:
Musahf
See how I managed to create a media source for every reciter link for streaming play on offline from file play MediaSourceBuilder.kt then I'm passing the created media source in ReciterPlayer.kt (see 'onDownloadingCompleted' function) to ReadQuranActivity.kt.

Helpful links to Exoplayer:
Google codelab
Google Exolpayer Pub on medium

today, all except 5 qaris are gapless. likely makes more sense to gapless those qaris instead at this point and remove gapped support completely.

i also have a branch that switches to exoplayer (as of the end of December 2019), though I didn’t plug any special transitioning logic for gapped audio into it. can consider pushing that as the primary player in the future in sha’ Allah.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mgalaleldin picture mgalaleldin  Â·  3Comments

ahmedre picture ahmedre  Â·  7Comments

ahmedre picture ahmedre  Â·  9Comments

habibr picture habibr  Â·  12Comments

MahmoudMabrok picture MahmoudMabrok  Â·  4Comments