0

I'm working on an Xamarin app that allows the user to create messages with 4 different content types [text, images, sounds, videos].

Everything worked fine before adding videos to the mix.

Files are being sent and stored in a blob database. And it works fine on most of our devices like:

  • LG Nexus 5 (???)
  • LG Nexus 5X (8.0)
  • Samsung Galaxy S3 Neo (4.4.2)

But somehow it doesn't work on our Samsung Galaxy S7 (7.0) and Samsung Galaxy S4 (???).

On the first devices I can make/select videos and send them to the server and they will be playable in an Android VideoView on all the other devices (even the SGS7 and SGS4). The videos are made with the external camera app.

When I make/select the videos with the SGS7/SGS4 the videos are playable in the preview. But after they are send to the server and you try to read the message the video won't play on any of the devices (not even the devices that made them). But the video does exists as it's URL is playable in the browser.

I've been debugging the whole day and nothing looks extraordinary. I don't get any errors when sending the files.

Any idea on where this could go wrong and why most of the devices are working just fine?

SEG.Veenstra
  • 718
  • 1
  • 7
  • 18
  • 1
    There's a lot at play here. Can you play videos that are stored locally? How are you sending the video to the client? – bryanbcook Oct 13 '17 at 13:57
  • I can play the video if I download it from the web and put it on the device by usb. So the format should be good and the file is not broken. It feels like the Android VideoView has some limitations on streaming the file. – SEG.Veenstra Oct 13 '17 at 14:25
  • Well, there's more to it than that. The mediaType has to appear in the header and some clients expect the content to be streamed a special way, eg scrubbing forward in the video stream before it has been fully downloaded. So how are you streaming it? – bryanbcook Oct 14 '17 at 17:08
  • @bryanbcook I'm sry, I'm really new to the whole video-playing streaming thing. All I know is that the media file is stored in a azure blobstorage and the Android VideoView gets the url to that item. It seems fine for iOS and web, and also for smaller video's on android. But when the video's get larger the Android VideoView will throw the Can't play Video message. – SEG.Veenstra Oct 16 '17 at 07:45
  • Alright, that's helpful. I've successfully streamed videos from azure blob storage before. Are you able to scrub forward beyond what's been downloaded on iOS? – bryanbcook Oct 16 '17 at 11:44
  • Also, can you post a snippet? – bryanbcook Oct 16 '17 at 11:45
  • @bryanbcook Thank you trying to help me. To answer your question, Yes, I'm able to skip/seek on iOS. And you know what? I can also do it on android now that I'm using the ExoPlayer instead of the MediaPlayer. – SEG.Veenstra Oct 16 '17 at 12:50

2 Answers2

1

Using the default MediaPlayer has some limitations:

ExoPlayer supports features like Dynamic adaptive streaming over HTTP (DASH), SmoothStreaming and Common Encryption, which are not supported by MediaPlayer. It's designed to be easy to customize and extend.

Source: ExoPlayer

Using ExoPlayer I was able to play the Video's that I could play before.

SEG.Veenstra
  • 718
  • 1
  • 7
  • 18
1

The ExoPlayer is probably your best bet for this. It's also used by the Xamarin.Forms MediaPlayer plugin.

Regarding streaming from Azure Storage, this blog post had some very helpful information for me as my Android application would crash if we tried to scrub the videos:

  1. The media-content type is properly set on the media. mp4 video should have a mime-type of "video/mp4"
  2. The media files themselves can be an issue. H.264 encoded files can sometimes have the index at the end of the file, which means the entire file must be downloaded before playing.
  3. Your Azure Storage version view here may need to be updated if you're using an older system. The x-ms-version header should be greater than 2012-02-12
bryanbcook
  • 16,210
  • 2
  • 40
  • 69