none
[U8.1]playing background audio using sharpDx in windows universal app 8.1? RRS feed

  • Question

  • How to play background audio using sharpDx in windows universal app 8.1,actually we are doing one music application, in that we are playing multiple songs simultaneously  for that, when we minimize that application the playing songs should run on the background in both windows and Mobile,and also in mobile while the screen get locked the app should be running on the background and the songs should be in playing state,so help for this as soon as possible.

       Actually we used SourceVoice instances in SharpDx framework,to play the multiple songs simultaneously ....

     Thanks in Advance.


    • Edited by Jamles Hez Thursday, January 28, 2016 4:53 AM subject
    Monday, January 25, 2016 6:05 AM

Answers

  • Hi Hemanth_K,

    As I know the only way is to play the audio is via SystemMediaTransportControls, since you want to play the audio when the app is not actived, the only possible way is to let system play the audio for you. BackgroundTask does not have any trigger or implementation for the Audio playing. 

    That's why I suggest you can combine the audio when the app is actived, and send the result to the SystemMediaTransportControl to play when the app is suspend.

    --James 


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Proposed as answer by Fred Bao Friday, February 5, 2016 7:43 AM
    • Marked as answer by Fred Bao Thursday, February 11, 2016 9:18 AM
    Friday, January 29, 2016 5:43 AM

All replies

  • Hi Hemanth_K,

    Sounds like when you are using sharpDx, it cannot play the media on the background, I think you can also feedback your issue on GitHub: https://github.com/sharpdx/SharpDX since it sounds like a DX wrapper.

    Basically if we want to play the background audio, you can try this: SystemMediaTransportControls class, ref: How to play audio in the background

    --James


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, January 28, 2016 4:52 AM
  • Hi James,

      Thank you for the reply,,

    Our requirement is we need to play multiple sounds at a time like a compose a song with different sounds. So i tried with system media but it didn't worked out so we chosen SHARPDX for this. In sharpdx background is not playing.

     Is there any other solution for this?

    Thanks in advance.

    Thursday, January 28, 2016 5:20 AM
  • Hi Hemanth_K,

    May I know if you already have such song with different sounds or you need programmatically compose one song and directly play on the background? How about you use some library to mix the song before the app goes to background.

    --James


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, January 28, 2016 7:15 AM
  • Hi james,

       Actually we have some .wav format audio files.those all .wav files are kept in one folder from that we are using,

    this is the code we used to play the audio (using SharpDX),

                        xAudio = new XAudio2();
                        SoundStream stream;

                        var masteringVoice = new MasteringVoice(xAudio);
                        path1 = "Songs/" + objSound.Name + ".wav";
                        var nativeFileStream = new NativeFileStream(path1, NativeFileMode.Open,                                               NativeFileAccess.Read, NativeFileShare.Read);
                        stream = new SoundStream(nativeFileStream);
                        waveFormat = stream.Format;
                        buffer = new AudioBuffer
                        {
                            Stream = stream.ToDataStream(),
                            AudioBytes = (int)stream.Length,
                            Flags = BufferFlags.EndOfStream,
                            LoopCount = AudioBuffer.LoopInfinite,
                        };

    for this is their any background capability to play the audio on background?


    • Edited by Hemanth_K Thursday, January 28, 2016 9:34 AM
    Thursday, January 28, 2016 9:24 AM
  • Hi Hemanth_K,

    As I know the only way is to play the audio is via SystemMediaTransportControls, since you want to play the audio when the app is not actived, the only possible way is to let system play the audio for you. BackgroundTask does not have any trigger or implementation for the Audio playing. 

    That's why I suggest you can combine the audio when the app is actived, and send the result to the SystemMediaTransportControl to play when the app is suspend.

    --James 


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Proposed as answer by Fred Bao Friday, February 5, 2016 7:43 AM
    • Marked as answer by Fred Bao Thursday, February 11, 2016 9:18 AM
    Friday, January 29, 2016 5:43 AM
  • Hi James,

                    If you don't mind,is there any personal Blog for you to communicate about the queries regarding windows app development,actually i am new to the windows app development.

    Friday, January 29, 2016 9:42 AM
  • Hi Hemanth,

    I will always use my search engine to type "keyword" with "site:blogs.msdn.com" to find some interesting blog.

    --James


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, February 3, 2016 1:42 AM