We want to build a Videoportal as a PWA. Every video will have a watch offline feature. Can this be done via the Serviceworker caching? Or should another Download-Mechanism enable this Feature. The videos size is about 120mb. Target Device is Android and Web.(Sorry for bad english)
Yes, you can use the Cache Storage API along with service workers to handle offline video playback.
There's a complete sample app at https://github.com/googlearchive/sample-media-pwa.
If you were to use the Workbox libraries for handling your caching logic, then this guidance should help. If you don't end up using Workbox, then you'll need to implement some logic to handle Range: requests in your service worker, or else your video playback will likely not behave as expected when the <video> element tries to load a partial chunk of video bytes.
Related
I have an Android videochat app running through a Kurento WebRTC server. The websocket, room and peer connections are handled with the help of Nubomedia libraries:
https://github.com/nubomedia-vtt/webrtcpeer-android
https://github.com/nubomedia-vtt/kurento-room-client-android
The connection works fine. Now I need to implement a pause/resume button but only for one of the streams. This way one peer can send his stream to the room while other may temporary disable his stream, but still see the other one.
I'm trying to stop it with:
nbmWebRTCPeer.stopLocalMedia();
Which works great, but I'm not able to resume it with:
nbmWebRTCPeer.startLocalMedia();
The upstream keeps frozen after resuming. Is not this a good approach? If not, is there any better? for example, sending a black stream instead of stop/start local media?
I ended up forking the library and adding my own funtion to call localVideoTrack.setEnabled(bool) in MediaResourceManager. Now I can pause/resume the outgoing video with ease.
I have an app that plays an song displaying its lyrics on the screen.
Two situations:
When the song is loaded from a local mp3 file.
When the song is loaded from remote location via internet
My understanding is that Android Service comes to rescue when the song is streamed from remote location via internet. Android Service helps here because of the i/o overheads involved. In the first case, where the song is played form local location, services is perhaps an overkill. I can simply play the music loading it in the activity and use MediaPlayer API to play it.
Is this understanding correct? Am I missing anything?
Update: The song size is over 10MB. So when you stream it via a slow internet over phone there might be some buffering and stuff to be accommodated for better user experience.
Thanks in advance.
There are different Services for different use cases. For a Media Player it depends if you want to have the playback continuously playing in the back- or foreground.
So both cases are applicable for a Media Player Service. But the Android Developer Guide Media Player Service outshines my answer
Using a Service with MediaPlayer
If you want your media to play in the background even when your application is not onscreen—that is, you want it to continue playing while the user is interacting with other applications—then you must start a Service and control the MediaPlayer instance from there. You should be careful about this setup, because the user and the system have expectations about how an application running a background service should interact with the rest of the system. If your application does not fulfil those expectations, the user may have a bad experience. This section describes the main issues that you should be aware of and offers suggestions about how to approach them
Your second case is more a question about networking and in this case you could use a IntentService to download the .mp3 and pass it to the MediaPlayer.
We are developing an Android application, where there is a need to upload several photos to our server in an asynchronous way. Consider that as soon as a picture is taken, it will start being uploaded. As soon as it has finished being uploaded, the next one (all of them will be placed in a queue) will start being uploaded.
However, it is also important to support cancellation functionality, meaning that the user can interact with the app in a way that will remove an image from the queue or even cancel a running upload.
After searching for possible solutions, we have come to the following possible scenarios:
1) Use an IntentService for the queue mechanism and implement our own logic inside it. However, there are some worries as to how easy it is going to be to support cancellation.
2) Use the SD card and a local database to store the files and a Service to check for new files. This has been described here:
Android (or iOS) - Image Upload Queue
3) Find a way to use the built-in Android DownloadManager for uploads (can it really be done?)
4) Use AsyncTask and isCancelled() function.
5) Or ideally find another built-in Android/Java mechanism to do all of the above in a seamless way.
Any ideas?
I am creating an app that streams music from a movie soundtrack, and prompts the user to guess what movie it is from. Do to some legal ramifications of using third party music, I am forced to think of another way to do it, than using my own streaming service. one thing that I have come up with, is using amazon's music service (being that with them, it will allow you to stream up to 30 seconds of music without buying it.) how would I be able to stream music from their site in android? is there an amazon API that I can use? how would I access their server to stream it? and do they allow people to stream from them, or do I have to get special permission?
I bet this is against their terms of service and you will likely be shut down pretty quickly.
I'm wondering what would be a good way to build an Android application with offsite processing. Essentially I am going to record an input (audio recording or photo), and then send it to a computer I have online (securely - probably using HTTPS). I then will have the computer process the data and send back a response.
Essentially this is a Shazam like application, except everywhere I look to how Shazam works they talk about the processing algorithm, not the process. Any help would be appreciated.
If your server processing may take time, you can use Push Notification to tell the application that you are done on the server side. The application can then get the result instead of holding up the connection for too long.