0

I have a .ashx handler file that I use to stream files from my website. I pass a file id and the handler gets the file, sets the content type and streams it.

This works great for all the files I display in my iOS apps.

I am having an issue with the MediaElement, when I set the source to the url of the handler, it does not play the video.

If I set it to a .mov file on my site, it works fine.

source = "https://mobile.mysite.com/BuildingPatrol/GetAttachment.ashx/?AttachmentId=12345" does not work

source = "https://mobile.mysite.com/BuildingPatrol/Test.MOV" works fine

If I put the link to the handler file directly in a browser, it downloads the 12345.MOV file to the downloads folder and the .mov file plays fine.

        var MediaElement = new Xamarin.CommunityToolkit.UI.Views.MediaElement()
        {
            //Source = "https://mobile.mysite.com/BuildingPatrol/GetAttachment.ashx/?AttachmentId=" + Attachment.AttachmentId.ToString(),
            Source = "https://mobile.mysite.com/BuildingPatrol/Test.MOV",
            ShowsPlaybackControls = true,
            IsLooping = true,
            AutoPlay = true,
            HeightRequest = 200,
            HorizontalOptions = LayoutOptions.FillAndExpand,
        };
thinkjohn
  • 33
  • 8
  • does the ashx handler set the correct content type header? – Jason Jul 30 '21 at 13:57
  • for the .mov file I am setting context.Response.ContentType = "video/quicktime" – thinkjohn Jul 30 '21 at 14:46
  • The native iOS and Android media APIs do have some specific server requirements to allow streaming media, however maybe the links you provided does not meet that criteria.If that is so, you could get the true URL from the ashx page and then set the MediaElement URL to the media's direct URL returned from the ashx page. What's more , consider raising issue on github : https://github.com/xamarin/XamarinCommunityToolkit/issues. – ColeX Aug 05 '21 at 02:52
  • Opened an issue on github and I can't get anyone to respond with a workaround. If anyone can provide a workaround, that would be awesome. – thinkjohn Sep 03 '21 at 17:12
  • https://github.com/xamarin/XamarinCommunityToolkit/issues/1589 – thinkjohn Sep 03 '21 at 17:12

0 Answers0