1
當我使用的事件處理程序:火狐等待loadedmetadata事件
video.on( 「等待loadedmetadata」,函數(){...})
火狐似乎不正確時,設置視頻尺寸回調被稱爲。 Chrome工作得很好。有沒有辦法在Firefox上正確地獲取視頻尺寸?
編輯: 它似乎工作,如果我把一個調試器,並通過代碼手動運行。這讓我相信這是一種競爭條件。但是這對我來說沒有任何意義,因爲該方法被調用,這意味着該事件應該正確發生=維度應該被設置。
下面的代碼片段:
$("document").ready() ->
# Setup variables
video = $("#video")
toolbar = $("#toolbar")
canvas = $("#filter")
context = canvas.get(0).getContext('2d')
# Setup webcam
# I have a separate webcam module that simply wraps the behavior of
# navigator.getMediaStream. Works fine in chrome.
webcam.setup(() -> alert("Browser Unsupported."))
webcam.getMedia({video:true}, (localMediaStream) ->
video.attr("src", window.URL.createObjectURL(localMediaStream))
# Video loaded event
video.on "loadedmetadata", (e) ->
# Turn on video controls
video.prop("controls", true)
# Setup canvas dimensions and add border
width = video.width()
height = video.height()
canvas
.css("border", "solid")
.css("border-width", "1px")
.attr("width", width)
.attr("height", height)
# In firefox, the width and height are 0! In chrome, they
# are correct. I tested videoWidth/videoHeight and most other
# variables. Does not work.
發佈一個更完整的代碼片段,並解釋你到底看到了什麼。你有其他一些我們看不到的錯誤是完全可能的。 – 2013-10-27 04:54:43
添加了一些評論解釋的片段。 – ImpGuard
https://bugzilla.mozilla.org/show_bug.cgi?id=926753 找到了。這確實是Firefox中的一個錯誤。該死。希望這會在我發佈我正在工作之前解決。真的不想讓黑客兼容。 – ImpGuard