gpt4 book ai didi

c# - 文件选取器的 Windows 8 手机应用代码错误

转载 作者:可可西里 更新时间:2023-11-01 11:30:23 25 4
gpt4 key购买 nike

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using PhoneApp4.Resources;
using Microsoft.Phone.Tasks;
using System.Windows.Media;
using System.Windows.Media.Animation;
using Windows.Storage.Pickers;
using Windows.Storage.FileProperties;
using System.IO;
using Windows.Storage;
using Windows.Storage.Streams;

namespace PhoneApp4
{
public partial class MainPage : PhoneApplicationPage
{

public MainPage()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
WebBrowserTask wbt = new WebBrowserTask();
wbt.Uri = new Uri("http://www.facebook.com", UriKind.Absolute);
wbt.Show();
}

private void Play_Click(object sender, RoutedEventArgs e)
{

medias.Play();

}

private void Pause_Click(object sender, RoutedEventArgs e)
{

medias.Pause();

}

private void Stop_Click(object sender, RoutedEventArgs e)
{

medias.Stop();
}



private async void Browse_Click(object sender, RoutedEventArgs e)
{
var openPicker = new FileOpenPicker();

// openPicker.SuggestedStartLocation = PickerLocationId.VideosLibrary;

openPicker.FileTypeFilter.Add(".mp3");

var file = await openPicker.PickSingleFileAsync();

var stream = await file.OpenAsync(FileAccessMode.Read);
stream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read);


if (null != file)
{
medias.SetSource(stream, file.ContentType);


}
}
}
}

代码是音频播放器,我想从存储中选择文件。在上面的代码中,以下代码会产生错误

if (null != file){  medias.SetSource(stream, file.ContentType); }  

错误是:- 方法“SetSource”的重载没有采用 2 个参数。任何人都可以帮我吗?麻烦如果有任何其他错误,请告诉我。

最佳答案

作为MSDN for FileOpenPicker说:

Windows Phone 8
This API is supported in native apps only.

编辑

正如 ToniPetrina 所说,您的代码可能存在更多问题。我已经指出了可能无法做你想做的事情。因为它也是mentioned here :

The FileOpenPicker in WP8 is simply a Windows Runtime wrapper over the same photo library functionality that's accessible from the managed PhotoChooserTask. We do not currently support choosing files other than photos or choosing files from other Store apps.

据我所知,很难将文件从 MediaLibrary 复制到 IsolatedStorage。如果有人展示了如何做,我也将不胜感激。

关于c# - 文件选取器的 Windows 8 手机应用代码错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21548366/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com