I'm building a Flutter app that plays audio files. I have hundreds of audio files that are too large to store in the app. So, I want to host the files, then stream them to the device.
I'm using the just_audio package (https://pub.dev/packages/just_audio). I've tested my code using the following hosted audio file and it works... (https://www.learningcontainer.com/wp-content/uploads/2020/02/Kalimba.mp3)
However, when I try to play my own audio files from Google Storage it doesn't work. Google gives me a storage location that looks like this (gs://myappname.appspot.com/audio_file.WAV)
So I guess I have two questions.
Is it possible to stream audio files from Google Storage to an iOS or Android app? If so, what am I not doing right? Or should I be using another Google service for this?
If this is not possible, how do apps like Headspace or Calm host and then stream their audio files?
Any advice would be greatly appreciated.
In an attempt to be thorough, here are the rules for my google storage account...
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
// allow access for all users
allow read, write;
}
}
}
I solved this. I was using the wrong address in Google Storage.
Google Storage gives a "storage location" which is the gs:// address I was using. It also gives a download link that I missed.
By using the download link, I solved my problem.
Related
This is the code for taking the image, and the logcat error. I suspect there is problem with the permissions in phone. By default the application shows no permissions in phone. Is there a way to give permissions explicitly through the code?
logcat error message
code used for taking image input
I checked permissions on phone, I am developing this project by seeing an older video in youtube. So there is a chance of updation problem.
There isn't any issue with your application or device.
You haven't set proper permission on firebase storage.
Firebase storage requires user to be authenticated.
But if you are just testing Storage you can by-pass that rule.
In the Storage > Rules, add below code block,
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read, write: if request.auth == null;
}
}
}
Note:
It's good practice to protect the firebase storage with authentication. So after testing storage feature, please update rules accordingly.
I'm developing android app that recording voice and upload to google drive.
The simple solution is to save recording file to the local cache directory and then upload that file to google drive using google drive api.
But I want to upload recording file to google drive directly not saving into local cache directory.
Like this
recorder = MediaRecorder()
.apply {
setAudioSource(MediaRecorder.AudioSource.MIC)
setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP)
setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB)
setOutputFile('googleDrivePath')
prepare()
}
recorder?.start()
But I don't know how to get google drive path
According to the docs:
Set the output file name using setOutputFile(). You must specify a file descriptor that represents an actual file.
As I also can’t find a way to retrieve the file as a byte array on a MediaRecorder in the javadoc, or redirect it to an OutputStream, I think I can assume it is impossible to not write it to a file.
i want to have a URL like this one (https://www.ooklnet.com/files/381/381489/video.mp4) where when you click it and itll play the video. Thing is this isnt my website or video. i tried my URL which i thought was corrct (http://54.XXX.XXX.238/srv/ProductVideos/lazar108#hotmail.com/s/s_7s.MP4) and it gives me this error:
The requested URL /srv/ProductVideos/lazar108#hotmail.com/s/s_7s.MP4 was not found on this server.
I know for a fact that theres a video in the file path on my server. Proof:
(I need this URL for my android app so i can display the video in the app.)
How can i create a link like this one (https://www.ooklnet.com/files/381/381489/video.mp4)?
I have a Ubuntu 14.04.4 server with AWS EC2!
Any help would be appreciated!!
Thank you!
1) your EC2 has to have security groups open to allow any access to port 80 from the Internet
2) your EC2 has to be running some web server software such as apache
3) apache needs to be configured to serve files, check the document root
4) apache needs to be configured to correctly send mp4 with the right mime type headers see this answer Apache not serving .mp4 files correctly - shows the contents of the file rather than a download prompt
If it is apache ( and not nginx or another web server) you are using check the access log file /var/log/apache2/access.log and the default error log /var/log/apache2/error.log
I'm trying to modify the universal music player app: https://github.com/googlesamples/android-UniversalMusicPlayer
Since I'm trying to build this for AOSP 6.0, I have no Google Play Services or any other Google Apps on my device, and so cannot use any non-android api's or api's that depend on Google Libraries.
The "Music provider" class, seems to visit this url:
http://storage.googleapis.com/automotive-media/music.json
As mentioned in this line:
private static final String CATALOG_URL =
"http://storage.googleapis.com/automotive-media/music.json";
This file contains a list of tracks that are hosted by Google online. It seems the app can stream these files, but for some reason it does not detect the music already on my device. Why is that ? How do I get the app to list the music tracks that are already on my device ?
Try to reimplement MusicProvider class and the setter to set your new Source from local device.
After you can use your new mMusicProvider variable in MusicService class and set the source you need in MusicService's onLoadChildren method.
More details you may see here:
Change the source in UAMP
I want to implement video-cast of video from internal storage or sd-card.
I see that this sample (https://github.com/googlecast/CastVideos-android ) does cast of internet content only.
How can I do same thing but using video from device ??
There is some tutorial or sample code ?
Edit:
I do more search, local web server is the way ? Something like nanohttpd ?
Yes, you need to set up a local web server in your android app and serve the media from that server.
step 1:
Run simple http server app in your device
https://play.google.com/store/apps/details?id=jp.ubi.common.http.server&hl=en
step 2: open chrome in your laptop and type your android device's http address (from the above app). you will get your device's directory. copy the address of a video file.
step 3. in CastVideos-android project open VideoProvider.java file.
modify the line :
String videoUrl =
step4: run the CastVideos-android project and enjoy casting.
(try clicking on big buck bunny video, to get the video casted faster)