Win (Phone) 10 Development of (5) Bullets, local media server some considerations

Source: Internet
Author: User

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 datahttpServer.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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.