XamarinAudioManager icon indicating copy to clipboard operation
XamarinAudioManager copied to clipboard

Cant seem to make it work from xamarin.forms

Open saaabbir opened this issue 7 years ago • 6 comments

HI, I have a shared project and its connected to real time service so whenever there is an update I need my app to play a notification sound. I installed this nuget package and did the initilize() in both android and ios (dont need uwp). And then when i go to my shared project and try to write await Audio.Manager.PlayBackgroundMusic("bgMusic.mp3"); it shows red underline under Audio as if it didnt find that. I also ensured that i used using AudioManager;.

Now where am i making mistake? Thanks

saaabbir avatar Aug 11 '17 15:08 saaabbir

I have the same problem....please update if you find a solution

edmckee avatar Aug 11 '17 18:08 edmckee

AudioManager.Audio.Manager.PlayBackgroundMusic() works for me, no "using" statements.

drewrobey avatar Aug 23 '17 14:08 drewrobey

having the same problem AudioManager.Audio.Manager.PlayBackgroundMusic("bgMusic.mp3"); gives me the error "the type or namespace name 'Audio' does not exist in the namespace 'AudioManager'"

have Xamarin.Forms version 2.3.3.180 and XamarinAudioManager version 0.8.6

brenaud avatar Oct 26 '17 14:10 brenaud

First of all sorry about closing and re-opening the issue. That was a mistake.

Hi brenaud, To be honest i dont think anyone manage this plugin anymore so no one bothers replying. I ended up using dependency service instead of this plugin because I couldnt make it to work.

I shouldnt probably be giving the link here but it might help others.

https://www.codeproject.com/articles/1088094/WebControls/

Try this it worked. I think for iOS you might need to change the code a little bit. I am giving you my snippet here as well.

Device.BeginInvokeOnMainThread(() =>
            {
                try
                {
                    NSUrl url = NSUrl.FromFilename(fileName.mp3); //put your mp3 in resources folder
                    var systemSound = new SystemSound(url);
                    systemSound.PlaySystemSound();
                    if (vibration == true)
                    {
                        SystemSound.Vibrate.PlaySystemSound();
                    }
                }
                catch(Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                
            });

Hope it helps.

Thanks

saaabbir avatar Oct 26 '17 16:10 saaabbir

Thank you! I'll try it

brenaud avatar Oct 26 '17 16:10 brenaud

I ran into the same thing. Looking into the files, I assume you used a shared project. It only works with PCL otherwise the classes are missing.

Falco20019 avatar Nov 10 '17 14:11 Falco20019