0

I'm trying to implement BackgroundAudio in my UWP app and I'm following the sample on github. Yet for me before the BackgroundTask gets initialized the output returns The program '[11864] Windows.Media.BackgroundPlayback.exe' has exited with code 1 (0x1).

I can't seem to figure out why though. Is there a way I can debug this?

Edit: I have put the project online. Seems a lot easier than just copy pasting parts of the code because I don't really understand where it goes wrong

Arn Vanhoutte
  • 1,779
  • 4
  • 16
  • 28
  • Showing us the relevant parts of your code is a good start. – Visual Vincent Apr 30 '16 at 20:27
  • Well I have a breakpoint in the function where I play a music file. Like in the example, it first checks if the task is running. Like this: `if (!IsMyBackgroundTaskRunning || MediaPlayerState.Closed == CurrentPlayer.CurrentState)` But when the breakpoint is hit, VS seems to hang for a while and then it outputs that the BackgroundPlayback has exited with code 1. I guess I could link the github project here if that would help. But not much of the sample code has been changed. I copy pasted everything from it – Arn Vanhoutte Apr 30 '16 at 20:32
  • [Error code 1](https://msdn.microsoft.com/en-gb/library/windows/desktop/ms681382(v=vs.85).aspx) is apparently `Invalid function`. I don't know if it means that you're calling a function that doesn't exist or something, but you could probably read more about it. – Visual Vincent Apr 30 '16 at 20:53
  • When I evaluate the BackgroundMedia.Current in my watch I get this `function evaluation disabled because a previous function evaluation timed out` Could this be related? I don't really get what it means – Arn Vanhoutte May 01 '16 at 07:44
  • Apparently that occurs [when something takes long time to evaluate](http://stackoverflow.com/a/2721245/3740093). I'd guess there is something in either of your applications that takes a bit of time executing, and without any code to look at this is a bit hard. You say you have pretty much copy-pasted a Github project. Could you share the link to that project if it's not way to much code? **EDIT:** Oh wait, you already did. I'll try debugging it as soon as I get access to a computer. – Visual Vincent May 01 '16 at 08:22
  • Oh man thanks for the effort you're putting into this. I'm stuck for weeks on this error now and I have no idea what's wrong. I think the reason it says that something took a long time to evaluate is because it crashes, but I'm not sure about that – Arn Vanhoutte May 01 '16 at 09:19
  • I'm sorry to say, but due to that I have Windows 7 and Visual Studio 2010 I cannot open your project. So I haven't been able to debug it. – Visual Vincent May 01 '16 at 15:47
  • Oh that's okay. Thanks for trying though – Arn Vanhoutte May 01 '16 at 16:00

2 Answers2

0

If you put your BackgroundTask into WinMD file you will be able to debug it from Visual Studio.

PS: don't forget to add capabilities in manifest

Alexej Sommer
  • 2,677
  • 1
  • 14
  • 25
  • My Backgroundtask is a part of the solution and I can debug that. But before it even runs it fails because Windows.Media.BackgroundPlayback.exe crashes – Arn Vanhoutte Apr 30 '16 at 20:26
0

Fixed it by adding a reference from my task to my main project

Arn Vanhoutte
  • 1,779
  • 4
  • 16
  • 28