Speeding up firebase storage download - java

I am trying to pull videos from firebase storage and put them into a slideshow on my Android app but the videos take so long to load. Does anyone have any alternatives or ways to speed up the data download?

You can store your files in the Regional Storage, such as us-east1.
Please refer to https://cloud.google.com/storage/docs/bucket-locations and change your bucket's region to most closest place to you.

One thing you can do is split your video in smaller chunks when you are uploading
then download chunks one by one as slideshow plays.
It is a good idea because by this way you or your user don't have to wait for whole file. you can start playing videos as soon as your first chunk is available and then continue downloading next one's in background.
When you chunk video files, you reduce the risk of timeouts. If a small chunk fails to download for whatever reason, you can automatically retry only that chunk, instead of having to restart the entire download.
and yes when firebase is downloading it will do chucking but it'll be random and not much useful to you now because firebase'll do it for download and it'll signal you when file is fully downloaded to play.
Every streaming service does this. even though multithread downloaders also do the same.
you can google to find optimal chunk size and more about it.
I just googled and it looks good.
https://www.limelight.com/blog/multiple-solutions-for-low-latency-live-video-streaming/

Related

(Java - Android) How do I smoothly unpack songs and play them on my Android app?

I am completely new to Android studio, but I would really like to create a music player that plays downloaded songs on android. My problem is that if I have a lot of songs they use up a lot of space and my question is if there is a way to compress the files in a way that they use up less space, but still get unpacked fast enough to not cause big lags between one song and the other.
The idea behind this is that when a song is selected it gets unpacked, then gets played and when it finishes it gets packed again. I don't know if that's the best way to do it, and if you have a better idea please let me know.
This is not possible. MP3 files (mentioned in tag) are already effectively compressed. The only way to make it significantly smaller is to re-encode it with lower bitrate which would be lossy compression. It would seem that external storage/hosting and loading the necessary files on the go is the only way to save device storage. To have no lag, keep "one song in advance from the playlist".

Android security for images

I am developing an app which is a graphical book. Every week, a new chapter is being released and the app will be updated. There are basically images that are going to be shown to the user as slides. The user can subscribe and all chapters will be visible to the user (the image sources are offline and embedded inside the APK file). The images are not saved into the internal SD card (like they are not shown in the phone gallery after installing the app).
I am afraid that it is not a safe way to show the content to the users. What if someone just extracts all the images? I am thinking of the solutions below. Please give me the best option to keep my image files secured.
Obfuscating the app (I'm not sure if this works in this case. I know obfuscating helps to change the codes but I'm not sure if it helps to encrypt the images)
Using an online server and let subscribed users download the images (I think this way it might be saved inside the external storage. Anyway after the download the images must be available offline)
Should I encrypt the images by an encryption method?
Let's explore your options one by one
If you obfuscate the app, it can be deobfuscated
If you use an online server, the images will be downloaded, you can manage to store the downloaded images into the memory instead of the disk and then show directly from memory.
If you encrypt the images, you need to have some decryption method/key implemented in the app, which can be retrieved and bingo,
the user can have decrypted images.
So if downloading the images from an online service will not break your business requirement, then go ahead with that.
Remember that, in any of the cases, if one is determined to save the images, he/she can.
You may need to have multiple methods in place to make it harder for those, seeking to save it.

android playlist, storing mp3 file in the app or calling url

i'm actually adding a music player in my android app. It will contains 8 albums, 12songs in each one. So i'm thinking about the best way to do this. Should i store the mp3 songs in the app, which will make there lecture faster and won't need access to internet. Or maybe it's too much heavy and calling mp3 url would be a better idea?
Thank you
There are a few things to consider when evaluating your options.
If you ship the songs together with the app, you will greatly increase it's size. Most probably you will go over the 50 Mb limit, and you will have to implement APK expansion files, which are downloaded when the app is first started. Implementing this is not very hard, but it can take some time.
If you implement a custom download for the songs, you can optionally provide better control over what is downloaded, optimizing bandwidth usage, download times, etc. Still, it would be more difficult to implement then the standard APK expansions, and you will have to deal with a lot of additional download logic - pausing / resuming, dealing with insufficient storage space, etc.
My advice is to go with an APK expansion, which is downloaded when the app is first started and will manage all the download complexity out of the box. If you need a more fine grained download - go custom.
Good luck.

Android best practice - download pictures

How would you approach this problem:
My app should download different packages of pictures (containing up to 300 pngs, each about 20 kb) and store the pictures on the phone, so i can display them.
I want to upload the pictures somewhere online, so I can change them every time and the user can enjoy the newest pictures. (I upload the pictures not with the app)
I read that storing them in a sqlite db isn't the best option.
At the moment I am storing the pictures in the app, but then I don't know how I can upload and replace pictures on all apps immediately without the need of updating the whole app.
I don't need code or stuff, so don't waste your precious time on that, just some general hints where and how you would store the pictures online, and how android can download the pictures easily.
Take a look at the Glide or Picasso libraries. Those are super easy to use for thread-safe downloading of images.
Personally, I just fetch/store the images on imgur.
If you want to upload a dedicated databse, you'll have to set one up. Some common ones are Amazon, Google, etc. There are tons.
Have a look at this answer. In this answer Picasso library is used to handle image download. Picasso gets rid of a lot of coding and testing to handle image download.
In a project that I am working on, we use Amazon S3 to store our pictures, it's very reliable and is one of the goto solutions right now.
From what I heard Snapchat and some other big firms use S3 to store their picture!
It's also very cheap, plus I believe they have free hosting to a certain degree.
This is their API guide for android.
We use a service called File Picker to handle upload and download from amazonS3, it reduces a lot of work, but I don't think it's a free service.
You can use Picasso for downloading images from network in Android. For storing images Amazon S3 or Google cloud storage can be your options.
Not sure if downloading packages is better than downloading individual pictures (archiving won't save you much space).
As for your question, you can make some kind of API you will query from your app, even a flat file hosted somewhere with changing content would work. Your app could check it periodically for the new address to download pictures from (assuming it will change).
another way is using push messages - sending out a push through GCM that your apps will receive that will notify them about new content available. It would even work when the app is closed.

Android (or iOS) - Image Upload Queue

We've written an app for Android (and iOS), and it allows users to upload photos to our REST server. The issue we're hitting is that sometimes the users are in places with terrible cell signal and no WIFI. So, I was wondering if there was either a prebuilt solution, or a recommended path to take to defer these uploads until later if there are only lackluster network options available.
Right now on Android I'm using an AsyncTask to upload a stream representation of a captured image. The image's maximum dimension is cropped to 1280, and the other is aspect scaled, so the images aren't massive.
The user may have no signal for up to 2 hours I imagine, so it'd not need to attempt to upload every minute. Additionally, there may be multiple uploads, so some kind of queue is needed, I think.
I'm not positive what the iOS app is leveraging, but I can find out if it helps.
The best option would be to save the photo to the SD card and put the path to it in a database. The database here acts like a queue. So whenever the user has access to internet, the app can check whether there are any entries in the database and start uploading. Once you upload the photo, you delete that record from the database.
Now, as far as the upload is concerned, I recommend doing it in a Service as opposed to an AsyncTask. This way you can use an AlarmManager to call the service at periodic intervals and check whether there is anything to upload.
I used this method in one of my applications but for documents. It works like a charm. Hope that helped.
In iOS I used ASIHTTPRequest, but at the moment you can find other solutions (MKNetworkKit). I did an application exactly like what you are doing so what I did was:
Check if there is internet, if yes continue, otherwise stop.
Try to send one photo, if succeed go to the next one, otherwise leave the photo on the queue and go to the next photo.
Repeat process.
Let's imagine the user putted 20 photos on the queue, and start the process, at the end of the day he could check again what succeed and what didn't. Of course he could re-send what failed in the first place.

Categories

Resources