【发布时间】:2014-03-21 13:49:37
【问题描述】:
我目前正在尝试使用 RubyMotion 并尝试使用 iPhone 的相机手电筒。我已经在我的 Rakefile 中“导入”了 AVFoundation 框架,但似乎还有其他问题。您知道以更简单的方式处理此问题的宝石吗?我查看了 rubymotion-wrappers.com,但没有一个很好。提前致谢。
这是我在应用崩溃时遇到的错误:
uninitialized constant Torch::AVMediaTypeVideo (NameError)
错误来自的行是这一行(来自以下类,第 3 行):
flashlight = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo)
这是我的手电筒课
class Torch
def torchOn
flashlight = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo)
check = flashlight.lockForConfiguration(nil)
if check
flashlight.setTorchMode(AVCaptureModeOn)
flashlight.unlockForConfiguration
end
end
def torchOff
flashlight = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo)
check = flashlight.lockForConfiguration(nil)
if check
flashlight.setTorchMode(AVCaptureModeOff)
flashlight.unlockForConfiguration
end
end
end
这是我添加相应框架的Rakefile部分:
# -*- coding: utf-8 -*-
$:.unshift("/Library/RubyMotion/lib")
require 'motion/project/template/ios'
require 'rubygems'
begin
require 'bundler'
Bundler.require
rescue LoadError
end
Motion::Project::App.setup do |app|
# Use `rake config' to see complete project settings.
app.name = 'hellworld'
app.frameworks += [
'AVFoundation'
]
end
【问题讨论】:
标签: ios avfoundation rubymotion