locked
[UWP]How to detect sound is playing in Windows 10 Mobile ? RRS feed

  • Question

  • Hello,

    I have a universal windows app, when start app I want check device sound is playing or not. If device sound playing the app will ask (continue playing device sound or stop it).

    As the title I want know: How to detect sound is playing in Windows 10 Mobile ?

    Thanks!


    • Edited by Krunal Parekh Thursday, December 3, 2015 7:50 AM subject
    Wednesday, November 18, 2015 2:45 AM

All replies

  • Hello Michinin,

    >> As the title I want know: How to detect sound is playing in Windows 10 Mobile ?

    Could you please explain your scenario why you want to do this? Usually when a background music is already playing and your app plays some music the background music will stop playing automatically and foreground music will play. If you are taking about BackGroundMediaPlayer then you can check it using IsMediaPlaying property.

    With Regards,

    Krunal Parekh


    Thanks MSDN Community Support Please remember to Mark as Answer the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Wednesday, November 18, 2015 6:05 AM
  • Hello Krunal Parekh,

    Thank for your answer !

    My purpose is to allow user can decide:  keep thier music or listen to music in my app

    My app is not a music app, it just play music during user play.

    Wednesday, November 18, 2015 7:22 AM
  • Hello Michinin,

    Then I think IsMediaPlaying property is the way to go.

    "If this value is true, you may want to prompt the user to see if they would prefer to continue to listen to the other media source."

    With Regards,

    Krunal Parekh


    Thanks MSDN Community Support Please remember to Mark as Answer the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Wednesday, November 18, 2015 7:32 AM
  • Hi Krunal Parekh,

    I tried use IsMediaPlaying, but its no work.

    BackgroundMediaPlayer::IsMediaPlaying() alway return true

    Please see my code( just demo code):

    using namespace Windows::Media::Playback;

    DirectXPage::DirectXPage():

    {

    InitializeComponent();

    if(BackgroundMediaPlayer::IsMediaPlaying())

    {

    BackgroundMediaPlayer::Current->Pause();

    }

    }

    Please help me if there is something wrong in my code

    Thanks!


    Wednesday, November 18, 2015 8:37 AM
  • I have the same issue here. 

    In my app, I don't have any background music, just some some sound effects. 

    If user plays music on other apps, then launch my app then the music keeps playing (expected behavior is to make that music stopped) 

    Sunday, November 22, 2015 3:11 AM
  • Hello Michinin,

    I was able to reproduce the issue I will try further look into the issue. It seems other users also have reported this.

    Please see: http://stackoverflow.com/questions/32830714/how-to-detect-if-background-music-is-playing-in-windows-phone-8-1-universal-app

    Comment section. I will further discuss this issue and let you know more once I find the solution.

    With Regards,

    Krunal Parekh


    Thanks MSDN Community Support Please remember to Mark as Answer the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Monday, November 23, 2015 7:45 AM