2015-02-23 67 views
0

即時通訊相當新的C#和即時通訊嘗試我看看製作Windows手機應用程序,在應用程序中,我需要它來減少視頻文件。經過搜索和詢問周圍人的時間向我指出這個 https://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh868176.aspx修剪視頻文件WPF C#

async void TrimVideoFile() 
{ 
Windows.Storage.StorageFile source; 
Windows.Storage.StorageFile destination; 

var openPicker = new Windows.Storage.Pickers.FileOpenPicker(); 

openPicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.VideosLibrary; 
openPicker.FileTypeFilter.Add(".wmv"); 
openPicker.FileTypeFilter.Add(".mp4"); 

source = await openPicker.PickSingleFileAsync(); 

var savePicker = new Windows.Storage.Pickers.FileSavePicker(); 

savePicker.SuggestedStartLocation = 
    Windows.Storage.Pickers.PickerLocationId.VideosLibrary; 

savePicker.DefaultFileExtension = ".mp4"; 
savePicker.SuggestedFileName = "New Video"; 

savePicker.FileTypeChoices.Add("MPEG4", new string[] { ".mp4" }); 

destination = await savePicker.PickSaveFileAsync(); 

// Method to perform the transcoding. 
TrimFile(source, destination); 

}

我已經在應用程序,我想提出使用這種嘗試,並在頁面

的Windows Phone上指出商店應用必須使用pickSingleFileAndContinue。

我已經嘗試過不同的代碼組合,正如剛纔陳述的一個新手。

我不斷收到不同的錯誤,是有任何人誰能夠如何得到這個對WP8.1工作

感謝

回答

0

當你使用的是Windows Phone平臺,您必須使用建議(如文檔和編譯器告訴你)PickSingleFileAndContinue()。這需要使用Continuation Manager,因此您可以在應用程序執行的位置選擇應用程序 - 在文件選擇處。

PickSaveFileAsync()也是如此,它必須是WP上的PickSaveFileAndContinue();再次,你需要延續經理。

現在,這兩種方法都是同步的,所以你不能使用await。

我想知道的東西:TrimFileasync void。如果將其更改爲async Task,則可以使用異步預先調用TrimFile並保持異步(因爲您不能等待void)。
我無法測試這是否正常工作,因爲我現在手上沒有WP設備。