NET MAUI - MediaElement - Not playing Audio Files stored on Google Drive

Riffy 276 Reputation points
2023-03-19T20:01:32.4066667+00:00

Hi

I am using MediaElement to play Audio Files (.mp4) that are stored on my Google Drive,.

But this is failing with error:

[0:] MediaManager: Error: Error codename: ERROR_CODE_PARSING_CONTAINER_UNSUPPORTED, Error message: Source error

The following is a portion of MediaElement XAML markup :

 <toolkit:MediaElement x:Name="mediaElement" Grid.Row="0" Source="{Binding MediaFile}" ShouldAutoPlay="True" />

The following is my C# code in my ViewModel to get the file details from Google Drive:

            request = Service.Files.List();
            request.Q = $"mimeType!='application/vnd.google-apps.folder' and name='{fileName}' and '{folder.Id}' in parents";
            request.Fields = "files(id,name)";
            result = await request.ExecuteAsync();
            if (result.Files != null && result.Files.Any())
            {
                var FName1 = result.Files.First().Name;
                MediaFile = "https://drive.google.com/drive/folders/myfolderid/" + result.Files[0].Id;
  	          MyPage.MediaControlA.Play();
            }

When I play the audio file directly in Google Drive, it plays without an issue.

Can anyone please advise as to what may be causing the error.

Thanks

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
2,868 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,245 questions
XAML
XAML
A language based on Extensible Markup Language (XML) that enables developers to specify a hierarchy of objects with a set of properties and logic.
765 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Riffy 276 Reputation points
    2024-03-11T18:09:14.5266667+00:00

    After spending time trying to resolve the issue, it appeared that you cannot stream audio/video files from Google drive using MediaElement.

    Instead I solved the issue by storing the files on AWS S3 cloud solution. This allows MediaElement to stream the files. This works perfectly.

    1 person found this answer helpful.