我们有一个视频流平台,用户可以在其中播放实时视频流并将其与一组演示幻灯片同步.要在iOS上显示广播,我们使用的是HTTP直播.为了在iOS上的流中正确显示幻灯片,我们正在收听qt_timedmetadataupdatedApple的Quicktime Javascript API提供的活动.这个方法在这里描述:
但是,在iOS8中,此方法不再有效,因此我们正在尝试寻找替代解决方案.
有没有人知道如何做到这一点?
我设法取得的唯一进展是检查"带内元数据文本轨道",如下所述:
https://github.com/videojs/videojs-contrib-hls#in-band-metadata
我使用flowplayer和flashls插件在下面设置了一个示例测试页面:
http://jsbin.com/vohicoxegi/1/edit?html,js,output
在代码中,我创建了一个间隔,每隔500ms检查一个文本轨道是否存在其kind属性metadata.我注意到当向流中注入一些定时元数据时,会创建其中一个文本轨道.但问题是我无法访问定时元数据中的数据,我需要正确地同步(前面提到的)幻灯片.
请注意,我只关注直播.播放现有媒体文件不是问题.
使用Node我正在尝试从LDAP服务器收集用户数据,然后将该数据写入JSON文件.我使用以下代码执行此操作:
fs.writeFile('data.json', JSON.stringify(data, null, 4));
Run Code Online (Sandbox Code Playgroud)
问题是该JSON.stringify方法导致以下错误:
FATAL ERROR: JS Allocation failed - process out of memory
Run Code Online (Sandbox Code Playgroud)
我知道问题在于JSON.stringify因为如果我使用console.log而不是fs.writeFile我得到相同的错误.
我正在尝试编写大量数据(LDAP数据库中有500多个条目).有谁知道我怎么能让这个工作?这是完整的代码:
var ldap = require('ldapjs');
var util = require('util');
var fs = require('fs');
var client = ldap.createClient({
url: '************'
});
client.bind('CN=**********,OU=Users,OU=LBi UK,OU=UK,DC=********,DC=local', '*********', function(err) {
if (err) {
console.log(err.name);
}
});
// taken from http://ldapjs.org/client.html
client.search('OU=Users,OU=******,OU=UK,DC=******,DC=local', {
scope: 'sub',
filter: 'objectClass=organizationalPerson',
attributes: ['givenName', 'dn', 'sn', 'title', 'department', 'thumbnailPhoto', 'manager']
// filter by organizational person
}, …Run Code Online (Sandbox Code Playgroud) 为什么嵌套的for loops工作方式与以下示例中的方式相同:
var times = [
["04/11/10", "86kg"],
["05/12/11", "90kg"],
["06/12/11", "89kg"]
];
for (var i = 0; i < times.length; i++) {
var newTimes = [];
for(var x = 0; x < times[i].length; x++) {
newTimes.push(times[i][x]);
console.log(newTimes);
}
}
Run Code Online (Sandbox Code Playgroud)
在这个例子中,我认为console.log会给我以下输出:
["04/11/10"]
["86kg"]
["05/12/11"]
["90kg"]
["06/12/11"]
["89kg"]
Run Code Online (Sandbox Code Playgroud)
但是,我实际上得到了这个:
["04/11/10"]
["04/11/10", "86kg"]
["05/12/11"]
["05/12/11", "90kg"]
["06/12/11"]
["06/12/11", "89kg"]
Run Code Online (Sandbox Code Playgroud)
有人能帮我理解这个吗?
编辑:
感谢您的所有回复!
我正在构建一个应用程序,其中使用HTML5地理位置找到用户的位置.一旦检索到它们的位置,它们的位置就会绘制在地图上(父路线).然后,他们可以选择查看在该位置(子路线)周围发布的推文列表.
所以,我需要将在父路由检索到的坐标(存储在控制器上)传递给子路由,这样我就可以正确地查询Twitter API.但是,我不确定如何做到这一点,或者即使我选择了最好的方法.
这是索引控制器:
App.IndexController = Ember.ObjectController.extend({
coords: false,
getGeoLocation: function() {
if (navigator.geolocation) {
this.set('retrieving', true);
navigator.geolocation.getCurrentPosition(
this.locationRetrieved.bind(this),
this.locationFailed.bind(this),
{
timeout: 20000
}
);
} else {
this.set('geolocation', false);
}
},
locationRetrieved: function(position) {
this.set('coords', position.coords);
this.get('target').transitionTo('what-do-you-want-to-know');
}
});
Run Code Online (Sandbox Code Playgroud)
WhatDoYouWantToKnow控制器"需要"索引控制器:
App.WhatDoYouWantToKnowController = Ember.ObjectController.extend({
needs: 'index',
createMap: function() {
var coords = this.get('controllers.index').get('coords');
var pyrmont = new google.maps.LatLng(coords.latitude, coords.longitude);
var map = new google.maps.Map(document.getElementById('map'), {
mapTypeId: google.maps.MapTypeId.ROADMAP,
center: pyrmont,
zoom: 8
});
var marker = new google.maps.Marker({
map: map,
position: …Run Code Online (Sandbox Code Playgroud) 我在渲染模型的'hasMany'部分时遇到了麻烦.我似乎对这个人有类似的问题,但我仍然无法弄清楚该怎么做.
这是相关的JS:
App.Router.map(function() {
this.resource('account', function() {
this.resource('transaction', {
path: '/transaction/:transaction_id'
});
});
});
App.AccountIndexRoute = Ember.Route.extend({
model: function() {
return App.Account.find();
}
});
App.TransactionRoute = Ember.Route.extend({
model: function() {
return App.Transaction.find();
}
});
App.Store = DS.Store.extend({
revision: 12,
adapter: 'DS.FixtureAdapter'
});
App.Account = DS.Model.extend({
title: DS.attr('string'),
transactions: DS.hasMany('App.Transaction')
});
App.Account.FIXTURES = [
{
id: 1,
title: 'Your account',
transactions: [1, 2, 3]
}];
App.Transaction = DS.Model.extend({
date: DS.attr('date'),
name: DS.attr('string'),
amount: DS.attr('number'),
paidWith: DS.attr('string'),
account: DS.belongsTo('App.Account')
}); …Run Code Online (Sandbox Code Playgroud) ember-data ×2
ember.js ×2
javascript ×2
arrays ×1
for-loop ×1
ios8 ×1
json ×1
ldap ×1
node.js ×1