Help with integrating this into WP7 app

Jan 4, 2013 at 5:02 PM
Edited Jan 4, 2013 at 5:02 PM

Hi,

I'm trying to integrate the code from this into my own WP7 app. I integrated it into a WP8 app earlier and was successful.

Currently, when I use WP8 to play a Shoutcast Stream, I see the following in output:

An exception of type 'System.Runtime.InteropServices.COMException' occurred in Microsoft.Phone.ni.dll and wasn't handled before a managed/native boundary
1:  OpenMediaAsync()
An exception of type 'System.Runtime.InteropServices.COMException' occurred in Microsoft.Phone.ni.dll and wasn't handled before a managed/native boundary

Followed by a whole bunch of Output showing the stream is working/decoding/playing, and the station starts playing. Since it works I don't care about the exceptions that occur.

However, when I use the WP7 app with what I believe to use the exact same code as my WP8 app, I am seeing in output:

An exception of type 'System.Runtime.InteropServices.COMException' occurred in Microsoft.Phone.ni.dll and wasn't handled before a managed/native boundary
An exception of type 'System.Runtime.InteropServices.COMException' occurred in Microsoft.Phone.ni.dll and wasn't handled before a managed/native boundary

But the station never plays, and nothing appears in Volume Control. No Output even shows up from AudioTrackStreamer/Shoutcast.Media.

I don't have much experience with debugging, so I'm not sure where the chain of events start but OnBeginStreaming is never called in the WP7 version of my app while it is called in the WP8 one.

I'd love if if someone could come and have a peek at my code or something and hopefully help me sort this out. It's especially weird since ShoutcastMSS is meant for WP7 >.<

Any help would be AWESOME.

Thanks.

Coordinator
Jan 4, 2013 at 6:06 PM

Generally, exceptions should not be ignored, so there is likely something wrong somewhere.  Can you get the HResult from the COMException?  It may shed some light on what is actually going on.

Jan 5, 2013 at 10:05 AM

Thanks for replying.

I wouldn't ignore the exception but it's shown to be working in my WP8 app despite the exceptions, so I'm not sure.

Anyway, the exception appears to be coming from AudioPlayer.cs, where OnPlayStateChanged:

 

base = {System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.
   at Microsoft.Phone.BackgroundAudio.Interop.IAudioTrack.get_Duration()
   at Microsoft.Phone.BackgroundAudio.AudioTrack.get...

Which isn't helpful at all seeing how E_FAIL is an unspecified error.

I can send you the project to have a look, both my WP7 and WP8 ones. Still can't figure out how the WP8 one can work while the WP7 one doesn't when the code is exactly the same.

 

Coordinator
Jan 18, 2013 at 7:33 PM

I actually haven't tested this at all in WP8 yet, so I have no idea why it would work or not there.  It might be that error checking could have been relaxed in WP8 for non-fatal scenarios.  I will hopefully have time to dig back into this soon and update it for WP8.  Anything with OnPlayStateChanged is always problematic, and AudioTrack is very picky.  Try stripping your AudioTrack creation down to only the URL, and see if it works.

Jan 19, 2013 at 10:27 PM

Bringing it down to only the URL in the Tag, still not working.

I am unable to even get to "OnBeginStreaming", it seems. Wonder if there's another way to trigger that.

 

Looking forward to the next update :/