private static String SAMPLE = dir + "Video_2014_5_7__15_33_44.mpg"; //"Video_2014_5_8__9_12_35.mpg";//"Video_2014_5_6__15_55_19.mpg";// protected override void OnElementChanged(Xamarin.Forms.Platform.Android.ElementChangedEventArgs <Xamarin.Forms.View> e) { Android.Util.Log.Debug(this.GetType().Name, "OnElementChanged()"); Android.Util.Log.Debug("Android API-int: ", Android.OS.Build.VERSION.Sdk); Android.Util.Log.Debug("Android API build: ", "" + Android.OS.Build.VERSION.SdkInt); Android.Util.Log.Debug("Android API: ", Android.OS.Build.VERSION.Codename); //first call into this method, the render was just created? if (e.OldElement == null) { surf = new SurfaceView(Context); myV = e.NewElement;//capture our Xamarin View. Android.Util.Log.Debug("X =", myV.X.ToString()); myV.SizeChanged += myV_SizeChanged; myV.PropertyChanged += myV_PropertyChanged; base.SetNativeControl(surf); surf.Holder.AddCallback(this); } }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { var view = inflater.Inflate(Resource.Layout.PlaybackExoPlayer, container, false); this._surfaceView = (SurfaceView)view.FindViewById(Resource.Id.SurfaceView); return view; }
public CameraAnalyzer(SurfaceView surfaceView, MobileBarcodeScanningOptions scanningOptions) { _scanningOptions = scanningOptions; _cameraEventListener = new CameraEventsListener(); _cameraController = new CameraController(surfaceView, _cameraEventListener, scanningOptions); Torch = new Torch(_cameraController, surfaceView.Context); }
private static String SAMPLE = dir + "Video_2014_5_7__15_33_44.mpg";//"Video_2014_5_8__9_12_35.mpg";//"Video_2014_5_6__15_55_19.mpg";// protected override void OnElementChanged(Xamarin.Forms.Platform.Android.ElementChangedEventArgs<Xamarin.Forms.View> e) { Android.Util.Log.Debug(this.GetType().Name, "OnElementChanged()"); Android.Util.Log.Debug("Android API-int: ", Android.OS.Build.VERSION.Sdk); Android.Util.Log.Debug("Android API build: ", ""+Android.OS.Build.VERSION.SdkInt); Android.Util.Log.Debug("Android API: ", Android.OS.Build.VERSION.Codename); //first call into this method, the render was just created? if (e.OldElement == null) { surf = new SurfaceView(Context); myV = e.NewElement;//capture our Xamarin View. Android.Util.Log.Debug("X =", myV.X.ToString()); myV.SizeChanged += myV_SizeChanged; myV.PropertyChanged += myV_PropertyChanged; base.SetNativeControl(surf); surf.Holder.AddCallback(this); } }
public CameraController(SurfaceView surfaceView, CameraEventsListener cameraEventListener, MobileBarcodeScanningOptions scanningOptions) { _context = surfaceView.Context; _holder = surfaceView.Holder; _surfaceView = surfaceView; _cameraEventListener = cameraEventListener; _scanningOptions = scanningOptions; }
public CameraPreview (Context context) : base (context) { surfaceView = new SurfaceView (context); AddView (surfaceView); windowManager = Context.GetSystemService (Context.WindowService).JavaCast<IWindowManager> (); IsPreviewing = false; holder = surfaceView.Holder; holder.AddCallback (this); }
public override void OnViewCreated (View view, Bundle savedInstanceState) { surfaceView = view.FindViewById<SurfaceView> (Resource.Id.surface); surface = surfaceView.Holder.Surface; buttonToggle = view.FindViewById<Button> (Resource.Id.toggle); buttonToggle.Click += delegate(object sender, EventArgs e) { if (virtualDisplay == null) StartScreenCapture (); else StopScreenCapture (); }; }
protected override void OnCreate (Bundle savedInstanceState) { base.OnCreate (savedInstanceState); if (!LibsChecker.CheckVitamioLibs (this)) return; SetContentView (Resource.Layout.subtitle1); tv = (TextView)FindViewById (Resource.Id.sub1); splayer = (SurfaceView)FindViewById (Resource.Id.surface); sholder = splayer.Holder; sholder.SetFormat (Format.Rgba8888); sholder.AddCallback (this); }
protected override void OnCreate (Bundle bundle) { /*base.OnCreate (bundle); SetContentView(Resource.Layout.CameraView); camera = (SurfaceView)FindViewById(Resource.Id.smallcameraview); camera.Holder.SetType(SurfaceType.PushBuffers); holder = camera.Holder; Session.setSurfaceHolder(holder);*/ base.OnCreate (bundle); base.RequestedOrientation = Android.Content.PM.ScreenOrientation.Portrait; SetContentView (Resource.Layout.Main); startButton = FindViewById<ImageButton> (Resource.Id.startButton); connectButton = FindViewById<ImageButton> (Resource.Id.connectToClientButton); settingsButton = FindViewById<ImageButton> (Resource.Id.settingsButton); connectLight = FindViewById<ImageView> (Resource.Id.connectLight); streamingLight = FindViewById<ImageView> (Resource.Id.streamingLight); connectText = FindViewById<TextView> (Resource.Id.connectStatus); streamText = FindViewById<TextView> (Resource.Id.streamingStatus); logView = FindViewById<TextView> (Resource.Id.log); scrollView = FindViewById<ScrollView> (Resource.Id.logScrollView); scrollView.FullScroll(FocusSearchDirection.Down); logView.SetText(savedText,TextView.BufferType.Editable); scrollView.ScrollTo(0,logView.Height); scrollView.FullScroll(FocusSearchDirection.Down); camera = (SurfaceView)FindViewById(Resource.Id.smallcameraview); camera.Holder.SetType(SurfaceType.PushBuffers); //holder = camera.Holder; Session.SetSurfaceHolder(camera.Holder); startButton.Click += OnStartClicked; connectButton.Click += OnConnectToClientClicked; settingsButton.Click += OnStettingsClicked; //this should be set based on something DisableButton(connectButton); EnableButton(settingsButton); SetStartICon(); SetDisableLight(connectLight); SetDisableLight(streamingLight); connectText.Text = "Client is not connected"; streamText.Text = "Not streaming"; PreferenceManager.SetDefaultValues(this, Resource.Layout.Settings,false); }
// * // * // * Called when the activity is first created. // protected override void OnCreate(Bundle icicle) { base.OnCreate(icicle); if (!LibsChecker.CheckVitamioLibs(this)) return; SetContentView(Resource.Layout.mediaplayer_2); mPreview = FindViewById<SurfaceView>(Resource.Id.surface); holder = mPreview.Holder; holder.AddCallback(this); holder.SetFormat(Format.Rgba8888); extras = Intent.Extras; }
public videoPlay(SurfaceView surface, string filename = "") { var holder = surface.Holder; holder.AddCallback(this); holder.SetType(SurfaceType.PushBuffers); if (filename == "") playFilename = System.IO.Path.Combine(Android.OS.Environment.ExternalStorageDirectory.ToString(), "myLOLvideo.mp4"); else playFilename = filename; mp = new MediaPlayer(); }
public videoRecord(SurfaceView surface, string filename = "") { if (filename == "") videoFilename = System.IO.Path.Combine (Android.OS.Environment.ExternalStorageDirectory.ToString (), "myLOLvideo.mp4"); else videoFilename = filename; isPaused = false; context = surface.Context; holder = surface.Holder; holder.AddCallback (this); holder.SetType (Android.Views.SurfaceType.PushBuffers); }
public BarcodeScanLayout(Context context, string holdStill, string alignBarcode) : base(context) { var param = new FrameLayout.LayoutParams(-1, -1, GravityFlags.Center); PreviewSurface = new SurfaceView(context); AddView(PreviewSurface, param); ViewFinderView = new ViewfinderView(context, holdStill, alignBarcode); AddView(ViewFinderView, param); LogoView = new ImageView(context); AddView(LogoView, param); }
public void StartVideoPlayback(SurfaceView surface, string FilePath) { if (_player != null) { StopVideoPlayback(); } _player = new MediaPlayer(); ISurfaceHolder holder = surface.Holder; holder.SetType(Android.Views.SurfaceType.PushBuffers); holder.SetFixedSize(400, 300); _player.SetDisplay(holder); _player.SetDataSource(FilePath); _player.Prepare(); _player.Start(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); EngineNS.CIPlatform.Instance.InitAndroid(this, this.Assets); // Set our view from the "main" layout resource SetContentView(Resource.Layout.activity_main); mHandler = new MainHandler(); mGameView = FindViewById <Android.Views.SurfaceView>(Resource.Id.surfaceView); mGameView.Holder.AddCallback(this); //var pm = (PowerManager)this.GetSystemService(Context.PowerService); //mWakeLock = pm.NewWakeLock(WakeLockFlags.ScreenDim | WakeLockFlags.OnAfterRelease, "BatMan"); //mWakeLock.Acquire(); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); FilePlayer.dir = dir; FilePlayer.SAMPLE = SAMPLE; mPlayer = null; //create the surface view for drawing to, and wire up callbacks(events) var sv = new SurfaceView(this); sv.Holder.AddCallback(this); sv.KeepScreenOn = true; SetContentView(sv); }
//private VideoQuality defaultVideoQuality = new VideoQuality(); protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); SetContentView(Resource.Layout.CameraView); camera = (SurfaceView)FindViewById(Resource.Id.smallcameraview); camera.Holder.SetType(SurfaceType.PushBuffers); holder = camera.Holder; Session.SetSurfaceHolder(holder); /*defaultVideoQuality.resX = 200; defaultVideoQuality.resY = 200; defaultVideoQuality.frameRate = 15; defaultVideoQuality.bitRate = 500*1000; // 500 kb/s Session.setDefaultVideoQuality(defaultVideoQuality);*/ }
//Button bAnsver; protected override void OnCreate(Bundle bundle) { base.OnCreate (bundle); SetContentView (Resource.Layout.IncomingCall); videoView = FindViewById<SurfaceView> (Resource.Id.incomingVideo); var bAnsver = FindViewById<Button> (Resource.Id.bAnsver); bAnsver.Click += delegate { Intent buttonUp = new Intent (Intent.ActionMediaButton); //buttonUp.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_HEADSETHOOK)); buttonUp.PutExtra (Intent.ExtraKeyEvent, new KeyEvent (KeyEventActions.Up, Keycode.Headsethook)); SendOrderedBroadcast (buttonUp, "android.permission.CALL_PRIVILEGED"); }; play("test.mp4"); }
private void Init(Context context) { // Get the current orientation of the device switch (((Android.App.Activity)context).WindowManager.DefaultDisplay.Rotation) { case SurfaceOrientation.Rotation90: _deviceOrientation = 90; break; case SurfaceOrientation.Rotation180: _deviceOrientation = 180; break; case SurfaceOrientation.Rotation270: _deviceOrientation = 270; break; default: _deviceOrientation = 0; break; } var surfaceView = new SurfaceView(context); AddView(surfaceView); // Install a SurfaceHolder.Callback so we get notified when the // underlying surface is created and destroyed. surfaceView.Holder.AddCallback(this); }
protected override void OnElementChanged(ElementChangedEventArgs <GradationDrawer> e) { if (Control == null && e.NewElement != null) { #if UseSurfaceView var ctrl = new Android.Views.SurfaceView(this.Context); ctrl.Holder.AddCallback(this); #else var ctrl = new Android.Views.View(this.Context); SetWillNotDraw(false); // Android.Views.View継承で必ず指定する #endif SetNativeControl(ctrl); } if (Control != null && e.OldElement != null) { if (e.OldElement.Colors is IList <GradationDrawer.ColPos> ) { foreach (var val in e.OldElement.Colors as IList <GradationDrawer.ColPos> ) { val.PropertyChanged -= Colors_PropertyChangedAsync; } } if (e.OldElement.Colors is INotifyCollectionChanged) { (e.OldElement.Colors as INotifyCollectionChanged).CollectionChanged -= Colors_CollectionChanged; } } if (Control != null && e.NewElement != null) { if (e.NewElement.Colors is IList <GradationDrawer.ColPos> ) { foreach (var val in e.NewElement.Colors as IList <GradationDrawer.ColPos> ) { val.PropertyChanged += Colors_PropertyChangedAsync; } } if (e.NewElement.Colors is INotifyCollectionChanged) { (e.NewElement.Colors as INotifyCollectionChanged).CollectionChanged += Colors_CollectionChanged; } } base.OnElementChanged(e); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); _SurfaceView = FindViewById<SurfaceView>(Resource.Id.SurfaceView); _SurfaceHolder = _SurfaceView.Holder; _SurfaceHolder.AddCallback(this); _SurfaceHolder.SetType(SurfaceType.PushBuffers); _FlashIcon = FindViewById<ImageView>(Resource.Id.FlashIcon); _FlashIcon.Click += (sender, args) => { if (FlashlightOnMode != GetCameraFlashMode()) { TurnFlashOn(); } else { TurnFlashOff(); } }; TurnFlashOn(); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Android.OS.Bundle savedInstanceState) { View v = inflater.Inflate(Resource.Layout.fragment_crime_camera, container, false); Button takePictureButton = v.FindViewById<Button>(Resource.Id.crime_camera_takePictureButton); takePictureButton.Click += (object sender, EventArgs e) => { //Activity.Finish(); if (mCamera != null) { mCamera.TakePicture(this, null, this); } }; mSurfaceView = v.FindViewById<SurfaceView>(Resource.Id.crime_camera_surfaceView); ISurfaceHolder holder = mSurfaceView.Holder; holder.SetType(SurfaceType.PushBuffers); holder.AddCallback(this); mProgressViewContainer = v.FindViewById<View>(Resource.Id.crime_camera_progressContainer); mProgressViewContainer.Visibility = ViewStates.Invisible; return v; }
internal Preview(Context context) : base(context) { mSurfaceView = new SurfaceView (context); AddView (mSurfaceView); // Install a SurfaceHolder.Callback so we get notified when the // underlying surface is created and destroyed. mHolder = mSurfaceView.Holder; mHolder.AddCallback (this); mHolder.SetType (SurfaceType.PushBuffers); }
protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); Java.Lang.JavaSystem.LoadLibrary("z_shared"); Java.Lang.JavaSystem.LoadLibrary("openpeer"); // Set our view from the "main" layout resource SetContentView (Resource.Layout.Main); // Get our button from the layout resource, // and attach an event to it LinearLayout localViewLayout = FindViewById<LinearLayout> (Resource.Id.myLocalViewLinearLayout); LinearLayout remoteViewLayout = FindViewById<LinearLayout> (Resource.Id.myRemoteViewLinearLayout); Button mediaControlButton = FindViewById<Button> (Resource.Id.myMediaControlButton); Button audioOutputButton = FindViewById<Button> (Resource.Id.myAudioOutputButton); EditText remoteIPAddressEditText = FindViewById<EditText> (Resource.Id.myRemoteIPAddressEditText); localView = ViERenderer.CreateLocalRenderer(this); localViewLayout.AddView (localView); remoteView = ViERenderer.CreateRenderer(this, true); remoteViewLayout.AddView (remoteView); OPMediaEngine.Init (Android.App.Application.Context); mediaEngine = OPTestMediaEngine.TestInstance; if (useFrontCamera) mediaEngine.CameraType = CameraTypes.CameraTypeFront; else mediaEngine.CameraType = CameraTypes.CameraTypeBack; mediaEngine.SetEcEnabled (Java.Lang.Boolean.True); mediaEngine.SetAgcEnabled (Java.Lang.Boolean.True); mediaEngine.SetNsEnabled (Java.Lang.Boolean.False); mediaEngine.SetNsEnabled (Java.Lang.Boolean.False); mediaEngine.MuteEnabled = Java.Lang.Boolean.False; mediaEngine.LoudspeakerEnabled = Java.Lang.Boolean.False; mediaEngine.ContinuousVideoCapture = Java.Lang.Boolean.True; mediaEngine.DefaultVideoOrientation = VideoOrientations.VideoOrientationPortrait; mediaEngine.RecordVideoOrientation = VideoOrientations.VideoOrientationLandscapeRight; mediaEngine.FaceDetection = Java.Lang.Boolean.False; mediaEngine.SetChannelRenderView (remoteView); mediaControlButton.Text = string.Format ("Start Video Capture"); audioOutputButton.Text = string.Format ("Speakerphone"); mediaControlButton.Click += delegate { switch (mediaEngineStatus) { case 0: mediaEngine.StartVideoCapture (); mediaControlButton.Text = string.Format ("Start Media Channel"); mediaEngineStatus++; break; case 1: mediaEngine.ReceiverAddress = remoteIPAddressEditText.Text; mediaEngine.StartVoice (); mediaEngine.StartVideoChannel (); mediaControlButton.Text = string.Format ("Stop Media Channel"); mediaEngineStatus++; break; case 2: mediaEngine.StopVoice (); mediaEngine.StopVideoChannel (); mediaControlButton.Text = string.Format ("Stop Video Capture"); mediaEngineStatus++; break; case 3: mediaEngine.StopVideoCapture (); mediaControlButton.Text = string.Format ("Start Video Capture"); mediaEngineStatus = 0; break; default: break; } }; audioOutputButton.Click += delegate { if (speakerphoneEnabled) { mediaEngine.LoudspeakerEnabled = Java.Lang.Boolean.False; audioOutputButton.Text = string.Format ("Speakerphone"); } else { mediaEngine.LoudspeakerEnabled = Java.Lang.Boolean.True; audioOutputButton.Text = string.Format ("Ear Speaker"); } speakerphoneEnabled = !speakerphoneEnabled; }; }
protected override void OnStart() { base.OnStart(); TesseractInit(); button.Enabled = true; _boxPaint.Color = _boxWhite; _boxPaint.SetStyle(Android.Graphics.Paint.Style.Stroke); _boxPaint.StrokeWidth = 5; _backgroundPaint.Color = Android.Graphics.Color.Black; _backgroundPaint.Alpha = 255 / 2; _backgroundPaint.SetStyle(Android.Graphics.Paint.Style.Fill); _backgroundClearPaint.SetXfermode(new Android.Graphics.PorterDuffXfermode(Android.Graphics.PorterDuff.Mode.Clear)); _resizePaint.Alpha = 255 / 2; _resizePaint.Color = _boxWhite; _resizePaint.SetStyle(Android.Graphics.Paint.Style.Fill); _resizePaint.StrokeWidth = 1; _surfaceCamera = (SurfaceView)FindViewById(Resource.Id.surfaceCamera); _holderCamera = _surfaceCamera.Holder; _holderCamera.AddCallback(this); _surfaceBox = (SurfaceView)FindViewById(Resource.Id.surfaceBox); _surfaceBox.SetOnTouchListener(this); _surfaceBox.SetWillNotDraw(false); _holderBox = _surfaceBox.Holder; _holderBox.AddCallback(this); _holderBox.SetFormat(Android.Graphics.Format.Transparent); _surfaceBox.SetZOrderOnTop(true); _boxThread = new Thread(new ThreadStart(() => { long lastUpdate = 0; double fps = 60.0; while (_cameraActive) { if (System.Environment.TickCount - lastUpdate > 1000 / fps) { lastUpdate = System.Environment.TickCount; if (_box != null) { DrawBox(); } } } })); bitmap = Android.Graphics.Bitmap.CreateBitmap(1, 1, Android.Graphics.Bitmap.Config.Argb8888); bitmapWithBoxes = Android.Graphics.Bitmap.CreateBitmap(1, 1, Android.Graphics.Bitmap.Config.Argb8888); for (int i = 0; i < threshholds.Length; i++) { threshholds[i] = 10 + i * 2; } _cameraActive = true; _toast = Toast.MakeText(this, "", ToastLength.Short); _processDialog = new Android.App.ProgressDialog(this); _processDialog.Indeterminate = true; _processDialog.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner); _processDialog.SetTitle("Please wait"); _processDialog.SetMessage("Please wait..."); _processDialog.SetCancelable(true); }
private void startPlaying() { var inflater = Application.Context.GetSystemService(Context.LayoutInflaterService) as LayoutInflater; //View view = inflater.Inflate (Resource.Id.incomingVideo,null,false); View _container = inflater.Inflate (Resource.Layout.IncomingCall, null, false); //_container.SetBackgroundResource (view); LinearLayout _lay = new LinearLayout (this); SurfaceView _tv = new SurfaceView (this); //_tv = _container.FindViewById<SurfaceView> (Resource.Id.incomingVideo); _tv = _container.FindViewById<SurfaceView> (Resource.Id.incomingVideo); _lay.RemoveView (_tv); _lay.AddView (_tv); //View view = inflater.Inflate(Resource.Layout.IncomingCall,null); play ("test.mp4"); /*var notificationService = (NotificationManager) GetSystemService(NotificationService); var notification = new Notification(Resource.Drawable.Icon, "Music started", Java.Lang.JavaSystem.CurrentTimeMillis()); notification.Flags = NotificationFlags.NoClear; var notificationIntent = PendingIntent.GetActivity(this, 0, new Intent(this, typeof(CallActivity)), 0); notificationService.Notify (VideoPlayingNotification, notification);*/ }
protected void bindTakePhotoElements() { surfaceView = FindViewById<SurfaceView>(Resource.Id.ContactNewSurfaceView); surfaceHolder = surfaceView.Holder; surfaceHolder.AddCallback(this); surfaceHolder.SetType(SurfaceType.PushBuffers); }
public Preview(Context context) : base(context) { mSurfaceView = new SurfaceView (context); AddView (mSurfaceView); mHolder = mSurfaceView.Holder; mHolder.AddCallback (this); mHolder.SetType (SurfaceType.PushBuffers); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.player_activity); var root = FindViewById(Resource.Id.root); root.Touch += (sender, args) => { var motionEvent = args.Event; switch (motionEvent.Action) { case MotionEventActions.Down: ToggleControlsVisibility(); break; case MotionEventActions.Up: ((View) sender).PerformClick(); break; } args.Handled = true; }; root.KeyPress += (sender, args) => { var keyCode = args.KeyCode; if (keyCode == Keycode.Back || keyCode == Keycode.Escape || keyCode == Keycode.Menu) { args.Handled = false; } else { _mediaController.DispatchKeyEvent(args.Event); } }; _shutterView = FindViewById(Resource.Id.shutter); _debugRootView = FindViewById(Resource.Id.controls_root); _videoFrame = FindViewById<AspectRatioFrameLayout>(Resource.Id.video_frame); _surfaceView = FindViewById<SurfaceView>(Resource.Id.surface_view); _surfaceView.Holder.AddCallback(this); _debugTextView = FindViewById<TextView>(Resource.Id.debug_text_view); _playerStateTextView = FindViewById<TextView>(Resource.Id.player_state_view); _subtitleLayout = FindViewById<SubtitleLayout>(Resource.Id.subtitles); _mediaController = new MediaController(this); _mediaController.SetAnchorView(root); _retryButton = FindViewById<Button>(Resource.Id.retry_button); _retryButton.SetOnClickListener(this); _videoButton = FindViewById<Button>(Resource.Id.video_controls); _audioButton = FindViewById<Button>(Resource.Id.audio_controls); _textButton = FindViewById<Button>(Resource.Id.text_controls); var currentHandler = CookieHandler.Default; if (currentHandler != DefaultCookieManager) { CookieHandler.Default = DefaultCookieManager; } _audioCapabilitiesReceiver = new AudioCapabilitiesReceiver(this, this); _audioCapabilitiesReceiver.Register(); }
/// <summary> /// 起動時 /// </summary> protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); // 画面の向きを固定する RequestedOrientation = Android.Content.PM.ScreenOrientation.Landscape; // 各種フラグ設定 this.Window.AddFlags(WindowManagerFlags.KeepScreenOn); //ウェイクロック using (PowerManager pm = (PowerManager)GetSystemService(Service.PowerService)) { wakeLock = pm.NewWakeLock(WakeLockFlags.ScreenDim, PackageName); wakeLock.Acquire(); } //設定読み込み settings = Settings.Load(this); //カメラを開く cameraManager = new CameraManager(); cameraManager.PictureTaken += CameraManager_PictureTaken; cameraManager.Open(); // カメラ表示設定 cameraSurfaceView = FindViewById<SurfaceView>(Resource.Id.surfaceView1); cameraSurfaceView.Holder.AddCallback(this); cameraSurfaceView.Holder.SetType(SurfaceType.PushBuffers); //位置情報を開く locTrackerGPS = new LocationTracker(this, LocationManager.GpsProvider); locTrackerGPS.Start(); locTrackerNetwork = new LocationTracker(this, LocationManager.NetworkProvider); locTrackerNetwork.Start(); // 各種イベントを登録する SetupEvents(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Wood.WebView.Resource.Layout.Camera); surfaceView = (SurfaceView)FindViewById(Wood.WebView.Resource.Id.surfaceView); captureBtn = (Button)FindViewById(Wood.WebView.Resource.Id.capture); okBtn = (Button)FindViewById(Wood.WebView.Resource.Id.ok); redoBtn = (Button)FindViewById(Wood.WebView.Resource.Id.redo); redoBtn.Visibility = ViewStates.Gone; okBtn.Visibility = ViewStates.Gone; ISurfaceHolder surfaceHolder = surfaceView.Holder; surfaceHolder.AddCallback(this); surfaceHolder.SetType(SurfaceType.PushBuffers); captureBtn.Click += delegate { camera.TakePicture(this, null, this); }; okBtn.Click += delegate { if (Success != null) Success(pictureData); Finish(); }; redoBtn.Click += delegate { camera.StartPreview(); redoBtn.Visibility = ViewStates.Gone; okBtn.Visibility = ViewStates.Gone; captureBtn.Visibility = ViewStates.Visible; }; }
private void PrepareViews(int co) { if (co >= counter || done) RunOnUiThread(delegate { t.Stop(); Window.ClearFlags(WindowManagerFlags.KeepScreenOn); Finish(); }); if (!done) t.Start(); float[] newSizes = new float[2]; newSizes [0] = 200f; if (wowZapp.LaffOutOut.Singleton.resizeFonts) { newSizes [0] *= wowZapp.LaffOutOut.Singleton.bigger; newSizes [1] = newSizes [0]; } this.stepViews = new Dictionary<int, View>(); string path = System.IO.Path.Combine(wowZapp.LaffOutOut.Singleton.ContentDirectory, "tempaudio.wav"); string videoPath = System.IO.Path.Combine(wowZapp.LaffOutOut.Singleton.ContentDirectory, "tempvideo.mp4"); #if DEBUG System.Diagnostics.Debug.WriteLine("co = {0}, counter = {1}", co, counter); #endif MessageStep eachMessageStep = null; if (co != counter) { eachMessageStep = MessagePlaybackUtil.messageSteps [co]; ContentPackItem packItem = null; MessagePlaybackUtil.contentPackItems.TryGetValue(eachMessageStep.ContentPackItemID, out packItem); #if DEBUG System.Diagnostics.Debug.WriteLine("co = {0}, messagestep type = {1}, contentPackID = {2}, packItem = {3}", co, eachMessageStep, eachMessageStep.ContentPackItemID, packItem != null ? "yes" : "no"); #endif switch (eachMessageStep.StepType) { case MessageStep.StepTypes.Text: RunOnUiThread(delegate { using (TextView textMessage = new TextView (context)) { textMessage.LayoutParameters = new ViewGroup.LayoutParams((int)ImageHelper.convertDpToPixel(250f, context), (int)ImageHelper.convertDpToPixel(150f, context)); textMessage.SetBackgroundResource(Resource.Drawable.bubblesolidleft); textMessage.Gravity = GravityFlags.Top; textMessage.SetPadding((int)ImageHelper.convertDpToPixel(20f, context), (int)ImageHelper.convertDpToPixel(15f, context), (int)ImageHelper.convertDpToPixel(20f, context), (int)ImageHelper.convertDpToPixel(15f, context)); textMessage.SetTextColor(Color.Black); textMessage.SetTextSize(Android.Util.ComplexUnitType.Pt, 12f); textMessage.Text = MessagePlaybackUtil.messageSteps [co].MessageText; textMessage.Visibility = ViewStates.Visible; linView.AddView(textMessage); this.stepViews [eachMessageStep.StepNumber] = textMessage; } }); break; case MessageStep.StepTypes.Comix: if (packItem != null) { RunOnUiThread(delegate { using (ImageView preview = new ImageView (context)) { preview.LayoutParameters = new ViewGroup.LayoutParams((int)ImageHelper.convertDpToPixel(newSizes [0], context), (int)ImageHelper.convertDpToPixel(newSizes [1], context)); preview.SetScaleType(ImageView.ScaleType.FitXy); Android.Graphics.Drawables.Drawable imgDataC = Android.Graphics.Drawables.Drawable.CreateFromStream(new MemoryStream(packItem.ContentPackItemIcon), "Comix"); preview.SetImageDrawable(imgDataC); linView.AddView(preview); this.stepViews [eachMessageStep.StepNumber] = preview; } }); } break; case MessageStep.StepTypes.Comicon: if (packItem != null) { RunOnUiThread(delegate { using (Android.Graphics.Drawables.Drawable imgDataS = Android.Graphics.Drawables.Drawable.CreateFromStream (new MemoryStream (packItem.ContentPackItemIcon), "Comicon")) { using (ImageView preview = new ImageView (context)) { preview.LayoutParameters = new ViewGroup.LayoutParams((int)ImageHelper.convertDpToPixel(newSizes [0], context), (int)ImageHelper.convertDpToPixel(newSizes [1], context)); preview.SetScaleType(ImageView.ScaleType.FitXy); preview.SetImageDrawable(imgDataS); linView.AddView(preview); this.stepViews [eachMessageStep.StepNumber] = preview; byte[] audio = packItem.ContentPackData; System.IO.File.WriteAllBytes(path, audio); AudioPlayer csfx = new AudioPlayer(context); t.Interval = csfx.findDuration(path) + 1000; csfx.playFromFile(path); } } }); } break; case MessageStep.StepTypes.SoundFX: if (packItem != null) { RunOnUiThread(delegate { using (ImageView preview = new ImageView (context)) { preview.LayoutParameters = new ViewGroup.LayoutParams((int)ImageHelper.convertDpToPixel(newSizes [0], context), (int)ImageHelper.convertDpToPixel(newSizes [1], context)); preview.SetScaleType(ImageView.ScaleType.FitXy); preview.SetImageResource(Resource.Drawable.audiofile); linView.AddView(preview); byte[] audio = packItem.ContentPackData; System.IO.File.WriteAllBytes(path, audio); AudioPlayer csfx = new AudioPlayer(context); t.Interval = csfx.findDuration(path) + 1000; csfx.playFromFile(path); this.stepViews [eachMessageStep.StepNumber] = preview; } }); } break; case MessageStep.StepTypes.Emoticon: if (packItem != null) { //RunOnUiThread (delegate { t.Interval = 5000; string base64String = System.Convert.ToBase64String(packItem.ContentPackData, 0, packItem.ContentPackData.Length); using (WebView wv = new WebView (context)) { string url = "<img src=\"data:image/gif;base64," + base64String + "\" width=\"" + ((int)newSizes [0]).ToString() + "\" height=\"" + ((int)newSizes [1]).ToString() + "\" />"; wv.LoadDataWithBaseURL(null, url, "text/html", "UTF-8", null); wv.VerticalScrollBarEnabled = false; wv.HorizontalScrollBarEnabled = false; wv.LayoutParameters = new ViewGroup.LayoutParams((int)ImageHelper.convertDpToPixel(200f, context), (int)ImageHelper.convertDpToPixel(200f, context)); wv.SetBackgroundColor(Color.Transparent); RunOnUiThread(() => linView.AddView(wv)); } //}); } break; case MessageStep.StepTypes.Voice: if (MessagePlaybackUtil.voiceRecordings != null) { RunOnUiThread(delegate { using (ImageView preview = new ImageView (context)) { preview.LayoutParameters = new ViewGroup.LayoutParams((int)ImageHelper.convertDpToPixel(newSizes [0], context), (int)ImageHelper.convertDpToPixel(newSizes [1], context)); preview.SetScaleType(ImageView.ScaleType.FitXy); preview.SetImageResource(Resource.Drawable.microphone); linView.AddView(preview); this.stepViews [eachMessageStep.StepNumber] = preview; } //byte[] audio = getLocalVoiceRecording (MessagePlaybackUtil.voiceRecordings [eachMessageStep.StepNumber]); AudioPlayer voice = new AudioPlayer(context); #if DEBUG System.Diagnostics.Debug.WriteLine("audio file filename = {0}, stepNumber = {1}", MessagePlaybackUtil.voiceRecordings [eachMessageStep.StepNumber], eachMessageStep.StepNumber); #endif t.Interval = voice.findDuration(MessagePlaybackUtil.voiceRecordings [eachMessageStep.StepNumber]) + 1000; string audioPath = MessagePlaybackUtil.voiceRecordings [eachMessageStep.StepNumber]; if (!File.Exists(audioPath)) { #if DEBUG System.Diagnostics.Debug.WriteLine("audio file doesn't exist for playback"); #endif } else voice.playFromFile(audioPath); isPlaying = true; }); } break; case MessageStep.StepTypes.Video: if (packItem != null) { RunOnUiThread(delegate { SurfaceView preview = new SurfaceView(context); preview.LayoutParameters = new ViewGroup.LayoutParams((int)ImageHelper.convertDpToPixel(newSizes [0], context), (int)ImageHelper.convertDpToPixel(newSizes [1], context)); linView.AddView(preview); byte[] audio = packItem.ContentPackData; System.IO.File.WriteAllBytes(videoPath, audio); videoPlay voice = new videoPlay(preview, videoPath); t.Interval = voice.videoDuration(path) + 1000; voice.videoStart(); this.stepViews [eachMessageStep.StepNumber] = preview; isPlaying = true; }); } break; case MessageStep.StepTypes.Animation: /*if (eachMessageStep.AnimationData != null) { string animationHtml = Translator.MakePlaybackCode (eachMessageStep.AnimationData, (int)newSizes [0], (int)newSizes [1], RenderPlatformTypes.Android, JSTemplate); t.Interval = Convert.ToInt32 (eachMessageStep.AnimationData.Duration) + 100; using (WebView wv = new WebView (context)) { wv.LoadDataWithBaseURL (null, animationHtml, "text/html", "UTF-8", null); wv.VerticalScrollBarEnabled = false; wv.HorizontalScrollBarEnabled = false; wv.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (200f, context), (int)ImageHelper.convertDpToPixel (200f, context)); wv.SetBackgroundColor (Color.Transparent); RunOnUiThread (() => linView.AddView (wv)); } }*/ break; case MessageStep.StepTypes.Polling: if (MessagePlaybackUtil.pollSteps.Count > 0) { PollingStep pollStep = MessagePlaybackUtil.pollSteps [eachMessageStep.StepNumber]; if (string.IsNullOrEmpty(pollStep.PollingAnswer1)) { t.Stop(); MessagePollUtil.pollStep = pollStep; MessagePollUtil.recipients = MessagePlaybackUtil.recipients; MessagePollUtil.isPhoto = true; LOLMessageSurveyResult pollResult; #if DEBUG System.Diagnostics.Debug.WriteLine("PollResults = {0}", MessagePlaybackUtil.pollResults == null ? "null" : "something"); #endif if (MessagePlaybackUtil.pollResults.TryGetValue(eachMessageStep.StepNumber, out pollResult)) MessagePollUtil.pollScreenType = PollingScreenType.Results; else MessagePollUtil.pollScreenType = PollingScreenType.Vote; #if DEBUG System.Diagnostics.Debug.WriteLine("polltype = {0}", MessagePollUtil.pollScreenType); #endif RunOnUiThread(delegate { SetContentView(Resource.Layout.PhotoPoll); ImageView topleft = FindViewById<ImageView>(Resource.Id.imgPoll1); topleft.Tag = 1; ImageView topright = FindViewById<ImageView>(Resource.Id.imgPoll2); topright.Tag = 2; ImageView bottomleft = FindViewById<ImageView>(Resource.Id.imgPoll3); bottomleft.Tag = 3; ImageView bottomright = FindViewById<ImageView>(Resource.Id.imgPoll4); bottomright.Tag = 4; voteTL = FindViewById<ProgressBar>(Resource.Id.pbVoteTL); voteTR = FindViewById<ProgressBar>(Resource.Id.pbVoteTR); voteBL = FindViewById<ProgressBar>(Resource.Id.pbVoteBL); voteBR = FindViewById<ProgressBar>(Resource.Id.pbVoteBR); TextView textPoll = FindViewById<TextView>(Resource.Id.txtPollText); textPoll.Text = MessagePollUtil.pollStep.PollingQuestion; doner = FindViewById<Button>(Resource.Id.btnDone); if (MessagePollUtil.pollScreenType == PollingScreenType.Results) { doner.Click += delegate { Intent i = new Intent(this, typeof(MessagePlayback)); i.PutExtra("position", co + 1); StartActivity(i); Finish(); }; } else doner.Visibility = ViewStates.Invisible; ImageButton btnUniBack = FindViewById<ImageButton>(Resource.Id.btnUniBack); btnUniBack.Visibility = ViewStates.Invisible; if (MessagePollUtil.pollScreenType == PollingScreenType.Vote) { voteTL.Visibility = voteTR.Visibility = voteBL.Visibility = voteBR.Visibility = ViewStates.Invisible; topleft.Click += new EventHandler(Photo_Click); topright.Click += new EventHandler(Photo_Click); bottomleft.Click += new EventHandler(Photo_Click); bottomright.Click += new EventHandler(Photo_Click); } else if (MessagePollUtil.pollScreenType == PollingScreenType.Results) { LOLMessageClient service = new LOLMessageClient(LOLConstants.DefaultHttpBinding, LOLConstants.LOLMessageEndpoint); service.PollingStepGetResultsCompleted += Service_PollingStepGetResultsCompleted; service.PollingStepGetResultsAsync(eachMessageStep.StepID, AndroidData.CurrentUser.AccountID, new Guid(AndroidData.ServiceAuthToken)); } if (MessagePollUtil.pollStep.PollingData1 != null) { if (MessagePollUtil.pollStep.PollingData1.Length != 0) { #if DEBUG System.Diagnostics.Debug.WriteLine("in A"); #endif using (Drawable imgDataA = Drawable.CreateFromStream (new MemoryStream (MessagePollUtil.pollStep.PollingData1), "Poll1")) { topleft.SetImageDrawable(imgDataA); } } } if (MessagePollUtil.pollStep.PollingData2 != null) { if (MessagePollUtil.pollStep.PollingData2.Length != 0) { #if DEBUG System.Diagnostics.Debug.WriteLine("in B"); #endif using (Drawable imgDataB = Drawable.CreateFromStream (new MemoryStream (MessagePollUtil.pollStep.PollingData2), "Poll2")) { topright.SetImageDrawable(imgDataB); } } } if (MessagePollUtil.pollStep.PollingData3 != null) { if (MessagePollUtil.pollStep.PollingData3.Length != 0) { #if DEBUG System.Diagnostics.Debug.WriteLine("in C"); #endif using (Drawable imgDataC = Drawable.CreateFromStream (new MemoryStream (MessagePollUtil.pollStep.PollingData3), "Poll3")) { bottomleft.SetImageDrawable(imgDataC); } } } if (MessagePollUtil.pollStep.PollingData4 != null) { if (MessagePollUtil.pollStep.PollingData4.Length != 0) { #if DEBUG System.Diagnostics.Debug.WriteLine("in D"); #endif using (Drawable imgDataD = Drawable.CreateFromStream (new MemoryStream (MessagePollUtil.pollStep.PollingData4), "Poll4")) { bottomright.SetImageDrawable(imgDataD); } } } }); } else { MessagePollUtil.isPhoto = false; MessagePollUtil.pollStep = pollStep; MessagePollUtil.recipients = MessagePlaybackUtil.recipients; LOLMessageSurveyResult pollResult; if (MessagePlaybackUtil.pollResults.TryGetValue(eachMessageStep.StepNumber, out pollResult)) MessagePollUtil.pollScreenType = PollingScreenType.Results; else MessagePollUtil.pollScreenType = PollingScreenType.Vote; t.Stop(); RunOnUiThread(delegate { SetContentView(Resource.Layout.TextPoll); Button opt1 = FindViewById<Button>(Resource.Id.btnOpt1); opt1.Tag = 1; Button opt2 = FindViewById<Button>(Resource.Id.btnOpt2); opt2.Tag = 2; Button opt3 = FindViewById<Button>(Resource.Id.btnOpt3); opt3.Tag = 3; Button opt4 = FindViewById<Button>(Resource.Id.btnOpt4); opt4.Tag = 4; res1 = FindViewById<ProgressBar>(Resource.Id.pbRes1); res2 = FindViewById<ProgressBar>(Resource.Id.pbRes2); res3 = FindViewById<ProgressBar>(Resource.Id.pbRes3); res4 = FindViewById<ProgressBar>(Resource.Id.pbRes4); TextView pollQ = FindViewById<TextView>(Resource.Id.txtPollText); pollQ.Text = MessagePollUtil.pollStep.PollingQuestion; Button finished = FindViewById<Button>(Resource.Id.btnDone); finished.Click += delegate { Intent i = new Intent(this, typeof(MessagePlayback)); i.PutExtra("position", co + 1); StartActivity(i); Finish(); }; doner = FindViewById<Button>(Resource.Id.btnDone); if (MessagePollUtil.pollScreenType == PollingScreenType.Results) { doner.Click += delegate { Intent i = new Intent(this, typeof(MessagePlayback)); i.PutExtra("position", co + 1); StartActivity(i); Finish(); }; } else doner.Visibility = ViewStates.Invisible; ImageButton btnUniBack = FindViewById<ImageButton>(Resource.Id.btnUniBack); btnUniBack.Visibility = ViewStates.Invisible; opt1.Text = MessagePollUtil.pollStep.PollingAnswer1; opt2.Text = MessagePollUtil.pollStep.PollingAnswer2; opt3.Text = MessagePollUtil.pollStep.PollingAnswer3; opt4.Text = MessagePollUtil.pollStep.PollingAnswer4; if (MessagePollUtil.pollScreenType == PollingScreenType.Vote) { res1.Visibility = res2.Visibility = res3.Visibility = res4.Visibility = ViewStates.Invisible; opt1.Click += new EventHandler(PollButton_Click); opt2.Click += new EventHandler(PollButton_Click); opt3.Click += new EventHandler(PollButton_Click); opt4.Click += new EventHandler(PollButton_Click); } else { LOLMessageClient service = new LOLMessageClient(LOLConstants.DefaultHttpBinding, LOLConstants.LOLMessageEndpoint); service.PollingStepGetResultsCompleted += Service_PollingStepGetResultsCompleted; service.PollingStepGetResultsAsync(eachMessageStep.StepID, AndroidData.CurrentUser.AccountID, new Guid(AndroidData.ServiceAuthToken)); } }); } } break; } } if (File.Exists(path)) File.Delete(path); if (File.Exists(videoPath)) File.Delete(videoPath); }
public RenderTarget(IPlatformHandle handle) { _view = (SurfaceView) handle; }