我目前正在开发一个凤凰网站,并有一个应该在后台播放的视频部分。
虽然它适用于Chrome& Firefox,它不适用于Safari。
我怀疑是因为牛仔没有正确地提供HTTP范围请求。
有没有办法启用(如果默认禁用)?
$ curl -H Range:bytes=16- -I http://localhost:4000/videos/vid_home_1.mp4
HTTP/1.1 200 OK
server: Cowboy
date: Tue, 12 Apr 2016 14:41:20 GMT
content-length: 633787
cache-control: public
etag: 480A03F
content-type: video/mp4
当它应该是一个206,如nginx服务器所示:
$ curl -H Range:bytes=16- -I http://localhost/videos/vid_home_1.mp4
HTTP/1.1 206 Partial Content
Server: nginx/1.8.0
Date: Tue, 12 Apr 2016 14:46:17 GMT
Content-Type: video/mp4
Content-Length: 633771
Last-Modified: Mon, 11 Apr 2016 12:26:26 GMT
Connection: keep-alive
ETag: "570b97f2-9abbb"
Content-Range: bytes 16-633786/633787
答案 0 :(得分:2)
我找到了一种方法来自己使用Plugs ... 所以如果有人想用凤凰城/ Elixir服务范围请求这就是你要做的事情(这是非常基本的,不考虑rfc)
public class Main_Act extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button startBtn = (Button) findViewById(R.id.button);
startBtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
if(sendSMS()) {
Intent intent = new Intent(Main_Act.this, Sample.class);
startActivity(intent);
}
}
});
}
protected boolean sendSMS() {
ArrayList<String> nums = new ArrayList<String>();
nums.add("111111111");
nums.add("222222222");
Log.i("Send SMS", "");
Intent smsIntent = new Intent(Intent.ACTION_VIEW);
smsIntent.setData(Uri.parse("smsto:"));
smsIntent.setType("vnd.android-dir/mms-sms");
smsIntent.putExtra("address" ,nums);
smsIntent.putExtra("sms_body" , "Test ");
try {
startActivity(smsIntent);
finish();
return true;
}
catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(Main_Act.this,
"SMS faild, please try again later.", Toast.LENGTH_SHORT).show();
return false;
}
}
}
正如您所看到的,现在,它只会发送“video / mp4”内容类型,但您可以轻松地为所有内容生效...
最后,要使Plug工作,您需要将它放在Project Endpoint文件中的Plug.static之前。
希望它有所帮助...
编辑:
对于那些感兴趣的人,我为此创建了一个github / hex.pm包:
Hex link
github link
答案 1 :(得分:0)
看起来牛仔还没有支持Range
标题,所以你需要使用不同的网络服务器。