我不能让相机在OSX Safari中工作。因为它无法使用getusermedia,所以我看不到任何其他选项,然后使用闪光灯访问相机。

问题是我发现的例子在流星中不起作用。

任何人都有我可以遵循的指示或相机在OSX Safari中可以使用的其他方法吗?

这是我使用的库:https://github.com/infusion/jQuery-webcam

这是例子

client / safari.html

<template name="safari">
    {{onLoad}}
    <div id="webcam"></div>
    <div>
        <h3>Available Cameras</h3><ul id="cams"></ul>
    </div>
    <div>
        <canvas id="canvas" height="240" width="320"></canvas>
    </div>
    <button id="capture">Make Video</button>
</template>


客户端/safari.js

Template.safari.onLoad = function() {
        $("#webcam").webcam({
            width: 320,
            height: 240,
            mode: "callback",
            swffile: "/jscam_canvas_only.swf", // canvas only doesn't implement a jpeg encoder, so the file is much smaller

            onTick: function(remain) {

                if (0 == remain) {
                    $("#status").text("Cheese!");
                } else {
                    $("#status").text(remain + " seconds remaining...");
                }
            },

            onSave: function(data) {
                debugger;
                var col = data.split(";");
            // Work with the picture. Picture-data is encoded as an array of arrays... Not really nice, though =/
            },

            onCapture: function () {
                webcam.save();

              // Show a flash for example
            },

            debug: function (type, string) {
                // Write debug information to console.log() or a div, ...
            },

            onLoad: function () {
            // Page load
                var cams = webcam.getCameraList();
                for(var i in cams) {
                    $("#cams").append("<li>" + cams[i] + "</li>");
                }
            }
        });
}

var filter_id = 0;

function changeFilter() {
 if (filter_on) {
 filter_id = (filter_id + 1) & 7;
 }
}

Template.safari.events = {
    'click #capture': function (e) {
        webcam.capture();
        changeFilter();
    }
}

最佳答案

感谢#meteor的irc频道,我找到了解决方案。

Template.safari.onload必须是Template.safari.rendered

并且swf文件需要位于根目录的公用文件夹中。所有资源文件都需要存放的地方。

初学者的错误,但我学到了很多。

07-24 09:50
查看更多