zoukankan      html  css  js  c++  java
  • Win(Phone)10开发第(5)弹,本地媒体服务器的一些注意事项

    首先有个wp上的http服务器

    http://wphttpserver.codeplex.com/

    使用方式:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    // 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);
    });

    需要移植到win10uap上来,是很简单的。

    我们可以使用这个服务器来做一个本地或者局域网的媒体播放器。

    这里说几个需要注意的地方

    1.读写媒体文件时,使用StorageFile类的OpenStreamForReadAsync之类的功能,直接将文件流与网络流做转化,而不要使用FileIO中的读写文件方法。

    2.响应请求时,务必设置Content-Type才能被客户端播放器识别。根据需要,也可以添加其他Header。

    1
    response.Headers.Add("Content-Type", "application/octet-stream");

    3.返回媒体数据时,使用BinaryContextProvider而不是其他ContextProvider。

  • 相关阅读:
    索引访问中的access和filter
    分页SQL走全表扫描导致TEMP耗尽
    多表关联的分页SQL经典案例
    分页技术COUNT STOPKEY和SORT ORDER BY
    FILTER再来一例
    错误的选择了HASH JOIN!
    dojo加载树报错
    dojo中获取表格中某一行的某个值
    dojo处理删除操作报错
    分页语句优化
  • 原文地址:https://www.cnblogs.com/liubaicai/p/4414538.html
Copyright © 2011-2022 走看看