[WP8.1]无法将大尺寸视频上传到Windows Phone 8中的服务器 [英] [WP8.1]Unable to upload large size videos to the server in windows phone 8
问题描述
我正在开发windows phone 8应用程序,我需要在其中记录并将12秒视频上传到服务器。我正在使用restsharp工具包上传视频。但是,当我尝试录制和上传视频时,获得Outofmemory异常。但是同样的
代码在模拟器中工作正常。 我对这个问题不太了解,有人可以帮忙吗?
I使用以下代码将视频上传到服务器。
public void postVideofile()
{
customIndeterminateProgressBar.Visibility =可见度。可见;
tbkloading.Visibility = Visibility.Visible;
isoVideoFile = new IsolatedStorageFileStream(isoVideoFileName,FileMode.Open,FileAccess.Read,IsolatedStorageFile.GetUserStoreForApplication());
StreamReader reader = new StreamReader(isoVideoFile);
DateTime dt = DateTime.Now;
////通过添加服务器URL,参数和文件来准备RestRequest ...
RestRequest request = new RestRequest(" http://slv1.socialnetgate.com/v1/files/postVideofile", Method.POST);
request.AddParameter(" apikey"," ******");
request.AddParameter(" userID"," ****");
request.AddFile(" uploadedfile",App.ReadToEnd(reader.BaseStream),isoVideoFileName);
request.AddParameter(" uploadID",dt);
//使用restClient调用服务器
RestClient restClient = new RestClient();
restClient.ClearHandlers();
restClient.AddHandler(" application / json",new XmlDeserializer());
restClient.AddHandler(" text / json",new XmlDeserializer());
restClient.ExecuteAsync(request,(response)=>
{
if(response.StatusCode == HttpStatusCode.OK)
{
string err = response.ErrorMessage;
String res = response.Content;
JObject results = JObject.Parse(res);
string jsonStatus =(string)results [" header"] [" description"];
string url =(string)results [" URL"];
}
else
{
MessageBox.Show("检查你的互联网连接!请再试一次);
}
});
}
Nikitha
$
我建议使用后台转移服务。 我假设您说Windows Phone 8时指的是Silverlight应用程序:
https://msdn.microsoft.com/en-us/library/windows/apps/hh202955(v=vs.105).aspx
Hi, I'm developing windows phone 8 app in which I need to record and upload the 12 seconds video to the server. I'm using restsharp toolkit to upload videos. However, when I try to record and upload the video, getting Outofmemory exception. But this same code is working fine in Emulator. I don't have much idea of this issue , can any one help please ?
I'm using the below code to upload the videos to server.
public void postVideofile() { customIndeterminateProgressBar.Visibility = Visibility.Visible; tbkloading.Visibility = Visibility.Visible; isoVideoFile = new IsolatedStorageFileStream(isoVideoFileName, FileMode.Open, FileAccess.Read, IsolatedStorageFile.GetUserStoreForApplication()); StreamReader reader = new StreamReader(isoVideoFile); DateTime dt = DateTime.Now; ////preparing RestRequest by adding server url, parameteres and files... RestRequest request = new RestRequest("http://slv1.socialnetgate.com/v1/files/postVideofile", Method.POST); request.AddParameter("apikey", "******"); request.AddParameter("userID", "****"); request.AddFile("uploadedfile", App.ReadToEnd(reader.BaseStream), isoVideoFileName); request.AddParameter("uploadID", dt); //calling server with restClient RestClient restClient = new RestClient(); restClient.ClearHandlers(); restClient.AddHandler("application/json", new XmlDeserializer()); restClient.AddHandler("text/json", new XmlDeserializer()); restClient.ExecuteAsync(request, (response) => { if (response.StatusCode == HttpStatusCode.OK) { string err = response.ErrorMessage; String res = response.Content; JObject results = JObject.Parse(res); string jsonStatus = (string)results["header"]["description"]; string url = (string)results["URL"]; } else { MessageBox.Show("Check your internet connection! Please try again"); } }); }
Nikitha
I would suggest using the Background Transfer Service for this. I am assuming when you say Windows Phone 8 you are referring to a Silverlight App:
https://msdn.microsoft.com/en-us/library/windows/apps/hh202955(v=vs.105).aspx
这篇关于[WP8.1]无法将大尺寸视频上传到Windows Phone 8中的服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!