2014-05-06 26 views
1

我試圖追加到與jQuery ajax媒體源緩衝區。jQuery ajax不能與'blob'dataType

以下總是導致error

$.ajax({url: 'streaminit.mp4', dataType: 'blob', async: false, 
        error: function() { 
         console.log('error'); 
        }}).done(function(frag) { 
        sourceBuffer.appendBuffer(new Uint8Array(frag)); 
        console.log(new Uint8Array(frag)); 
       }); 

請求工作,如果我設置dataTypetext但隨後追加源時失敗。我認爲,因爲這種類型是錯誤的。

+2

'dataType'可以是xml,json,script或html - https://api.jquery.com/jQuery.ajax/ – Blazemonger

+0

http://stackoverflow.com/questions/7327776/jq uery-ajax-stream-audio-in-binary-format – Blazemonger

回答

0

您需要將數組類型傳遞到Uint8Array才能使用。請嘗試返回JSON,如:

{ 'data': [] } 
0

看起來球隊已經計劃在jQuery的1.12

信息來實現here

我想在那之前我就與XMLHttpRequest()堅持

+0

第一個鏈接如何相關?它只是在談論刪除遺留選項 –

+0

@GeorgeMauer刪除 – andrew