Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot play audio from stream in Android #913

Open
3 tasks
ikeremozcan opened this issue Apr 4, 2024 · 3 comments
Open
3 tasks

Cannot play audio from stream in Android #913

ikeremozcan opened this issue Apr 4, 2024 · 3 comments

Comments

@ikeremozcan
Copy link

🐛 Bug Report

Can not play audio from stream in Android. This part was working in Xamarin. But in MAUI gives this error

Playback error
[ExoPlayerImplInternal]   com.google.android.exoplayer2.ExoPlaybackException: Unexpected runtime error
[ExoPlayerImplInternal]       at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:628)
[ExoPlayerImplInternal]       at android.os.Handler.dispatchMessage(Handler.java:102)
[ExoPlayerImplInternal]       at android.os.Looper.loopOnce(Looper.java:240)
[ExoPlayerImplInternal]       at android.os.Looper.loop(Looper.java:351)
[ExoPlayerImplInternal]       at android.os.HandlerThread.run(HandlerThread.java:67)
[ExoPlayerImplInternal]   Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'com.google.android.exoplayer2.upstream.DataSource com.google.android.exoplayer2.upstream.DataSource$Factory.createDataSource()' on a null object reference
[ExoPlayerImplInternal]       at com.google.android.exoplayer2.source.ProgressiveMediaSource.createPeriod(ProgressiveMediaSource.java:292)
[ExoPlayerImplInternal]       at com.google.android.exoplayer2.source.MaskingMediaPeriod.createPeriod(MaskingMediaPeriod.java:128)
[ExoPlayerImplInternal]       at com.google.android.exoplayer2.source.MaskingMediaSource.createPeriod(MaskingMediaSource.java:100)
[ExoPlayerImplInternal]       at com.google.android.exoplayer2.source.ConcatenatingMediaSource.createPeriod(ConcatenatingMediaSource.java:489)
[ExoPlayerImplInternal]       at com.google.android.exoplayer2.source.MaskingMediaPeriod.createPeriod(MaskingMediaPeriod.java:128)
[ExoPlayerImplInternal]       at com.google.android.exoplayer2.source.MaskingMediaSource.createPeriod(MaskingMediaSource.java:100)
[ExoPlayerImplInternal]       at com.google.android.exoplayer2.MediaSourceList.createPeriod(MediaSourceList.java:315)
[ExoPlayerImplInternal]       at com.google.android.exoplayer2.MediaPeriodHolder.createMediaPeriod(MediaPeriodHolder.java:433)
[ExoPlayerImplInternal]       at com.google.android.exoplayer2.MediaPeriodHolder.<init>(MediaPeriodHolder.java:108)
[ExoPlayerImplInternal]       at com.google.android.exoplayer2.MediaPeriodQueue.enqueueNextMediaPeriodHolder(MediaPeriodQueue.java:190)
[ExoPlayerImplInternal]       at com.google.android.exoplayer2.ExoPlayerImplInternal.maybeUpdateLoadingPeriod(ExoPlayerImplInternal.java:1983)
[ExoPlayerImplInternal]       at com.google.android.exoplayer2.ExoPlayerImplInternal.updatePeriods(ExoPlayerImplInternal.java:1970)
[ExoPlayerImplInternal]       at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:968)
[ExoPlayerImplInternal]       at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:502)

Expected behavior

Should be able to play meditation from memory stream

Reproduction steps

Play audio file from stream

Stream stream = new MemoryStream(file.Bytes);
await CrossMediaManager.Current.Play(new MediaItem
 {
     Data = stream,
     MediaType = MediaType.Audio,
     MediaLocation = MediaLocation.InMemory,
     MimeType = MediaManager.Media.MimeType.AudioMp3,
});

Configuration

Version: 1.2.2

Platform:

  • 🤖 Android 13
  • 🐒 MAUI
  • .NET 8
@gogolon
Copy link

gogolon commented May 6, 2024

@ikeremozcan I bumped into the exact same issue. Did you manage to solve it somehow?

@ikeremozcan
Copy link
Author

I solve it by saving stream in a file @gogolon. Then play audio from the file

@morre95
Copy link

morre95 commented Aug 3, 2024

I have the same problem. I can not get files mp3 to play in android emulator. This line works on windows but not in android for me: await CrossMediaManager.Current.Play("https://ia800806.us.archive.org/15/items/Mp3Playlist_555/AaronNeville-CrazyLove.mp3");

I have .net 8 and android 13
I get:
Java.Lang.RuntimeException: 'Can't create handler inside thread Thread[Thread-13,10,main] that has not called Looper.prepare()'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants