windows phone - 如何获取图片名称

windows phone - how to get picked picture name

我的 windows phone 混合应用正在从我的图库中挑选一个视频。 我的目标是获取 selected 视频的名称。

为此,我使用 FileOpenPicker 对象并将其包装在我的 cordova/phonegap 插件中。

我必须打开我的画廊并选择一个视频,但是当我 select 它时,我只是在我的输出中收到这个 windows:

*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.1cordovavs2013

这是我的工作解决方案:

    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);
         }
    }