小编Tir*_*tha的帖子

使用节点JS的HLS流

我正在尝试使用node.js来传输HLS内容.不知怎的,它不起作用.如果有人帮助我,那将是非常有帮助的.

问题: - 尝试从node.js提供HLS内容(不是实时流,而是一组.ts文件和.m3u8播放列表,或者换句话说VOD内容)

文件夹结构

stream_test
|--- app.js
|--- node_modules
|--- streamcontent
        |--- test.m3u8
        |--- segment0.ts
        |--- segment1.ts
        .
        .
        .
        |--- segment127.ts
Run Code Online (Sandbox Code Playgroud)

app.js看起来像这样

var http = require('http'),
    url = require('url'),
    path = require('path'),
    fs = require('fs');
var mimeTypes = {
    "html": "text/html",
    "jpeg": "image/jpeg",
    "jpg": "image/jpeg",
    "png": "image/png",
    "js": "text/javascript",
    "css": "text/css",
    "ts": "video/MP2T",
    "m3u8": "application/vnd.apple.mpegurl"};

http.createServer(function(req, res) {
    var uri = url.parse(req.url).pathname;
    var filename = path.join(process.cwd(), unescape(uri));
    var stats;

    console.log('filename '+filename);

    try …
Run Code Online (Sandbox Code Playgroud)

ffmpeg video-streaming node.js http-live-streaming m3u8

8
推荐指数
1
解决办法
1万
查看次数

Javascript Prototype Chaining超类构造函数和方法调用

我是JavaScript世界的新手,当我尝试原型链接继承时,我想出了这个奇怪的问题.

我有3节课

//class parent
function parent(param_1){
    this.param = param_1;
    this.getObjWithParam = function(val){
        console.log("value in parent class "+val);
        console.log("Constructor parameter : "+this.param);
    };

};

//class child
function child(param_1){
    this.constructor(param_1);
    this.getObjWithParam = function(val){
        console.log("value in child class "+val);
        val = Number(val)+1;
        child.prototype.getObjWithParam.call(this, [val]);
    };
};
child.prototype = new parent();

//class grandChild
function grandChild(param_1){
    this.constructor(param_1);
};
grandChild.prototype = new child();


var gc = new grandChild(666);
gc.getObjWithParam(0);
Run Code Online (Sandbox Code Playgroud)

首先,我想将一个参数传递给父类的构造函数,就像它们通过在其他OO语言中调用super(args)一样.所以this.constructor(param_1);非常适合这个目的.

但是,输出结果为

value in parent class 0
Constructor parameter : 666
Run Code Online (Sandbox Code Playgroud)

这表明,类grandChild已跳过原型链,而不是调用child()类的getObjWithParam(),而是调用了父类的getObjWithParam().

有谁知道这里出了什么问题?

注意: 我想添加2个更多的发现,第二个是重要的发现. …

javascript constructor parameter-passing superclass

6
推荐指数
1
解决办法
4523
查看次数