android / socialite

Apache License 2.0
406 stars 74 forks source link

Video playback support via network #87

Closed MayuriKhinvasara closed 4 months ago

MayuriKhinvasara commented 4 months ago

Support playback of video through network. Modify the MediaMetadataRetriever data sources to support remote urls. Move this to an IO Thread.

calren commented 4 months ago

I'm getting a crash when I try to set the media uri: https://storage.googleapis.com/exoplayer-test-media-1/mp4/android-screens-10s.mp4

In Contact.kt I set the dog to reply with a mediaUri like this:

    "dog" to { _ ->
        buildReply {
            this.text = "Check out the Top 3 Modern Android Development Announcements from I/O '23!"
            mediaUri = "https://storage.googleapis.com/exoplayer-test-media-1/mp4/android-screens-10s.mp4"
            mediaMimeType = "video/mp4"
        }
    },

but this leads to a crash

  java.lang.RuntimeException: setDataSource failed: status = 0xFFFFFFEA
                                                                                                        at android.media.MediaMetadataRetriever._setDataSource(Native Method)
                                                                                                        at android.media.MediaMetadataRetriever.setDataSource(MediaMetadataRetriever.java:281)

Should I use another media uri to test remote videos?

calren commented 4 months ago

ah, i think the crash is due to local videos, not remote videos.

i added some print statements. when i record a video, the uri is /storage/emulated/0/Android/data/com.google.android.samples.socialite/cache/Socialite-edited-recording-2024-08-05-12-09-45-454.mp4 , which doesn't start with content://

MayuriKhinvasara commented 4 months ago

Fixed the crash. Switched the logic to tread remote urls via https.

calren commented 4 months ago

lgtm, one suggestion about adding a comment for why we moved getting the video duration to the IO thread, as I think it's not clear for a developer just reading the code