First, there is an HTTP server on WP
http://wphttpserver.codeplex.com/
How to use:
1234567891011121314151617181920212223 |
// create the http server
// http://www.liubaicai.net/archives/458
HttpServer httpServer =
new HttpServer(
"192.168.2.102"
);
// register an request handler which will handle the posted form data
httpServer.RegisterRequestHandler(
new Regex(
"/sendSms"
), request =>
{
// get the data send as form data
FormDataContentProvider formDataProvider = request.Content
as FormDataContentProvider;
// read the data from the form
string number = formDataProvider.FormData[
"number"
];
string message = formDataProvider.FormData[
"message"
];
// use the windows phone SMS api to send a SMS
SmsComposeTask smsTask =
new SmsComposeTask();
smsTask.To = number;
smsTask.Body = message;
smsTask.Show();
// tell the client, that everything went fine
return new HttpResponse(HttpStatusCode.Ok);
});
|
It is very simple to transplant to WIN10UAP.
We can use this server to make a local or LAN media Player.
Here are a few points to be aware of.
1. When reading and writing media files, use functions such as the Openstreamforreadasync of the Storagefile class to directly convert the file stream to the network stream instead of using the read-write file method in FileIO.
2. When responding to a request, be sure to set Content-type to be recognized by the client player. You can also add additional headers, as needed.
1 |
response.Headers.Add( "Content-Type" , "application/octet-stream" ); |
3. When returning media data, use Binarycontextprovider instead of other contextprovider.
Win (Phone) 10 Development of (5) Bullets, local media server some considerations