1

I have the following problem:

if I hand over an uri with the Content Type audio/aacp to the MediaPlayer for Android, the MediaPlayer won't recognize the content type as it should and throws an exception.

How can I change it so the MediaPlayer recognizes and uses this content type correctly?

Just as a side note i still have uris with different "Content Types" which it recognizes correctly. (and i obviously still need that working)

here is some of my code (i'm not sure if that is helpful or not):

readonly MediaPlayer player;

internal StreamingAudioPlayer(System.Uri uri)
{
    player = new MediaPlayer();
    player.Completion += OnPlaybackEnded;
                
    player.SetDataSource(Android.App.Application.Context, Uri.Parse(uri.AbsoluteUri));

    player.Prepare();
}

If you have any questions or need more information, just say so. I'm happy to provide what I can.

Edit: More information about the exception(s):
if I try to start the app with the uri, I get a Java.IO.IOException: 'Prepare failed.: status=0x1'

In the Output it also says:

[MediaPlayer] Couldn't open (and then the uri here): java.io.FileNotFoundException: No content provider: (uri here)
[System] ClassLoader referenced unknown path: /system/framework/tcmclient.jar
[NetworkSecurityConfig] No Network Security Config specified, using platform default
[MediaPlayer] error (1, -2147483648)

If I start the app by using another uri and then changing to this specifiy uri I get following System.Reflection.TargetInvocationException: 'Exception has been thrown by the target of an invocation.'

The output says this time:

[MediaPlayer] Couldn't open (and then the uri here): java.io.FileNotFoundException: No content provider: (uri here)
[MediaPlayer] error (1, -2147483648)
System.Reflection.TargetInvocationException: 'Exception has been thrown by the target of an invocation.'

  • *"throws an exception"*. Add to question the complete text (but not as an image) of the exception. – ToolmakerSteve Sep 26 '22 at 20:05
  • You can check this [link](https://learn.microsoft.com/en-us/xamarin/android/app-fundamentals/android-audio#playing-audio-with-the-mediaplayer-class). It explained in detail how to initialize and play about MediaPlayer. – Jianwei Sun - MSFT Sep 27 '22 at 07:05

0 Answers0