question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to manage errors related to the URL or to connectivity?

See original GitHub issue

Hello,

I use the XamarinMediaManager in a Xamarin.Forms project, to play audio from a web radio.

But I would like to manage error cases, like when the URL is no longer available, or if there is not internet access for example.

I launch the audio stream like this: var mediaItem = await CrossMediaManager.Current.Play(audioUrl);

If I use a “wrong” URL, nothing happens, but I didn’t found how to “identify” this case. It’s the same thing if I activate the airplane mode.

I would like to display an error message to the user in both cases, so he could understand why the audio doesn’t launch.

Is there a way to manage this?

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
RichardSV15commented, Feb 9, 2021

From the top of my head: there’s a OnMetadataUpdated that you can subscribe to for updates. mediaItem.MetadataUpdated += (sender, args) => { var title = args.MediaItem.Title; // Perhands check for null values and act accordingly. };

0reactions
pcduscommented, Feb 19, 2021

I’ve did some investigations, and it seems that the behaviour is not the same on iOS and Android.

As a reminder, I would like to manage errors that can occur when the user try to play a webradio stream.

On Android, I use the MediaItemFailed event, that is raised after 1 minute: CrossMediaManager.Current.MediaItemFailed += OnCurrentMediaItemFailed;

On iOS the event is not raised, so I check the MediaItem.Title like this:

var mediaItem = await CrossMediaManager.Current.Play(radioUrl);
var currentTitle = mediaItem.Title;

But in both cases, I would to display an error message to the user, and to reset CrossMediaManager.Current.State to Stopped.

For this, I call the Stop() method when an issue is detected: await CrossMediaManager.Current.Stop();

But this seems only working on Android. On iOS, the State is still Pause or Buffering after this…

Is there any explanation?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Handling operation errors - Apollo GraphQL Docs
Executing GraphQL operations on a remote server can result in GraphQL errors or network errors. GraphQL errors. These are errors related to the...
Read more >
Fix connection errors - Google Chrome Help
Fix most connection errors​​ If you go to a website and get an error, try these troubleshooting steps first: Check the web address...
Read more >
Manage errors | Error Reporting
To view the issues associated with an error group, click the link icon link: If the error group isn't associated with an issue...
Read more >
How to Fix the ERR_CONNECTION_RESET Error in 7 Ways
If the issue persists, try opening the website using another device that's connected properly to the same network. If the error message still ......
Read more >
8 Common Webpage Errors & How to Fix Them
You can usually fix this error by reviewing the URL of the page that is causing the error; it's possible that the link...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found