C# How to programatically change the playback device - c#

How can I programatically change the default audio device on a vista / win 7 system? Using C# or a Win API call?

The WinMM API should provide the functionality that you request.
You would use the DRVM_MAPPER_PREFERRED_SET message, which is sent with waveOutMessage() function.
Documentation: http://msdn.microsoft.com/en-us/library/aa909789.aspx
However, if you are trying to send the waveform sound out yourself, you should look at the WinMM.Net library.
http://winmm.codeplex.com

This can now (actually for quite some time already) be done very easily using the AudioSwitcher.AudioApi.CoreAudio NuGet package.
Simply create a new CoreAudioController:
var controller = new AudioSwitcher.AudioApi.CoreAudio.CoreAudioController();
Get hold of the desired device using its GUID:
var device = controller.GetDevice(Guid.Parse(...));
And lastly set it as the default playback device:
controller.DefaultPlaybackDevice = device;

Related

Defining GattCharacteristic as a Server

I want to fill my variable "selectedCharacteristic" with
GattCharacteristic selectedCharacteristic
selectedCharacteristic = Constants.ResultCharacteristicUuid;
Unfortunately, this doesn't work. It won't convert.
The ResultCharacteristicUuid is from the Microsoft UWP BLE Example.
https://github.com/microsoft/Windows-universal-samples/blob/main/Samples/BluetoothLE/cs/Constants.cs
My program, which has not much to do with the microsoft example (besides the constants.cs),
opens up a BLE Service on start, along with the Result-Characteristic. It acts as an BLE server, nothing more.
So when my BLE Server started, there should be a simple solution to get the device infos and everything GattCharacteristic needs, or not?
The goal is to write to the characteristic as the server, not as a client.
What do I need to get the ResultCharacteristic-Uuid into selectedCharacteristic ?
The UUID should be defined by yourself when you are creating your own service, characteristic. Based on the document- Bluetooth GATT server, you could generate your custom UUID from Visual Studio through Tools -> CreateGuid (use option 5 to get it in the "xxxxxxxx-xxxx-...xxxx" format). This uuid can now be used to declare new local services, characteristics or descriptors.

What device information can I access from the Hololens at run time? (OS Level, Serial Code etc)

What device information can I access from the Hololens at run time using MRTK?
Can MRTK determine a unique identifier for each Hololens device that runs my program? Ideally this would be a serial code, but any other unique identifier from the device would be useful.
I am trying to determine ways to track how many unique devices are running my program, as well as how often they run it.
I am aware that using a managed device might be one way to do this, but I am curious if there is any way to get such information without needing to set up ID Management.
You can use the instance of the EasClientDeviceInformation to get device information from the local device. The property Id provides the identifier of the local device. you can use the following code:
using Windows.Security.ExchangeActiveSyncProvisioning;
. . .
EasClientDeviceInformation deviceInfo = new EasClientDeviceInformation();
var deviceIdentifier = deviceInfo.Id;
In addition, you can retrieve more device information through other properties of the instance, a specific sample is provided here: Client Device Information sample.

Initializing Mobile Hotspot using bluetooth C#

I need to create a service that starts a mobile hotspot using bluetooth. I've found the code to create a hotspot service, but this creates a hotspot with the Ethernet adapter.
I've read the documentation and can't find anything to specify bluetooth like in the settings UI.
This is the code to initialize the hotspot with the Ethernet adapter.
var connectionProfile = Windows.Networking.Connectivity.NetworkInformation.GetInternetConnectionProfile();
var tetheringManager = Windows.Networking.NetworkOperators.NetworkOperatorTetheringManager.CreateFromConnectionProfile(connectionProfile);
The problem with this is that the network is shared through WiFi, and not Bluetooth.
Here are my current connections:
My OS were unfortiunately installed in Norwegian, but the display should look familiar in English.
GetConnectionProfiles returns a IReadOnlyList of ConnectionProfile. You can then try to select a specific profile from the list to operate on, instead of using the default one you have in your snippet.

Launch the android Video App from my app

I am trying to create an app for Android 4.0.3 that listens for UDP-telegrams and starts other apps, depending on the received message.
I am already able to Launch some apps, like the "Music" app:
Intent intent = new Intent("android.intent.action.MUSIC_PLAYER");
intent.SetFlags(ActivityFlags.NewTask);
context.StartActivity(intent);
Is there any chance to do the same for the Video app?
I dont find a valid command for that. (especially WITHOUT loading a defined Video, like Action_View would do)
I was also thinking about using the StartApp, like the following:
OpenApp(context, "com.google.android.apps.maps");
But I also dont find a valid package-name for the Video app, like the other apps have.
Background:
This is for a car-project. The Android-tablet should be used as infotainment system and I want to use an "Ardoino Leonardo Ethernet" to switch between the most important app, using hardkeys instead of the touchscreen.
I prefer to avoid hardcoding any package names as doing so will cause the code to break on different APIs and different vendor's ROMs as they include their own "players" and "viewers".
You can determine which packages are installed that will response to different Uri and Mime types by using the Package Manager and making a query to it, i.e.
var activityIntent = new Intent(Intent.ActionView);
activityIntent.SetDataAndTypeAndNormalize(Uri.Parse("pseudo.mp4"), "video/mp4");
var resolvedActivityList = PackageManager.QueryIntentActivities(activityIntent, PackageInfoFlags.MatchAll);
foreach (var info in resolvedActivityList)
{
Log.Debug("SO", info.ActivityInfo.ApplicationInfo.PackageName);
}

Twilio mms from an Android phone within Canada using Unity3D

Target Platform : Samsung S6 - Android
Development base : Unity3D using C#
Intention :
Send a picture (MMS) shot within an app to any desired phone number within Canada. This app is supposed to be preloaded to a single Samsung S6.
Questions :
I was unable to find any Unity samples within you SDK, however I was wondering if anyone knows Unity samples for my intended use. However planned to use these scripts as first of reference.
Though the Android Phone number which is used to send MMS can be associated with Twilio the receiver would have no association with Twilio as the sender phone number is not something we would know until the photo is taken - hence is this a concern?
I see that from from the API call
// Send a new outgoing MMS by POSTing to the Messages resource */
client.SendMessage(
"YYY-YYY-YYYY", // From number, must be an SMS-enabled Twilio number
person.Key, // To number, if using Sandbox see note above
// message content
string.Format("Hey {0}, Monkey Party at 6PM. Bring Bananas!", person.Value),
// media url of the image
new string[] {"https://demo.twilio.com/owl.png" }
);
the fourth and final parameter is a URL link. Can link of the image be from any server or should it only be from twilio's server?
Thank you very much for time. Highly appreciate it.
Here you are. As far as I know this works like a charm.

Categories