In WP8 I had to get the list of songs from "MusicLibrary" class and play it through the "MediaPlayer" class. It was simple enough. But both of these are gone in 8.1. Actually pretty much everything is gone. Even simple things like page navigation syntax has changed completely (and I don't see any logical reason behind doing that)
Can someone tell me how I can get the list of songs in the user's phone in WP8.1? And how to play them in the background? I can't find any documentation on 8.1 on the net at the moment. After a lot of googling I only managed to find one example which showed how to play a file from isolated storage. Please help..
I think you are targeting windows phone 8.1 (Windows Run time version) If you target windows phone 8.1 Silverlight almost everything is same as windows phone 8. Windows phone 8.1 winRt is targeted for code re-usability on window phone and windows store app. So if you are targeting both platforms then try to Use Universal Apps.
Edit
For Player use <MediaElement... and for accessing Music library use below code.
var folder = Windows.Storage.KnownFolders.MusicLibrary;
var files = await folder.GetFilesAsync();
Hope this helps.
Related
How to get current media queue in windows phone 8.1 (runtime) as in windows phone 8 MediaPlayer.Queue
Is it available or we have to implement?
Similarly IsShuffled functionality is there ?
The MediaPlayer API belongs to the Microsoft.Xna.Framework.Media namespace which is no longer available for WinRT components. So you can't use it but you can implement your own logic for it using the MediaElement API which has sufficient properties for a media player except for the logic of queuing etc.
The explanation here and the msdn-code-sample would surely help you out.
For background music player you should use the SystemMediaTransportControls API and attach the events that occur when your app is running in background.
This link has a background audio explanation. Seems helpful.
Trying to handle multi-resolution images in a Windows Phone Universal App I came across this article from Microsoft.
Unfortunately it only applies to Windows Phone 8 and Windows Phone Silverlight 8.1.
When using the code samples they mention of:
private static bool IsWvga
{
get
{
return App.Current.Host.Content.ScaleFactor == 100;
}
}
In this case App.Current doesn't have a Host property - Host presumably being the SilverlightHost property mentioned here.
Has anyone found a way to do the equivalent in an 8.1 Universal App?
If you want to handle image scaling then it is handled by folder name in Windows Phone 8.1 Universal Apps. Here is how:
To use these images in XAML you just give the file name and the OS does the rest.
<Image Grid.Row="1" Grid.Column="0" Source="wpimages/resolution.jpg" VerticalAlignment="Top" Width="100"/>
An additional method is simply to have multiple copies of the image at different scales and to name them in the same way as the folders i.e resolution.scale-100.jpg, resolution.scale-240.jpg. You still name the file the same in your XAML.
I will share an article on that in the future.
Quick update about Universal Windows Apps (UWP, Apps for Windows 10).
Microsoft extended the automatic scaling support in UWP and now supports more different scales (probably the most complete list is here - around 16 different, from 100% to 500%).
According to the article Porting Windows Runtime 8.x XAML and UI to UWP you just need to use 100/200/400:
Providing assets at 100%-scale, 200%-scale, and 400%-scale (in that priority order) will give you excellent results in most cases at all the intermediate scale factors.
Additionally, UWP supports different qualifiers (languages, scales, etc).
Please read How to name resources using qualifiers (XAML)
On the personal side, I prefer to keep images in one folder, just to make life easier. It is easy to check if you have all the resolutions, it is easy to manage images (copy/delete/etc). Folders is way to go for Android, filenames - for iOS, Windows 10 supports both ways and it's great!
So, our Windows Phone developer left recently, and I primarily do Android development.
We had a question from a client about the possibility of installing our Windows Phone 8 app on a Surface Tablet. Namely, is it possible to do? As it stands, our WP8 app was not written with tablets in mind, so my question is:
Is there anything I need to do to the WP8 app to get it to install on a tablet, (should it work as-is (like Android apps do), is there some sort of flag I have to enable and then rebuild, etc.?)
As #AMR mentions, the biggest challenge will be the UI; however, depending on the device functionality being used, the "backend" may or may not be a challenge as well.
There is great guidance on the Windows Phone Dev Center about practices and techniques for building for both platforms, so depending on when the phone app was built and your former developer's awareness of the overlapping platforms, you could be in great shape or just so-so shape.
Additionally, the following resources may be of help in mapping from what you have already coded in Windows Phone 8 to what you'd do in Windows 8:
XAML controls comparison between Windows Phone 8 and Windows 8
(much will be relevant to Windows Phone 7 too)
Windows Phone 8 and Windows 8 platform comparison (shows common
APIs, storage, networking, etc.)
Lastly, the Windows Phone Runtime API documentation gives a listing
of APIs only on Phone 8 vs. APIs adopted from Windows 8.
Okay well first off yes, there will be a few things that change but nothing to serious.
HOPFULLY you have a good MVVM model. If this is the case then you should be able to just copy and paste 99.999% of your backend code right into your tablet app. There are a few things that are different but its just namespace stuff. Nothing too serious.
The Major change is going to be your UI layout and UI controls. Depending on what libs you are using you will probably have a lot of conflicts.
Your best bet is to just copy and paste your backend code in and then creating a new UI. I have tried to merge phone UIs in the paste into the tablet and its rediculous at times. I found it takes less time to just recreate it.
If you need any help you can hit me up at www.AnthonyRussell.info Maybe I can help with your transfer. Just make sure to leave your contact info.
I recently started doing some development in the Windows Phone 8 OS I'm pretty new on this. I was doing some searching about the fact to create an app who play any audio for some specific events/actions.
I was reading the Windows Phone API reference from Windows Phone Dev Center http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff626516%28v=vs.105%29.aspx#BKMK_Win32andCOMAPIforWindowsPhone
But it seems a little confusing to me at first glance and I have the doubt of which one of the following should I use to accomplish my task.
The .Net API for Windows Phone
Win 32 and COM API
... or the Windows Phone Runtime API
Any help would be very appreciate
It really depends what you're trying to do. If you're writing a native application or are interested in cross-compatability with Windows 8 then XAudio2 or the WinRT APIs are definitely the way to go. If you just want to play some infrequent sounds (say, when you pop up a warning dialog) from within a XAML app then I have seen a number of approaches, teh easiest of which is probably just having a MediaElement in your XAML that you use to play the audio.
It is somehow possible to observe foreground applications in Windows Phone 8?
Observe the name of the opened app and maybe time of opening and closing.
Thanks a lot in advance.
There's no API in the WP8 SDK that would return that information. If that's a feature you'd like to see in future releases go to the wpdev uservoice, explain you usecase and get developers to vote on it.