Issue
var medPlay: MediaPlayer
holder.vidPlayer.setVideoPath(fileUrl)
holder.vidPlayer.setOnPreparedListener { mp ->
medPlay = mp
}
Instead of downloading the Video separately again for sharing, I'd like to share the file that is already loaded in the VideoView / MediaPlayer and then:
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("video/*");
sharingIntent.putExtra(Intent.EXTRA_TEXT, "Hey this is the video text");
sharingIntent.putExtra(Intent.EXTRA_STREAM,uriFromVideoView);
startActivity(Intent.createChooser(sharingIntent,"Share Video");
Is that possible? I would also accept alternatives / suggestions
Solution
Is that possible?
No. For starters, it is not physically possible for all types of streams. Beyond that, VideoView
/MediaPlayer
are not writing the media to disk. They download in chunks, to minimize RAM consumption, and use it solely for playback.
I would also accept alternatives / suggestions
Download the video yourself, such as by using OkHttp. Use the downloaded copy both for setVideoPath()
and for ACTION_SEND
(the latter by way of FileProvider
, most likely). Note that this will only work for video streams that are actual files (e.g., not some livestream), and it would require downloading the entire video first.
Answered By - CommonsWare
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.