Baseflow / Baseflow/XamarinMediaManager
Xamarin.Forms - Streaming from Encrypted Azure Media Services works on iOS and fails under Android
- Dominant language
- C#
- Stars
- 763
- Forks
- 299
- PR merge metrics
- No merged PRs in 30d
Description
## 🐛 Bug Report
I have media (music) stored in an Azure Streaming Media Endpoint. The music is protected by token based authentication and as such during start-up I add the Auth Header like below:
`CrossMediaManager.Current.RequestHeaders.Add("Authorization", $"Bearer {token}");`
Then when I'm ready to play a song I do the following:
```
var url = song.DirectUrls.First(s => s.Contains("m3u")); //aapl
var mediaitem = await CrossMediaManager.Current.Extractor.CreateMediaItem(url);
mediaitem.MediaType = MediaType.Hls;
var item = await CrossMediaManager.Current.Play(mediaitem);
```
This works perfect in XF iOS and Fails in XF Android.
Here is the error message I see for XF Android:
```
[System.out] (HTTPLog)-Static: isSBSettingEnabled false
[System.out] (HTTPLog)-Static: isSBSettingEnabled false
[MediaHTTPConnection] response code = 200
[MediaHTTPConnection] mTotalSize is -1
setDataSource failed: status = 0x80000000
[Choreographer] Skipped 151 frames! The application may be doing too much work on its main thread.
[System.out] (HTTPLog)-Static: isSBSettingEnabled false
[System.out] (HTTPLog)-Static: isSBSettingEnabled false
[AudioManager] requestAudioFocus status : 1
[System.out] (HTTPLog)-Static: isSBSettingEnabled false
[System.out] (HTTPLog)-Static: isSBSettingEnabled false
[art] Waiting for a blocking GC Alloc
[art] Clamp target GC heap from 142MB to 128MB
[art] WaitForGcToComplete blocked for 28.848ms for cause Alloc
[art] Starting a blocking GC Alloc
[System.out] (HTTPLog)-Static: isSBSettingEnabled false
[System.out] (HTTPLog)-Static: isSBSettingEnabled false
[System.out] (HTTPLog)-Static: isSBSettingEnabled false
[System.out] (HTTPLog)-Static: isSBSettingEnabled false
[System.out] (HTTPLog)-Static: isSBSettingEnabled false
[System.out] (HTTPLog)-Static: isSBSettingEnabled false
[System.out] (HTTPLog)-Static: isSBSettingEnabled false
[System.out] (HTTPLog)-Static: isSBSettingEnabled false
[ExoPlayerImplInternal] Source error.
[ExoPlayerImplInternal] com.google.android.exoplayer2.upstream.HttpDataSource$InvalidResponseCodeException: Response code: 401
[ExoPlayerImplInternal] at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.open(DefaultHttpDataSource.java:300)
[ExoPlayerImplInternal] at com.google.android.exoplayer2.upstream.DefaultDataSource.open(DefaultDataSource.java:250)
[ExoPlayerImplInternal] at com.google.android.exoplayer2.upstream.StatsDataSource.open(StatsDataSource.java:83)
[ExoPlayerImplInternal] at com.google.android.exoplayer2.source.chunk.DataChunk.load(DataChunk.java:75)
[ExoPlayerImplInternal] at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:381)
[ExoPlayerImplInternal] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
[ExoPlayerImplInternal] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
[ExoPlayerImplInternal] at java.lang.Thread.run(Thread.java:762)
```
It appears that it cannot access the media as seen by the ExoPlayer returning a 401 however the log does indicate: `[MediaHTTPConnection] response code = 200` so I'm not sure.
I've also tried switching the url to use the mpd format and set the MediaType to Dash but it still fails, although in this case ExoPlayer complains with
```
[ExoPlayerImplInternal] Source error.
[ExoPlayerImplInternal] java.io.EOFException
[ExoPlayerImplInternal] at com.google.android.exoplayer2.extractor.DefaultExtractorInput.readFromDataSource(DefaultExtractorInput.java:265)
[ExoPlayerImplInternal] at com.google.android.exoplayer2.extractor.DefaultExtractorInput.skipFully(DefaultExtractorInput.java:102)
[ExoPlayerImplInternal] at com.google.android.exoplayer2.extractor.DefaultExtractorInput.skipFully(DefaultExtractorInput.java:110)
[ExoPlayerImplInternal] at com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor.readAtomPayload(FragmentedMp4Extractor.java:427)
[ExoPlayerImplInternal] at com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor.read(FragmentedMp4Extractor.java:315)
[ExoPlayerImplInternal] at com.google.android.exoplayer2.source.chunk.InitializationChunk.load(InitializationChunk.java:89)
[ExoPlayerImplInternal] at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:381)
[ExoPlayerImplInternal] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
[ExoPlayerImplInternal] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
[ExoPlayerImplInternal] at java.lang.Thread.run(Thread.java:762)
```
### Expected behavior
Should be able to stream on both XF iOS and XF Android
### Reproduction steps
### Configuration
**Version:** 0.8.8
**Platform:**
- [ ] :iphone: iOS
- [ ] :robot: Android
- [ ] :checkered_flag: WPF
- [ ] :earth_americas: UWP
- [ ] :apple: MacOS
- [ ] :tv: tvOS
- [x] :monkey: Xamarin.Forms
Contributor guide
Research direction
No repository files or tests are identified. Start by reproducing the Xamarin.Forms 0.8.8 sample with Azure Media Services token authentication, then compare the Android ExoPlayer requests with iOS and investigate the reported 401 response. Done means authenticated HLS or DASH media streams successfully on Android.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, azure, csharp
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100