Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gapless Audio #283

Closed
Eng-Fouad opened this issue Apr 10, 2013 · 9 comments
Closed

gapless Audio #283

Eng-Fouad opened this issue Apr 10, 2013 · 9 comments

Comments

@Eng-Fouad
Copy link

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~

@ahmedre
Copy link
Contributor

ahmedre commented Apr 10, 2013

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.

@Eng-Fouad
Copy link
Author

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.

@ahmedre
Copy link
Contributor

ahmedre commented Apr 10, 2013

  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).

@ozbek
Copy link
Contributor

ozbek commented Dec 13, 2016

Possible duplicate of #231

@vipafattal
Copy link

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.

@ozbek
Copy link
Contributor

ozbek commented Jul 11, 2019

Wa alaikum assalam @vipafattal.

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

Please send PR.

@ahmedre
Copy link
Contributor

ahmedre commented Jul 12, 2019

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.

@vipafattal
Copy link

vipafattal commented Aug 18, 2019

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

@ahmedre
Copy link
Contributor

ahmedre commented Mar 26, 2020

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.

@ahmedre ahmedre closed this as completed Mar 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants