Actionscript 3 Flash builder 4.6摄像头移动应用程序
大家好,我正在Flash builder 4.6中开发一款手机摄像头应用程序。 我的问题是,我可以让摄像头与网络摄像头一起工作,但不能让移动摄像头在需要部署的地方工作。我正在用空气来流。Actionscript 3 Flash builder 4.6摄像头移动应用程序,actionscript-3,flash,air,flash-builder,android-camera,Actionscript 3,Flash,Air,Flash Builder,Android Camera,大家好,我正在Flash builder 4.6中开发一款手机摄像头应用程序。 我的问题是,我可以让摄像头与网络摄像头一起工作,但不能让移动摄像头在需要部署的地方工作。我正在用空气来流。 我是这样叫我的按钮的: <?xml version="1.0" encoding="utf-8"?> <s:View xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.co
我是这样叫我的按钮的:
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" title="Capture">
<!-- Button event script -->
<fx:Script>
<![CDATA[
{
//Bring in the actionscript
import views.CoolVideo;
//The button handler
private function button1_clickHandler(event:MouseEvent):void
{
//Calling the actionScript function
new CoolVideo();
}
}
]]>
</fx:Script>
<!-- Basic structure of the app page -->
<s:VGroup width="100%" height="100%" verticalAlign="middle" horizontalAlign="center">
<!-- Label on the screen -->
<s:Label text="Capture page(current)"/>
<!-- Button to change between screens -->
<s:Button label="Capture" click="button1_clickHandler(event)" styleName="next"/>
<s:Button label="Back" click="navigator.pushView(app3HomeView)" styleName="next"/>
<!--<s:Image id="img" height="649" y="124" width="460" x="10"/> -->
</s:VGroup>
</s:View>
如果有人能告诉我为什么它不在移动摄像头上运行,而是在网络摄像头上运行,这将是非常好的,或者甚至可以为我指出正确的方向,以便在Android中访问设备摄像头,那么您需要在文件的
部分的
根目录下请求它
例如:
16位
]]>
仔细检查您的所有权限,就好像它在模拟环境中工作一样,这几乎是它必须具备的 我确实觉得奇怪的是,您的示例实际上是在桌面模式下使用网络摄像头运行的,因为我看不到您的CoolVideo sprite被添加到stage或display视图中的任何位置。@AdrianPirvulescu抱歉,现在我该如何实现这一点,如我是否尝试使用子对象添加cam??您正在实例化新的CoolVideo();但不要将其添加到视图中。这个怎么样;我感觉您使用的示例与您的桌面air appI中的示例不一样。我检查了它们的权限,但仍然不允许使用@cyangelhmm,好的。您是否尝试过将摄像机
输出到像视频显示器
这样的UI元素,以检查您实际获得的输出。
package views
{
import flash.display.Sprite;
import flash.display.Stage;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.MouseEvent;
import flash.events.NetStatusEvent;
import flash.media.Camera;
import flash.media.CameraUI;
import flash.media.H264Level;
import flash.media.H264Profile;
import flash.media.H264VideoStreamSettings;
import flash.media.Video;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.text.TextField;
import flash.text.TextFormat;
public class CoolVideo extends Sprite
{
//All the Stuff we need
private var metaText:TextField = new TextField();
private var vid_outDescription:TextField = new TextField();
private var vid_inDescription:TextField = new TextField();
private var metaTextTitle:TextField = new TextField();
//the connection will be used to link to server
private var nc:NetConnection;
//net stream is the data flow
private var ns_out:NetStream;
//the camera, get camera looks for an available camera returns null if not one available
private var cam:Camera = Camera.getCamera();
//this will be the video streamed to the server
private var vid_out:Video;
//Class constructor
public function CoolVideo()
{
//Call initConnection()
initConnection();
}
//Called from class constructor, this function establishes a new NetConnection and listens for its status
private function initConnection():void
{
//instantiate netConnection
nc = new NetConnection();
//The on status event is where all the streaming will go on
nc.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
//make net Connection to the server
nc.connect("rtmp://192.168.200.233/livepkgr/_definst_/");
//Step 7: Tell the NetConnection where the server should invoke callback methods
nc.client=this;
//Instantiate the vid_out variable
vid_out = new Video();
}
//It's a best practice to always check for a successful NetConnection
protected function onNetStatus(event:NetStatusEvent):void
{
//Step 8: Trace the value of event.info.code
trace(event.info.code);
/*Step 9: Check for a successful NetConnection, and if successful
call publishCamera()*/
if(event.info.code == "NetConnection.Connect.Success")
{
publishCamera();
}
}
//The encoding settings are set on the publishing stream
protected function publishCamera():void
{
//Step 12: Instantiate the ns_out NetStream
ns_out = new NetStream(nc);
//Step 13: Attach the camera to the outgoing NetStream
ns_out.attachCamera(cam);
//Step 14: Define a local variable named h264Settings of type H264VideoStreamSettings
var h264Settings:H264VideoStreamSettings = new H264VideoStreamSettings();
//Step 15: Set encoding profile and level on h264Settings
h264Settings.setProfileLevel( H264Profile.BASELINE, H264Level.LEVEL_3_1 )
//Step 16: Set the bitrate and quality settings on the Camera object
cam.setQuality( 90000, 90 );
//Step 17: Set the video's height, width, fps, and whether it should maintain its capture size
cam.setMode( 320, 240, 30, true );
//Step 18: Set the keyframe interval
cam.setKeyFrameInterval( 15 );
//Step 19: Set the outgoing video's compression settings based on h264Settings
ns_out.videoStreamSettings = h264Settings;
//Step 20: Publish the outgoing stream
ns_out.publish( "livestream?adbe-live-event=liveevent" );
}
//Step 11: Un-comment this necessary callback function that checks bandwith (remains empty in this case)
public function onBWDone():void
{
}
}
}
<android>
<colorDepth>16bit</colorDepth>
<manifestAdditions><![CDATA[
<manifest android:installLocation="auto">
<uses-permission android:name="android.permission.CAMERA"/>
</manifest>
]]></manifestAdditions>
</android>