How to get Track Source in BackgroundMediaPlayer in Windows Phone 8.1 - c#

Code in WP8.0
if (BackgroundAudioPlayer.Instance.PlayerState == PlayState.Playing)
{
if (BackgroundAudioPlayer.Instance != null && BackgroundAudioPlayer.Instance.Track.Source.ToString().Contains("Claps.mp3"))
{
BackgroundAudioPlayer.Instance.Stop();
}
}
When i Convert this code into WP8.1 Universal Apps, Replaced BackgroundAudioPlayer With BackgroundMediaPlayer, and i tried the below code
if(BackgroundMediaPlayer.Current.CurrentState==MediaPlayerState.Playing)
{
if(BackgroundMediaPlayer.Current!=null && )
{
BackgroundMediaPlayer.Current.Pause();
}
}
For Second if condition compare the present source track with user input. How get present Track Source in BackgroundMediaPlayer. Please Help me to solve this error.

There is no way to directly get the source from the media player. You need to make your own mechanism for saving the source somewhere after setting it (like local settings) and then checking it.

Related

Trying Upload same file in windows form

I am working to develop a Windows form Project, we should use a Product picture.
Every this working well, we use File.Exists() to check if the file already exists then copy the image to the product Image folder.
if (image.ShowDialog() == DialogResult.OK && !string.IsNullOrEmpty(image.FileName))
{
_view.FirmLogo.Image = new Bitmap(image.FileName);
_view.LogoURL = Path.Combine(System.IO.Path.GetFullPath(#"..\..\"), #"Resources\ProductImage\", Path.GetFileName(image.FileName));
//
if (File.Exists(_view.LogoURL))
{
File.Delete(_view.LogoURL);
}
//File.Move(#"c:\test\SomeFile.txt", #"c:\test\Test\SomeFile.txt");
File.Copy(image.FileName, _view.LogoURL);
}
The Bug
when we try to update the same file it fired an error:
"because it is being used by another process.
Ex. if we upload pic1, everything is well, we try to change to pic2 great job.
but if we try to back the pic1 fired the error especially if it happens in the same seesion.

How to get Image Account of user currently logged on Windows?

Searching on the web I found this code UWP, to get the image but I'm not be able to include namespace Windows.Storage in WPF. I tried to include all possible references but doesn't work. I would have a solution WPF to include Windows.Storage(if possible) or simply another way to implement code to get image
StorageFile image = UserInformation.GetAccountPicture(AccountPictureKind.SmallImage) as StorageFile;
if (image != null)
{
rootPage.NotifyUser("SmallImage path = " + image.Path, NotifyType.StatusMessage);
}
else
{
rootPage.NotifyUser("Small Account Picture is not available", NotifyType.StatusMessage);
mediaPlayer.Visibility = Visibility.Collapsed;
smallImage.Visibility = Visibility.Collapsed;
largeImage.Visibility = Visibility.Collapsed;
}
The Windows.​System.​User​Profile namespace is for UWP app development and does not apply to WPF.
You may be able to use it if you package (convert) your app to UWP: https://learn.microsoft.com/sv-se/windows/uwp/porting/desktop-to-uwp-supported-api#apis-supported-in-both-converted-apps-and-desktop-applications. Note that the UserInformation class is not supported on Windows 10 or later. Instead, you should use the User class.
In a .NET application, you could try to search the C:\Users\<user>\AppData\Roaming\Microsoft\Windows\Account Pictures folder for the latest modified file:
How to find the most recent file in a directory using .NET, and without looping?
Based on this answer if you take a look here
As long as you have the currently logged in username, you should be able to access it. This is the case for Win OS 7 at least, I don't know which OS you're working with.

Proper way to detect that a UWP app is running on a small-screen device (phone)

Having read about this, I feel there is still an un-answered question about detecting whether a UWP app is running on a device where it would be appropriate to display in portrait only.
The optimal page layouts for our UWP app are such that on a phone, it's best that we disable landscape mode (we don't need such a restriction for larger format devices). What would be the best-practice approach to accomplish this?
You can detect the device family using AnalyticsInfo.VersionInfo.DeviceFamily.
if(AnalyticsInfo.VersionInfo.DeviceFamily == "Windows.Mobile") {
// It's a phone
}
else {
// It's not a phone
}
if ((Window.Current.Bounds.Width < 640) && (Window.Current.Bounds.Height < 550))
{
//Do something
}
Best of luck .
You can also test with hardware buttons availability , but not every phone has them !
public Platform DetectPlatform()
{
bool isHardwareButtonsAPIPresent = ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons");
if (isHardwareButtonsAPIPresent)
{
return Platform.WindowsPhone;
}
else
{
return Platform.Windows;
}
}
You can check for the hardware back button.
Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")

Windows 10 lock screen slideshow from RSS doesn't work (RequestSetImageFeedAsync)

I made the app in which I use method public static IAsyncOperation<SetImageFeedResult> RequestSetImageFeedAsync(Uri syndicationFeedUri) to play lock screen slideshow from external RSS feed in Windows 8. I use next Uri https://urzagatherer.azure-mobile.net/api/wallpapers and it works perfectly in Windows 8 (8.1). But when I run my App in Windows 10 and set the same Uri, lock screen slideshow doesn't play. Could somebody tell me, what is the problem?
I use following code:
SetImageFeedResult result = await LockScreen.RequestSetImageFeedAsync(new Uri("https://urzagatherer.azure-mobile.net/api/wallpapers"));
if (result == SetImageFeedResult.Success)
{
AddImageFeedScenarioOutputText.Text = "Called RequestSetImageFeedAsync: the specified URL was set as the default.";
}
else if (result == SetImageFeedResult.ChangeDisabled)
{
AddImageFeedScenarioOutputText.Text = "Called RequestSetImageFeedAsync: call succeeded but group policy has the lock screen image slide show turned off.";
}
else // (result == SetImageFeedResult.UserCanceled)
{
AddImageFeedScenarioOutputText.Text = "Called RequestSetImageFeedAsync: the specified URL was not set as the default.";
}
result is always equal SetImageFeedResult.Success
For your question, it seems that this method is working with windows 8.1 only
From Microsoft Docs:
LockScreen.RequestSetImageFeedAsync(Uri)
Registers an RSS image feed to be used as a lock screen slideshow. (Windows 8.1 only)

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