Select music file in windows phone 8 - c#

I want to create an app which will let the user open an mp3 file.
I am using FileOpenPicker but get the error while creating an object of FileOpenPicker itself.
FileOpenPicker filePicker = new FileOpenPicker();
This line is throwing an error:
An exception of type 'System.NotSupportedException' occurred in PhoneApp1.DLL but was not handled in user code.
Can someone tell me what is the problem here.

Windows phone 8 don't support the FileOpenPicker https://wpdev.uservoice.com/forums/110705-dev-platform/suggestions/1897833-video-chooser-task. This feature was added in the windows phone 8.1

From MSDN:
In Windows 8 if you attempt to display the file picker while your app is snapped, the file picker will not be shown and an exception will be thrown. You can avoid this by making sure your app is not snapped, or by unsnapping it before you call the file picker.
Link to Class: http://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.pickers.fileopenpicker?cs-save-lang=1&cs-lang=csharp#code-snippet-1

Related

WPD C# Windows Phone

I am new to Windows Phone developing and I am trying to copy a file from PC to Windows Phone Documents folder. I read and tried what is written in this article Copy files with WPD to Windows Phone C#. The original article is https://dzone.com/articles/creating-apis-for-mobile-iot-apps. Unfortunately I got an error of ArgumentException in the line:
targetStream.Write(buffer, bytesRead, pcbWritten);
I think it's related to the parameter ParentObjectID, when I call the method:
device.TransferContentToDevice(#"H:\temp\QuestPhone\Pesquisas.db",#"G:\Documents");
I tried to replace "G:\Documents" by "Windows Phone:\Documents", and "Phone:\Documents" and "Windows Phone:\Phone\Documents" but without success.
So, how can I specify the "logical drive" where my Windows Phone device is connected to?
After some time I got a solution. The correct ParentObjectID is #"o1". "o1" is the ID of documents folder on the device.

Touchscreen friendly file picker in Windows 10

I am looking for a touchscreen-friendly file picker for Windows 10. In Windows 8 and 8.1, i used FileOpenPicker:
FileOpenPicker fileOpenPicker = new FileOpenPicker();
fileOpenPicker.FileTypeFilter.Add(".wma");
fileOpenPicker.FileTypeFilter.Add(".mp3");
fileOpenPicker.SuggestedStartLocation = PickerLocationId.VideosLibrary;
fileOpenPicker.ViewMode = PickerViewMode.List;
IReadOnlyList<StorageFile> files = await fileOpenPicker.PickMultipleFilesAsync();
which produced a nice interface (example), but in Windows 10, the same code displays the same interface as OpenFileDialog would (example), which is very hard to use on a touchscreen. Does anyone know how to get Windows 8/8.1 style FileOpenPicker in Windows 10, or knows an alternative?
In my application I have ask user to select folder (with standard folder picker that is not much touch friendly), but after this I have shown my own custom control that have display files in folder and let them select in touch friendly manner.

Unable to open camera in window 8 store app using c#

I am the beginner on window 8 store app,still i am working on the app in which i have to open camera and capture the image, but when i try to execute following line of code, its throws following exception.
I am using following line of code
Windows.Media.Capture.CameraCaptureUI dialog = new CameraCaptureUI();
And throwing following exception
Requested Windows Runtime type 'Windows.Media.Capture.CameraCaptureUI' is not registered.
Please advise
thanks in advance
Maybe because you are on an emulator? Can you reproduce the error on a real device?

So there is no way to access videos on Windows Phone 8?

I need to access videos on camera roll and also on Music+Video. but it seems there is no way at all.
Here in the documentation says we can use:
MediaLibrary library = new MediaLibrary();
But it only can access musics.
Can we say I should forget this thing for ever in WP8?
Unfortunately, there is no way to access videos in Media Library.
You have read-write access only to audio and photos.
See this answer: https://stackoverflow.com/a/13473349/1029518
There are a couple answers in the following thread which points out it is now feasible to read the video files via KnownFolders if you upgrade to Windows Phone 8.1: Windows Phone 8: Media file access
Here is an alternative option for accessing the videos (also in Windows Phone 8.1):
FileOpenPicker picker = new FileOpenPicker();
picker.ViewMode = PickerViewMode.Thumbnail;
picker.SuggestedStartLocation = PickerLocationId.VideosLibrary;
picker.FileTypeFilter.Add(".mp4");
picker.PickSingleFileAndContinue();
Once you have the file you should be able to play it back.

Obtain Access Into the Camera Roll Windows Phone 8

I am having an issue getting into the camera roll folder for Windows Phone 8. Unfortunately due to the project being a MonoGame Project, the MediaLibrary object is not implemented and thus does not work. I am left with having to directly tap into the camera roll folder directly, through I am getting an
Access Denied
Error as a result. The idea is that if I know the location of the file in the future, I can display it in certain parts of my app after the user has taken a photo using the app. The code is as follows:
StorageFile folder = await StorageFile.GetFileFromPathAsync("Pictures\\Camera Roll\\WP_20130227_001.jpg");
I have also checked off:
ID_MEDIALIB_PHOTO
and am still getting the error.
Any help is greatly appreciated!
Try using the photochoosertask..
PhotoChooserTask selectphoto = new PhotoChooserTask();
selectphoto.Completed += new EventHandler<PhotoResult>(selectphoto_Completed);
selectphoto.Show();
this might help.

Categories

Resources