質問

I am trying to share a photo from media library via SharedMediaTask but I am getting error from GetPath(). The error says:

Error 1 'Microsoft.Xna.Framework.Media.MediaLibrary' does not contain a definition for 'GetPath' and the best extension method overload...

Here is my code for photo sharing via SharedMediaTask:

//Open Saved image from isolated storage
IsolatedStorageFile Store = IsolatedStorageFile.GetUserStoreForApplication();
IsolatedStorageFileStream toShare = new IsolatedStorageFileStream(filePath1, FileMode.Open, FileAccess.ReadWrite, Store);

//Save image to media library
MediaLibrary library = new MediaLibrary();
library.SavePicture("Memefy_Photo", toShare);

//Open ShareMediaTask
var task = new ShareMediaTask();
task.FilePath = library.GetPath(); //<----THIS is where the error appears :(
task.Show();

Also I have use this using Microsoft.Xna.Framework.Media.PhoneExtensions; to enable the GetPath() as it is needed based on my research.

Any guidance is greatly appreciated.

役に立ちましたか?

解決

GetPath is defined on the picture, not on the media library.

//Save image to media library
MediaLibrary library = new MediaLibrary();
var picture = library.SavePicture("Memefy_Photo", toShare);

//Open ShareMediaTask
var task = new ShareMediaTask();
task.FilePath = picture.GetPath();
task.Show();
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top