C# How to access the current playback of windows - c#

at Windows 10 there is a Music Feature(Pic Below):
So my Question is: How can I access this information with C# and which libraries do i need?
Thanks for helping

Excuse me for my ignorance, but if I am correct, this widget is a pop up of Spotify, isn't this? In that case, you only have to check the MainWindowsTitle of spotify process.
var spotify = Process.GetProcessesByName("Spotify");
foreach (var song in spotify)
{
Console.WriteLine(song.MainWindowTitle);
}
Console.ReadLine();
Don't forget use using System.Diagnostics;. You will have to check if you don't get any song.
I was checking if this method works yet :)

Related

anyway i could make my Speech Recognition App search google?

i've been working on a personal assistant project, so far its going great but i dont know how to make her do a google search.
here's what i've tried :
if (speech == "friday search google")
{
Friday.SpeakAsync("what are you searching for?");
//theoratically speaking the next line should be the problem, i need a string that
//starts recording audio so i can recall the recorded audio as the named string (search)
SpeechRecognitionEngine search = new SpeechRecognitionEngine(); // <-- this line
string url = "www.google.com/search?=q";
Process.Start(url + search);
}
or if im entirely wrong, i'd really appreciate some help into making it work.
thanks in advance everyone!

Read data via bluetooth using c#

I am using Lecia Disto e7100i which basically measures distance and area using laser. This device has bluetooth and can be paired with windows.
I am trying to develop an wpf app that reads the mesaured data using c#
There is no sdk that comes along with the device.
I have tried to use 32feet.Net but since there is no proper documentation I don't know where to start.
Is there any way that I can do to solve my problem?
This is not a full response, instead its more of a guideline on how to resolve your issue:
Pair the device with your Computer
Run the included software that displays the data somehow
Use WireShark to analyze the traffic
see if it is a standard protocol type or something custom
understand the protocol and reimplement it using c# and BluetoothSockets
To get started, you can try:
var client = new BluetoothClient();
// Select the bluetooth device
var dlg = new SelectBluetoothDeviceDialog();
DialogResult result = dlg.ShowDialog(this);
if (result != DialogResult.OK)
{
return;
}
BluetoothDeviceInfo device = dlg.SelectedDevice;
BluetoothAddress addr = device.DeviceAddress;
Console.WriteLine(device.DeviceName);
BluetoothSecurity.PairRequest(addr, "PIN"); // set the pin here or take user input
device.SetServiceState(BluetoothService.HumanInterfaceDevice, true);
Thread.Sleep(100); // Precautionary
if (device.InstalledServices.Length == 0)
{
// handle appropriately
}
client.Connect(addr, BluetoothService.HumanInterfaceDevice);
Also make sure that
Device appears in "Bluetooth devices" in the "Control panel".
Device is HID or change code accordingly.
Hope it helps. Cheers!
Try this demo project, and the following articles after that one.
Try to follow this tutorial
Here you can see a direct answer by the mantainer of 32feet, with which you can get in touch
Check also this answer

How to read QR code in windows phone 8.1 app development?

I want to scan QR code in windows phone app 8.1.I am tried lot of examples but no one is work for me.
Below code I tried but no use
xmlns:jwqr="clr-namespace:JeffWilcox.Controls;assembly=JeffWilcox.Controls.QR"
in xaml
<jwqr:QRCodeScanner
ScanComplete="QRCodeScanner_ScanComplete"
Error="QRCodeScanner_Error"
Width="400"
Height="400"/>
It showing error like:
The name "QRCodeScanner" does not exist in the namespace
"clr-namespace:JeffWilcox.Controls;assembly=JeffWilcox.Controls.QR"
And tried the link this one also not working for me. But in this camera not scan the code. Please anyone help me. If you have any other links. I am trying this last 3 days but till now I am not getting any answer correctly. Plase help me.......
I'm not recommending but i've used Zxing Library for Barcode/QR code scanning and that worked for me.
here's a sample how to use this library:
// create a barcode reader instance
IBarcodeReader reader = new BarcodeReader();
// load a bitmap
var barcodeBitmap = (Bitmap)Bitmap.LoadFrom("C:\\sample-barcode-image.png");
// detect and decode the barcode inside the bitmap
var result = reader.Decode(barcodeBitmap);
// do something with the result
if (result != null)
{
txtDecoderType.Text = result.BarcodeFormat.ToString();
txtDecoderContent.Text = result.Text;
}
Documentation and other demoClient is available here
Ask if you require more code. Hope that helps..!

Distinguishing between phone and tablet browsers

I know this question as been beaten to death, but I don't want anything super complicated here.
We have a companion app with our site that is only compatible with 7 and 10-inch tablets. We need to only alert users on those devices about our app. Problem is, I can't go by resolution. My Galaxy S3 has a 1280 x 720 screen, but is obviously not a tablet. I also can't for the life of me find out a way to get the physical size of the screen. The only solution I have come up with is detecting whether the device can make calls with MobileCapabilities.CanInitiateVoiceCall. Unfortuantely, by boss isn't happy with that solution.
So... How can I distinguish between a phone and a tablet in my web app (Server or client side)?
UPDATE: So far it seems that the best approach for Android is something from a blog post by the Android team: All Android phones use "Mobile" in the UserAgent string, so checking for "Mobile" *and "Android" will tell you if it's a phone, while just "Android" should be a tablet. iOS devices should be just as simple--checking for "iPhone" vs "iPad" seems to have worked so far.
I know this is a little late, but I was looking for the same thing.
Wurfl has wat you want. You can implement it easily and and even have an api you can query.
For ASP.NET application first you must place the one-off initialization.
public class Global : HttpApplication
{
public const String WurflDataFilePath = "~/App_Data/wurfl.zip";
private void Application_Start(Object sender, EventArgs e)
{
var wurflDataFile = HttpContext.Current.Server.MapPath(WurflDataFilePath);
var configurer = new InMemoryConfigurer().MainFile(wurflDataFile);
var manager = WURFLManagerBuilder.Build(configurer);
HttpContext.Current.Cache[WurflManagerCacheKey] = manager;
}
}
And then use it like this.
var device = WURFLManagerBuilder.Instance.GetDeviceForRequest(userAgent);
var isTablet = device.GetCapability("is_tablet");
var isSmartphone = device.GetCapability("is_smartphone");
For more info check ASP.NET implementation
Hope this helps anyone else looking for this.
You can try to do a user agent detection and search for the keywrords, for example, all Non tablet devices have a "Mobile Safari" key words on their user agent.

Reading timecode track data using the C# version of Quicktime

I'm using the .Net activeX component of Quicktime.
I would like to read the timecode track data contained in a QTMovie track.
I can already select my timecode track like this :
// Valid Quicktime movie
QTMovie movie;
QTUtils qtu = new QTUtils();
for (int i = 1; i <= movie.Tracks.Count; i++)
{
if (movie.Tracks[i].Type == qtu.StringToFourCharCode("tmcd"))
{
QTTrack tcTrack = movie.Tracks[i];
//
// Timecode data reading ?
//
}
Is there a way to extract the timecode data?
Thank you for your help!
I asked a very similar question regarding applescript and timecode. The workaround was to use another app, an open source, command line app called timecodereader available here. I'm not sure if it's cross platform, but you might be able to glean something from the sourc code.
HTH

Categories