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。

  • 相关阅读:
    随机100道四则运算(文件储存)
    基于 GitBook 搭建个人博客
    ios常用第三方库git下载地址
    网络工程师经常会用到的终端仿真软件
    最常用的终端仿真程序 替代putty
    Linux 命令大全
    Nginx 安装配置
    nginx
    React函数组件和class组件以及Hook
    2020年前端面试题及答案
  • 原文地址:https://www.cnblogs.com/liubaicai/p/4414538.html
Copyright © 2011-2022 走看看