arraybuffer

javascript readAsArrayBuffer returns empty Array Buffer

回眸只為那壹抹淺笑 提交于 2019-11-30 07:27:17
I am trying to read a local file using the FileReader readAsArrayBuffer property. The read is success and in the "onload" callback, I see the Array Buffer object in reader.result. But the Array Buffer is just empty. The length is set, but not the data. How do I get this data? Here is my code <!DOCTYPE html> <html> <body> <input type="file" id="file" /> </body> <script> function handleFileSelect(evt) { var files = evt.target.files; // FileList object var selFile = files[0]; var reader = new FileReader(); reader.onload = function(e) { console.log(e.target.result); }; reader.onerror = function(e)

How to decrypt an ArrayBuffer?

笑着哭i 提交于 2019-11-30 02:25:55
I've been trying to decrypt an ArrayBuffer object using CryptoJS, but so far it always returns a blank WordArray. The files (images) are encrypted in an iOS and Android app, sent to a server, and downloaded in this web app to be decrypted and displayed. The iOS and Android apps are able to decrypt the files without problems, so there's nothing wrong with the encryption process. The files are downloaded with an XMLHttpRequest with responseType set to arraybuffer . Here's my code so far: // Decrypt a Base64 encrypted string (this works perfectly) String.prototype.aesDecrypt = function(key) { var

How send arraybuffer as binary via Websocket?

寵の児 提交于 2019-11-30 00:11:49
I am working on a project with Mozilla Europe. In this project, I use websocket by Worlize (server-side) and Mozilla (client side), Node.js to try to upload files from a client to a server. My present goal is to send a arraybuffer of the file to the server. Create the arraybuffer and send it is fine. But my server tells me that arraybuffer is a utf8 message and not a binary message. Do I misunderstand something? If not, how can i correct that? Client side: reader = new FileReader(); reader.readAsArrayBuffer(file); reader.onload = function(e) { connection.send(e.target.result); }; Server side:

scala数组

牧云@^-^@ 提交于 2019-11-29 21:38:55
scala数组:分为定长数组和变长数组 scala> val arr1 = new Array[Int](8) //只定义8个是整型类型的定长数组,没有赋值,每个数组里面的值是0 arr1: Array[Int] = Array(0, 0, 0, 0, 0, 0, 0, 0) scala> val arr1 = new Array[String](8) //只定义8个是字符串类型的定长数组,没有赋值,每个值显示是为null arr1: Array[String] = Array(null, null, null, null, null, null, null, null) scala> println(arr1) //直接打印数组是一个引用,并没有打印出数组里面的内容。 [Ljava.lang.String;@4973f7dd scala> println( arr1.toBuffer ) //使用toBuffer方法将数组里面的内容转换成数组缓冲里面,将其打印出来。 ArrayBuffer(null, null, null, null, null, null, null, null) 下面是直接赋值方式定义一个数组: scala> val arr2 = Array("java","scala","python") //没有用new是调用的一个静态方法 ,并给数组里面每个元素赋值

scala02

一个人想着一个人 提交于 2019-11-29 18:58:00
scala02 课件 函数得定义 val funtionName=(param:ParamType...)=>{} 这种定义方式没有返回值类型,会自己进行适配 函数在 scala 中可以任务是一个可以使用得值 函数在放置得时候会显示签名信息,描述当前函数得一个描述信息文件 eg: 在 scala 中存在三种类型 class 类 object 对象 trait 特质(接口) 定义得函数其实在 scala 内部已经存在模板, function0-function22 我们根据参数得数量不一致可以得出 23 中函数 函数定义得复杂形式 scala> val add:(Int,Int)=>Int=(x,y)=>{x+y} add: (Int, Int) => Int = <function2> val func:(paramType...)=>returnType=(param...)=>{content} 如果直接放置函数则显示得是签名信息 function() 调用 高级函数得使用 scala> val a:(Int,Int)=>Int = add a: (Int, Int) => Int = <function2> scala> val b:(Int,Int)=>Int=add b: (Int, Int) => Int = <function2> 函数得放置类型,函数可以作为返回值

Serialize canvas content to ArrayBuffer and deserialize again

半城伤御伤魂 提交于 2019-11-29 17:49:26
问题 I have two canvas, and I want to pass the content of canvas1, serialize it to an ArrayBuffer, and then load it in canvas2. In the future I will send the canvas1 content to the server, process it, and return it to canvas2, but right now I just want to serialize and deserialize it. I found this way of getting the canvas info in bytes: var img1 = context.getImageData(0, 0, 400, 320); var binary = new Uint8Array(img1.data.length); for (var i = 0; i < img1.data.length; i++) { binary[i] = img1.data

Extracting the song frequency of an mp3 file using HTML5 web audio API

让人想犯罪 __ 提交于 2019-11-29 17:42:05
问题 I am using the HTML5 web audio API to analyse a song and create markers when the average sound frequency drops below a certain value. Using the existing AudioNode infrastructure, I managed to do this but the sound is analyzed only and only when the song is played. What I want however, is to analyse the song in advance, so I can extract the silence markers, and turn them into CUE buttons, which the user can use to move throughout the song. Obviously, it will be very slow to rely on playing the

javascript readAsArrayBuffer returns empty Array Buffer

戏子无情 提交于 2019-11-29 09:11:55
问题 I am trying to read a local file using the FileReader readAsArrayBuffer property. The read is success and in the "onload" callback, I see the Array Buffer object in reader.result. But the Array Buffer is just empty. The length is set, but not the data. How do I get this data? Here is my code <!DOCTYPE html> <html> <body> <input type="file" id="file" /> </body> <script> function handleFileSelect(evt) { var files = evt.target.files; // FileList object var selFile = files[0]; var reader = new

Scala(一)基础

回眸只為那壹抹淺笑 提交于 2019-11-29 08:31:23
OOP 面向对象编程 AOP 面向切面编程 FP 函数式编程 编程语言都要定义变量,一些代码是用来注释的,变量和变量之间有一些关系,要做一些运算,运算离不开流程控制,进行运算的数据往往来自数据结构,最基本的是数组。 所有编程语言的需要: 变量 注释 运算符 流程控制 数组 编码规范:命名、换行、缩进、分号 变量 在java中定义变量,必须要使用数据类型来声明。Scala中不用,只需要使用两个关键字来声明即可,var、val。 scala> var a = 1 a: Int = 1 scala> var b ="1" b: String = 1 scala> var c = 2.0 c: Double = 2.0 重要结论1:Scala在定义变量的时候,可以不用指定数据类型,当然也可以指定,如果不指定,编译器会自动推断。 不确定数据类型,不要指定数据类型,类型不匹配会报错 重要结论2:如果已经定义好的变量,就算定义时没有指定类型也一定已经确定了,这个使用var修饰的变量可以被改成相同类型的其他值,但是不能改成其他类型的值。 重要结论3:如果已经有一个变量 a:Int = 3,那么使用var a = "huangbo"这是可以执行的。var的作用就是告诉编译器,正在定义一个新的变量。 重要结论4:一个变量被val修饰,这个变量等同于java中的常量,就是使用final修饰的变量。

Saving ArrayBuffer in IndexedDB

隐身守侯 提交于 2019-11-29 07:34:10
How can I save binary data (in an ArrayBuffer object) into IndexedDB? The IndexedDB spec doesn't mention ArrayBuffer - does that mean that is not supported (and I have to pack ArrayBuffer as a string or a an array?). In the latest (nightly) builds of FF this is very easy. See this bug . window.BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder; var bb = new BlobBuilder(); bb.append(arrayBuffer); var myblob = bb.getBlob(); indexedDB.open("mydatabase").onsuccess = function(e) { var db = e.result; var trans = db.transaction(["objectstore1", "objectstore2", READ