小编Mar*_*S95的帖子

通过RTC数据通道发送图像数据

我试图通过a发送图像数据Data Channel,但它无法正常工作.刚从中获取数据时ctx.getImageData,我会"[Object ImageData]"在另一侧收到一个字符串.仅将数据块转换为blob会导致错误:Uncaught NetworkError: Failed to execute 'send' on 'RTCDataChannel': Could not send data.尝试将其转换为时,我得到了同样的错误ArrayBuffer.我该怎么做?

javascript canvas webrtc

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

从 FileEntry (或等效项)获取对象 URL

我目前正在通过执行以下操作来加载删除的文件:

var files = e.dataTransfer.items;
for (var i = 0; i < files.length; i++) {
    var file = files[i]; //typeof is 'DataTransferItem'
    var url = URL.createObjectURL(file);
}
Run Code Online (Sandbox Code Playgroud)

这会获取对象 url,然后我可以将其放入音乐播放器中。但是,当迭代输入的文件夹时:

var reader = entry.createReader();
reader.readEntries(function (res) {
    res.forEach(function (entry) {
        console.log('The entry:', entry);
        console.log('The url:', JSON.stringify(entry.toURL()));
    });
});
Run Code Online (Sandbox Code Playgroud)

我得到类型的文件FileEntry。据此我将能够执行file.toURL()并使用它来代替对象 url。这确实返回了一个空字符串。这似乎是有原因的,但我不知道如何解决这个问题。我看到一些有关 blob URL 的信息,但我不知道它是如何工作的。 示例 尝试将文件和文件夹拖到输出屏幕并自行查看

javascript blob file-upload

5
推荐指数
1
解决办法
2364
查看次数

Web音频5.1(6声道)输出

我试图通过一个channelsplitter带有增益控制的6个通道将立体声音频路由,然后返回到a channelMerger,以控制5.1组的所有6个通道.该组通过HDMI连接,并且窗口正确输出到所有6个通道(一个屏幕,您可以让所有6个扬声器分别播放声音).

我能找到的唯一例子就是这段代码:

if (context.destination.maxChannelCount >= 6) {
    context.destination.channelCount = 6;
}
else {
    context.destination.channelCount = 2;
}
Run Code Online (Sandbox Code Playgroud)

初始化audiocontext时,我的channelCount默认为2,maxChannelCount为6.

我使用以下代码在中间创建拆分器,合并和增益:

if (context.destination.maxChannelCount >= 6) {
    context.destination.channelCount = 6;
}
else {
    context.destination.channelCount = 2;
}

context.destination.channelCountMode = "explicit";
context.destination.channelInterpretation = "discrete";

var ammount = context.destination.channelCount;

console.log('Ammount of channels:',ammount); //this outputs 6

window.channelSplitter = context.createChannelSplitter(ammount);
window.channelMerger = context.createChannelMerger(ammount);

postGain.connect(channelSplitter); //postGain is the last node of the audio system
channelMerger.connect(context.destination);
window.channelGains = [];
for(i=0;i<ammount;i++){
    channelGains[i] = context.createGain();

    channelSplitter.connect(channelGains[i],i,0);
    channelGains[i].connect(channelMerger,0,i); …
Run Code Online (Sandbox Code Playgroud)

javascript web-audio-api

5
推荐指数
1
解决办法
1740
查看次数

启动时关闭表单

我编写了一个应用程序来检查启动时是否存在某些文件和文件夹.如果他们不这样做,我打电话this.Close();(因为我想退出整个申请).但是,我收到一个错误:ObjectDisposedErroron Application.Run(new MainForm());.我认为这与在成功加载表单之前调用.Close有关.我正在从MainForm.cs的公共MainForm()函数执行这些启动检查.这是正确的还是我需要把它放在别的地方?

我尝试过:使用委托运行它并调用:

public void CloseApplication() {
    if (this.InvokeRequired) {
        this.Invoke(new CloseGameDelegate(CloseApplication));
    } else {
        this.Close();
    }
}
public delegate void CloseGameDelegate();
Run Code Online (Sandbox Code Playgroud)

这仍然给我同样的错误.

使用Application.Exit():这只是打开表单.

c#

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

标签 统计

javascript ×3

blob ×1

c# ×1

canvas ×1

file-upload ×1

web-audio-api ×1

webrtc ×1