1

When i migrated all my image- and mp3-files from inside myapplication to Firebase then the performance changed alot. Loading mp3-files takes alot of time and it is not because of my internet (i have 200/200mb down/up speed).

Im also using the Glide library to resize my huge images.

This is how i use Glide to place my images to the layout:

Glide.with(getActivity()).load(song.getArtistImg()).into(artistImg); Glide.with(getActivity()).load(song.getArtistImg()).into(artistImgBG);

This is how i retrieve my mp3-file from firebase:

mediaPlayer = MediaPlayer.create(getActivity(), Uri.parse(getSong));

I use my viewmodel to set and get my objects

I've set logs on every step of my code to see exactly where it takes so long to and i found out that when creating my MediaPlayer object it is taking a while. I've searched about it but did not find anything that solved my problem.

How can i increase the time it takes to create the MediaPlayer object?

Delice
  • 743
  • 9
  • 20
  • Do you know for a fact, that Firebase is the bottleneck here? If not, put some prints with timestamps at different parts of your code to see which parts are slow. – Ian Rehwinkel Feb 17 '19 at 19:16
  • As i said - when i had my images inside my app (in my drawable folder) i had zero problems loading my images beside running out of memory and that is why i migrated everything to Firebase. – Delice Feb 17 '19 at 19:19
  • Does this seem relatable: https://stackoverflow.com/questions/39065607 – Ian Rehwinkel Feb 17 '19 at 19:23
  • @IanRehwinkel I edited my post. – Delice Feb 18 '19 at 19:50
  • Hey @Delice, what firebase plan are you on. Also can you take a look at one of the files and let me know the size of the file. Also how are you getting the downloadURL for the file? – Alex Dunlop Feb 18 '19 at 19:55
  • @AlexDunlop Im on the free version of Firebase "Spark". Each one of my mp3-files are between 3mb and 6mb. My mp3-urls are inside my `SharedViewModel` that i call inside my `Fragment`. – Delice Feb 18 '19 at 20:09

1 Answers1

0

I have had a similar problem with my Firebase Storage, I upgraded to the Flame Plan and noticed a little bit of an increase. With 3mb/6mb files you will expect to have a bit of download wait as it's a big file for wifi on a phone. I did some reading a while back to find what the problem for me was and I believe it's because I am in a region isn't no yet optimized for (New Zealand) although I could be wrong.

None the less there is a work around, instead of storing your files in Firebase Storage I suggest you store them Firebase Hosting, on a website with a url. Firebase Hosting has great caching as well. Take a look at hosting here. https://firebase.google.com/docs/hosting/ I suggest you upload the images to a static website, I have done this in the past for images and it worked well!

Alex Dunlop
  • 1,383
  • 15
  • 24