我的Windows手机混合应用程序正在从我的图库中选择一个视频。 我的目标是获取所选视频的名称。
为此,我使用 FileOpenPicker 对象并将其包装在我的cordova / phonegap插件中。
我必须打开我的画廊并选择一个视频,但当我选择它时,我只是在输出窗口中收到这个:
*thread 0x87c terminated code 259 (0x103).*
*INFO: AppDeactivated because UserAction
program'[184] AgHost.exe' terminated with 0 (0x0).*
我的插件代码:
class PickVideo : BaseCommand, IFileOpenPickerContinuable
{
public void pickOneVideo(string options) {
try {
Debug.WriteLine("pickOneVideo --------------------------------");
FileOpenPicker openPicker = new FileOpenPicker();
openPicker.SuggestedStartLocation = PickerLocationId.VideosLibrary;
openPicker.FileTypeFilter.Add(".wmv");
openPicker.FileTypeFilter.Add(".mp4");
openPicker.FileTypeFilter.Add(".wma");
openPicker.FileTypeFilter.Add(".mp3");
openPicker.ContinuationData["Operation"] = "GetOneVideo";
openPicker.PickSingleFileAndContinue();
}
catch (Exception e) {
Debug.WriteLine("e: " + e.Message);
}
// return path video
//DispatchCommandResult(new PluginResult(PluginResult.Status.OK, "path del video"));
}
public void ContinueFileOpenPicker(FileOpenPickerContinuationEventArgs args)
{
Debug.WriteLine("-- ContinueFileOpenPicker ---");
if (args.Files.Count > 0)
{
Debug.WriteLine( "Picked video: " + args.Files[0].Name);
}
else
{
Debug.WriteLine( "Operation cancelled.");
}
}
}
我正在使用与此处相同的ContinuationManager:https://msdn.microsoft.com/it-it/library/dn631755.aspx
所以我希望我的控件进入ContinueFileOpenPicker()
,我可以在那里检索我的视频名称。
我错过了什么?
我正在使用wp silverlight 8.1
,cordova
和vs2013
答案 0 :(得分:0)
这是我的工作解决方案:
public void pickOneVideo(string options) {
try {
FileOpenPicker openPicker = new FileOpenPicker();
openPicker.SuggestedStartLocation = PickerLocationId.VideosLibrary;
openPicker.FileTypeFilter.Add(".wmv");
openPicker.FileTypeFilter.Add(".mp4");
openPicker.FileTypeFilter.Add(".wma");
openPicker.FileTypeFilter.Add(".mp3");
openPicker.PickSingleFileAndContinue();
view.Activated += viewActivated;
}
catch (Exception e) {
Debug.WriteLine("e: " + e.Message);
}
// return path video
//DispatchCommandResult(new PluginResult(PluginResult.Status.OK, "path del video"));
}
private void viewActivated(CoreApplicationView sender, IActivatedEventArgs args1)
{
Debug.WriteLine("viewActivated ----");
FileOpenPickerContinuationEventArgs args = args1 as FileOpenPickerContinuationEventArgs;
if (args != null)
{
if (args.Files.Count == 0) return;
view.Activated -= viewActivated;
Debug.WriteLine("args: " + args.Files[0].Name);
}
}