Audio player in xamarin.forms - c#

I am looking for a audio player feature to add to my app, I would like to have a play, stop/pause, and progessbar option for the player. I reffered to https://developer.xamarin.com/samples/monodroid/Example_WorkingWithAudio/. I want to implement the feature for android, iOS, and windows.
Are there any available plugins which I can use or any other reference link which can help..

Take a look at the Xamarin-Forms-Labs Plugin it has a Audioservice.
Here is the code for the interface.
And here an usage example

For those who are facing the same issue, you can achieve this by creating the audio player yourself with help of dependency service and native (platform specific) api's.

Related

Call Functions on Voice Commands In Android Unity

I am making a flashlight application in unity C#. The application is almost complete I just want to add this voice command feature in this like when I say "ON" the flashlight should turn on and when I say " OFF " the flashlight should turn off. The application is for Android devices. I saw several tutorials about calling functions on voice commands but that all were only for windows platform please help me if you know something about doing this in android thanks
I have not used any Speech Recognition tools but its not very difficult to implement if you can create a java plugin & use it to call native function. Anyways I have found few of the SDK:
You can check out the pocket sphinx demos for speech recognition.
https://github.com/cmusphinx/pocketsphinx
https://github.com/cmusphinx/pocketsphinx-android-demo
Here is a repo I found which uses AndroidSpeechRecognition.
https://github.com/gsssrao/UnityAndroidSpeechRecognition
Programmer has given a nice explaination of voice recognition implementation natively:
How to add Speech Recognition to Unity project?
Then there is WatsonSDK for unity but it seems to be via cloud but you can check this one out:
https://github.com/watson-developer-cloud/unity-sdk
And if you dont mind paying for this plugin called Android SpeakNow you can grab it from asset store:
https://assetstore.unity.com/packages/tools/integration/android-speaknow-16781
These are some cloud based packages from asset store, I really doubt you might need this one to implement but in any case this is for someone who may require them at some point of time:
https://assetstore.unity.com/packages/add-ons/machinelearning/google-cloud-speech-recognition-vr-ar-desktop-desktop-72625
https://assetstore.unity.com/packages/tools/integration/yandex-cloud-speech-recognition-vr-ar-mobile-desktop-75155
And finally DictationRecognizer; by default this one is available only for windows 10 as of Unity 2018.2. So this is out of question. My best bet would be cmusphinx or implementing natively which I believe would be more suitable for your needs. Check them out. Try to implement one or two and let us know if you were successful or not.
If anyone can add more links to SDK for voice recognition feel free to add. This would be really great.
If you just need only ON and OFF voice inputs you can use the following code
Speech to text in unity
If you need exact speech recognition then refer the following code
Speech recognition in unity

Unity android Native Camera as WebcamTexture

Can someone help me about to use the Native Camera of Android in Unity the same way we use WebcamTexture? I want the "camera preview image" in Unity as a texture2d or texture.
Thanks in advance.
I did it once using https://bitbucket.org/Unity-Technologies/graphicsdemos as starting point. You are going to be interested in the RenderingPlugin.cpp.
Back in the day I had to use code in Java as bridge to Android NDK since it was not possible to plug an ImageReader in the camera feed on the C level due to security reasons.
It looks like things got updated and it might be possible to simplify the architecture by using https://github.com/googlesamples/android-ndk/tree/master/camera.
Hope this helps.
ps-> In case you want to do a code walkthrough I put together an end-to-end demo here https://github.com/robsondepaula/unity-android-native-camera

Audio recording in Xamarin.forms

I have a xamarin.forms project which has to record the audio and save it localy on the app.
Is there any plugin / api which can be used to achieve this?
Also I would like to know the source of the recorind ie. whether it is being recorded from microphone or is it from handsfree (speaker) without using microphone.
There is no plugin that I know of that does this. you could create a generic service interface called IRecorder which has the functionality you need and then implement the IRecorder interface in the platform specific projects using called AndroidRecorder etc using the dependency service
when implementing your platform specific code you can use these samples
Android
iOS
Windows 10
There is an open-source plugin for working with audio recorder in Xamarin.Forms :
https://github.com/NateRickard/Plugin.AudioRecorder
You can use the dependency service to access platform-specific APIs such as AVAudioRecorder on iOS or MediaRecorder on Android.

How to use two controls for movie player?

I have created a movie player. I'm using the default windows control for Media Player. However I just saw that some movies do not work under it(some FLV files). However those files do work under Media Player Classic. So I was thinking about using the Media Player Classic control.
However
I want this movie player to be as portable as possible. So what I would like to do is to use Media Player Classic control when its available in system, but if its NOT than use Media Player control.
Is that even possible or do I need to create two applications that share the same code?
I would recommend using libvlc. VLC is really good about playing almost anything you give it. It is a C API but one could possibly DllImport their way to success and write code in C#.
Here are some good resources to get you started:
http://wiki.videolan.org/Libvlc
http://www.helyar.net/2009/libvlc-media-player-in-c/ (Shows how to DllImport and call the C code from C#)

How to interface with Windows Media Player in C#

I need to synchronize Windows Media Player with my application. I want to show the current song that WMP is playing in a ListBox in real time, with updates when WMP changes songs. How can I implement this?
A bit of sniffing around in Google gave me this: http://brandon.fuller.name/archives/hacks/nowplaying/wmp/, it looks like you need to write a plugin for WMP that exposes the information to your application. Depending on what you need/cost, the Plugin on that page might do the job!
Poll HKEY_CURRENT_USER\SOFTWARE\Microsoft\MediaPlayer\Player\RecentFileList\File perhaps.
We've controlled Windows Media Player through the Windows Media library (wmp.dll) and .NET Remoting, using a singleton service.
Look here:
How to interact with Windows Media Player in C#

Categories