Example #1
0
 public void OnCompletion(MediaPlayer mp)
 {
     try
     {
         mp.Release();
         StoryVideoView?.StopPlayback();
         StoryVideoView = null !;
     }
     catch (Exception e)
     {
         Methods.DisplayReportResultTrack(e);
     }
 }
 public void OnCompletion(Android.Media.MediaPlayer mp)
 {
     try
     {
         mp.Release();
         StoryVideoView?.StopPlayback();
         StoryVideoView = null;
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
        public override void OnBackPressed()
        {
            try
            {
                PostVideoView?.StopPlayback();
                PostVideoView = null;

                base.OnBackPressed();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                base.OnBackPressed();
            }
        }
Example #4
0
        protected override void OnStop()
        {
            try
            {
                base.OnStop();

                if (Settings.BackgroundScreenWelcomeType == "Video")
                {
                    VideoViewer.StopPlayback();
                }
            }
            catch (Exception exception)
            {
                Crashes.TrackError(exception);
            }
        }
Example #5
0
        protected override void OnStop()
        {
            try
            {
                base.OnStop();

                if (AppSettings.BackgroundScreenWelcomeType == "Video")
                {
                    VideoViewer.StopPlayback();
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
Example #6
0
        public override void OnBackPressed()
        {
            try
            {
                PostVideoView?.StopPlayback();
                PostVideoView = null;

                MsgTabbedMainActivity.GetInstance()?.OffWakeLock();

                base.OnBackPressed();
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
                base.OnBackPressed();
            }
        }
Example #7
0
        public override void OnBackPressed()
        {
            try
            {
                PostVideoView?.StopPlayback();
                PostVideoView = null;

                TabbedMainActivity.GetInstance()?.SetOffWakeLock();

                base.OnBackPressed();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                base.OnBackPressed();
            }
        }
Example #8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="e"></param>
        protected override void OnElementChanged(ElementChangedEventArgs <AtomVideoPlayer> e)
        {
            base.OnElementChanged(e);

            if (Element == null)
            {
                return;
            }

            videoView = new VideoView(this.Context);
            var vlp = new Android.Widget.RelativeLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent);

            vlp.AddRule(LayoutRules.CenterInParent);
            //vlp.AddRule(LayoutRules.AlignParentLeft);
            //vlp.AddRule(LayoutRules.AlignParentRight);
            //vlp.AddRule(LayoutRules.AlignParentBottom);
            videoView.LayoutParameters = vlp;

            //vlp.AddRule(LayoutRules.fill);
            var mc = new MediaController(this.Context);

            videoView.SetMediaController(mc);



            var ctrl = new Android.Widget.RelativeLayout(this.Context);

            ctrl.AddView(videoView);
            SetNativeControl(ctrl);

            ResetVideo();

            if (Element.IsPlaying)
            {
                videoView.Start();
            }
            else
            {
                videoView.StopPlayback();
            }
            mc.Show(0);
        }
Example #9
0
        private async void TakePhotoButtonTapped(object sender, EventArgs e)
        {
            //camera.StopPreview ();
            //DialogService.ShowLoading ("Capturing Every Pixel");

            //var image = textureView.Bitmap;
            //using (var imageStream = new MemoryStream ()) {
            //	await image.CompressAsync (Bitmap.CompressFormat.Jpeg, 50, imageStream);
            //	image.Recycle ();
            //	imageBytes = imageStream.ToArray ();
            //}

            //var navigationPage = new NavigationPage (new DrawMomentPage (imageBytes)) {
            //	BarBackgroundColor = Colors.NavigationBarColor,
            //	BarTextColor = Colors.NavigationBarTextColor
            //};

            //DialogService.HideLoading ();
            //camera.StartPreview ();
            //await App.Current.MainPage.Navigation.PushModalAsync (navigationPage, false);

            //var video = FindViewById<VideoView>(Resource.Id.SampleVideoView);

            vv.StopPlayback();
            string path = global::Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/test.mp4";

            camera = global::Android.Hardware.Camera.Open();
            camera.SetDisplayOrientation(90);
            recorder = new MediaRecorder();
            camera.Unlock();
            recorder.SetCamera(camera);
            recorder.SetVideoSource(VideoSource.Camera);
            recorder.SetAudioSource(AudioSource.Mic);
            recorder.SetOutputFormat(OutputFormat.Default);
            recorder.SetVideoEncoder(VideoEncoder.Default);
            recorder.SetAudioEncoder(AudioEncoder.Default);
            recorder.SetOutputFile(path);
            recorder.SetPreviewDisplay(vv.Holder.Surface);
            recorder.Prepare();
            recorder.Start();
        }
Example #10
0
        public void StartRecord(object video_obj)
        {
            VideoView video = video_obj as VideoView;

            InitCamera();

            video.StopPlayback();

            var documents = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments);
            var filename  = System.IO.Path.Combine(documents, "Write.MP4");

            File.Delete(filename);

            var cameraParameters      = camera.GetParameters();
            var supportedSizes        = cameraParameters.SupportedVideoSizes;
            var supportedPreviewSizes = cameraParameters.SupportedPreviewSizes;

            camera.Unlock();

            recorder?.Release();
            recorder = null;

            recorder = new MediaRecorder();
            recorder.SetCamera(camera);

            recorder.SetVideoSource(VideoSource.Camera);
            recorder.SetAudioSource(AudioSource.Camcorder);
            recorder.SetOutputFormat(OutputFormat.Mpeg4);

            recorder.SetVideoSize(supportedSizes[0].Width, supportedSizes[0].Height);

            recorder.SetVideoEncoder(VideoEncoder.Mpeg4Sp);
            recorder.SetAudioEncoder(AudioEncoder.AmrNb);

            recorder.SetPreviewDisplay(video.Holder.Surface);

            recorder.SetOutputFile(filename);
            recorder.Prepare();
            recorder.Start();
        }
Example #11
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     base.OnElementPropertyChanged(sender, e);
     if (e.PropertyName == "Source")
     {
         ResetVideo();
     }
     if (e.PropertyName == "IsPlaying")
     {
         if (videoView.IsPlaying != Element.IsPlaying)
         {
             if (Element.IsPlaying)
             {
                 videoView.Start();
             }
             else
             {
                 videoView.StopPlayback();
             }
         }
     }
 }
        public void DisplayAdvertising() //funcion que muestra la publicidad, es un layout inflado
        {
            try
            {
                var layout = VideoViewInstance(); //devuelve la vista con el video incorporado

                _displayParam = new WindowManagerLayoutParams(
                    WindowManagerLayoutParams.MatchParent,
                    WindowManagerLayoutParams.MatchParent,
                    WindowManagerTypes.Phone,
                    WindowManagerFlags.Fullscreen, Format.Transparent);
                _displayParam.Gravity = GravityFlags.Center;

                if (transparentLayout != null)
                {
                    _windowManager.RemoveViewImmediate(transparentLayout);
                }

                _windowManager.AddView(layout, _displayParam);

                mVideoView.Start(); //esto es asincrono

                mVideoView.Prepared += delegate
                {
                    mButton.Visibility = ViewStates.Visible;
                };

                mVideoView.Completion += delegate
                {
                    mVideoView.StopPlayback();
                    mVideoView.SetVideoURI(Android.Net.Uri.Parse(GetVideoUrl.GetUrlBySection(_configuration.GetConfigurationSection())));
                    mVideoView.Start();
                };
            }
            catch (Exception ex)
            {
            }
        }
 void OnStopRequested(object sender, EventArgs args)
 {
     videoView.StopPlayback();
 }
 private void OnStopRequested(object sender, EventArgs args)
 {
     Control.Visibility = ViewStates.Invisible;
     _videoView.StopPlayback();
 }
Example #15
0
 public override void OnBackPressed()
 {
     base.OnBackPressed();
     VideoPlayer.StopPlayback();
     VideoPlayer.Suspend();
 }
 private void OnError(object sender, MediaPlayer.ErrorEventArgs e)
 {
     isPrepared = false;
     videoView.StopPlayback();
 }
Example #17
0
        async protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.activity_viewer);



            if (!(Intent.Extras is null))
            {
                variance = (float)Intent.Extras.GetInt("Variance");
                originalInputVariance = (int)variance;
                brick       = (float)Intent.Extras.GetInt("Brick");
                ore         = (float)Intent.Extras.GetInt("Ore");
                sheep       = (float)Intent.Extras.GetInt("Sheep");
                wheat       = (float)Intent.Extras.GetInt("Wheat");
                wood        = (float)Intent.Extras.GetInt("Wood");
                gold        = (float)Intent.Extras.GetInt("Gold");
                boardConfig = Intent.Extras.GetString("BoardConfig");
                numThreads  = Intent.Extras.GetInt("NumThreads");

                System.Diagnostics.Debug.WriteLine("brick: " + brick);
                System.Diagnostics.Debug.WriteLine("ore: " + ore);
                System.Diagnostics.Debug.WriteLine("sheep: " + sheep);
                System.Diagnostics.Debug.WriteLine("wheat: " + wheat);
                System.Diagnostics.Debug.WriteLine("wood: " + wood);
            }

            //Get the back button
            ImageButton backButton = FindViewById <ImageButton>(Resource.Id.backButton);

            backButton.SetImageResource(Resource.Drawable.BackButtonLoading);


            //Setup functionality for back button
            backButton.Click += (sender, e) =>
            {
                backButtonPressed();
            };

            //Get the yes button
            Button Yes = FindViewById <Button>(Resource.Id.Yes);

            //Add functionlity to it
            Yes.Click += (sender, e) =>
            {
                //Go back to the previous activity
                loadPreviousActivity();
            };

            //Get the No button
            Button No = FindViewById <Button>(Resource.Id.No);

            //Setup functionaliy of this button
            No.Click += (sender, e) =>
            {
                //reset the state of this activity
                ImageButton backButton = FindViewById <ImageButton>(Resource.Id.backButton);
                backButton.Clickable  = true;
                backButton.Visibility = ViewStates.Visible;
                TextView ContinuePrompt = FindViewById <TextView>(Resource.Id.ContinuePrompt);
                ContinuePrompt.Visibility = ViewStates.Gone;
                Yes.Visibility            = ViewStates.Gone;
                Yes.Clickable             = false;
                Button No = FindViewById <Button>(Resource.Id.No);
                No.Visibility = ViewStates.Gone;
                No.Clickable  = false;
            };

            VideoView LoadingIcon = FindViewById <VideoView>(Resource.Id.LoadingIcon);

            Android.Net.Uri uri = Android.Net.Uri.Parse("android.resource://" + PackageName + "/" + Resource.Raw.LoadingIcon2);
            LoadingIcon.SetVideoURI(uri);
            LoadingIcon.Start();
            string[] possibleTips =
            {
                "Raising Mountains",
                "Carving Canyons",
                "Shifting Tectonic Plates",
                "Adding Volcanos",
                "Removing Volcanos",
                "Filling Ocean",
                "Too Much Water, Draining Ocean",
                "Building Harbors",
                "Prospecting for Ore",
                "Plowing Fields",
                "Planting Wheat",
                "Watering Wheat",
                "Waiting for Wheat to Grow",
                "Still Waiting for Wheat to Grow",
                "Wheat Died; Planting more",
                "Breeding Sheep",
                "Shearing Sheep",
                "Feeding Wheat to Sheep",
                "Digging up Clay",
                "Turning Clay into Bricks",
                "Commiting Deforestation",
                "Planting New Trees"
            };

            Random   randomNumberGenerator = new Random();
            TextView tips = FindViewById <TextView>(Resource.Id.Tips);

            LoadingIcon.Completion += async(sender, e) =>
            {
                LoadingIcon.Start();
                tips.Visibility = ViewStates.Gone;
                await Task.Delay(500);

                tips.Text = "..." + possibleTips[randomNumberGenerator.Next(0, possibleTips.Length)] + "...";
                await Task.Delay(500);

                tips.Visibility = ViewStates.Visible;
                await Task.Delay(1500);

                tips.Visibility = ViewStates.Gone;
                await Task.Delay(500);

                tips.Text = "..." + possibleTips[randomNumberGenerator.Next(0, possibleTips.Length)] + "...";
                await Task.Delay(500);

                tips.Visibility = ViewStates.Visible;
                if (stopAll || stopSome)
                {
                    tips.Text       = "";
                    tips.Visibility = ViewStates.Gone;
                }
            };
            tips.Visibility = ViewStates.Visible;
            tips.Text       = "...Generating Map...";

            RelativeLayout menu = FindViewById <RelativeLayout>(Resource.Id.menuButtons);

            menu.SetBackgroundColor(Android.Graphics.Color.Black);

            //Wait for the board to be generated
            //Board testBoard = await Task.Run(() => generateBoard(variance, brick, ore, sheep, wheat, wood, gold, boardConfig));
            Board testBoard = await Task.Run(() => genMultipleBoards(variance, brick, ore, sheep, wheat, wood, gold, boardConfig, numThreads));

            //Intentional delay to make the transition from the Generator Activity to the loading screen smoother
            await Task.Delay(1000);

            //Once the board is generated, get rid of the loading icon
            LoadingIcon.Visibility = ViewStates.Gone;
            LoadingIcon.StopPlayback();
            menu.SetBackgroundColor(Android.Graphics.Color.White);
            tips.Text       = "";
            tips.Visibility = ViewStates.Gone;
            backButton.SetImageResource(Resource.Drawable.BackButton);

            //Get a variable for the main relative layout
            RelativeLayout r = FindViewById <RelativeLayout>(Resource.Id.board);

            if (stopAll)
            {
                Console.WriteLine("STOPPED BECAUSE USER HIT BACK BUTTON");
            }
            else
            {
                Console.WriteLine("YES!!!!!!!!!!!!");
                //Get the width and height of our screen (in pixels)
                int width  = Resources.DisplayMetrics.WidthPixels;
                int height = Resources.DisplayMetrics.HeightPixels;

                Console.WriteLine("WIDTH: " + width);
                Console.WriteLine("HEIGHT: " + height);

                //Find the max and min values in the x direction on the board
                int  max   = 0;
                int  min   = 0;
                bool first = true;

                foreach (KeyValuePair <HexPosition, Hex> tile in testBoard.tiles)
                {
                    if (first || tile.Key.x_pos > max)
                    {
                        first = false;
                        max   = tile.Key.x_pos;
                    }
                    if (first || tile.Key.x_pos < min)
                    {
                        first = false;
                        min   = tile.Key.x_pos;
                    }
                }

                //Calculate the board width (its complicated because of flat tops)
                double boardWidth = 1;
                for (int i = 1; i < max; i++)
                {
                    if (i % 2 == 0)
                    {
                        boardWidth += 1;
                    }

                    if (i % 2 == 1)
                    {
                        boardWidth += 0.5;
                    }
                }
                if (max % 2 == 0)
                {
                    boardWidth += 1;
                }
                if (max % 2 == 1)
                {
                    boardWidth += 0.75;
                }

                for (int i = -1; i > min; i--)
                {
                    if (((-1) * i) % 2 == 0)
                    {
                        boardWidth += 1;
                    }

                    if (((-1) * i) % 2 == 1)
                    {
                        boardWidth += 0.5;
                    }
                }
                if ((-1.0 * min) % 2 == 0)
                {
                    boardWidth += 1;
                }
                if ((-1.0 * min) % 2 == 1)
                {
                    boardWidth += 0.75;
                }

                float offsetWidth = -.75F * (Math.Abs(max) - Math.Abs(min));



                //Find the max and min values in the y direction on the board
                max   = 0;
                min   = 0;
                first = true;

                foreach (KeyValuePair <HexPosition, Hex> tile in testBoard.tiles)
                {
                    if (first || tile.Key.y_pos > max)
                    {
                        first = false;
                        max   = tile.Key.y_pos;
                    }
                    if (first || tile.Key.y_pos < min)
                    {
                        first = false;
                        min   = tile.Key.y_pos;
                    }
                }

                //Calculate the board width (its complicated because of flat tops)
                double boardHeight = 1;
                for (int i = 1; i <= max; i++)
                {
                    boardHeight += 1;
                }

                for (int i = -1; i >= min; i--)
                {
                    boardHeight += 1;
                }

                int offsetHeight = (Math.Abs(max) - Math.Abs(min));


                Console.WriteLine("BOARDWIDTH: " + boardWidth);
                Console.WriteLine("BOARDHEIGHT: " + boardHeight);
                Console.WriteLine("OFFSETWIDTH: " + offsetWidth);
                Console.WriteLine("OFFSETHEIGHT: " + offsetHeight);

                //The size (height and width) in pixels of the images to be displayed on screen (we floor it so it doesn't go 1 pixel off screen)
                int dimensionsWidth  = (int)Math.Ceiling(width / boardWidth);   //196
                int dimensionsHeight = (int)Math.Ceiling(height / boardHeight); //256

                //Get the smaller of the two
                //int dimensions = Math.Max(dimensionsWidth, dimensionsHeight);

                var size = dimensionsWidth / 2;

                //Loop through all the tiles in the board
                foreach (KeyValuePair <HexPosition, Hex> currentTile in testBoard.tiles)
                {
                    //Create a new image and add it to the layout
                    ImageView currentHexImage = new ImageView(this);
                    r.AddView(currentHexImage);

                    //Set proper image file based on resource type
                    var currentResource = currentTile.Value.type;
                    switch (currentResource)
                    {
                    case global::Resource.brick:
                        currentHexImage.SetImageResource(Resource.Drawable.BrickPiece);
                        break;

                    case global::Resource.ore:
                        currentHexImage.SetImageResource(Resource.Drawable.OrePiece);
                        break;

                    case global::Resource.sheep:
                        currentHexImage.SetImageResource(Resource.Drawable.WoolPiece);
                        break;

                    case global::Resource.wheat:
                        currentHexImage.SetImageResource(Resource.Drawable.GrainPiece);
                        break;

                    case global::Resource.wood:
                        currentHexImage.SetImageResource(Resource.Drawable.LumberPiece);
                        break;

                    case global::Resource.gold:
                        currentHexImage.SetImageResource(Resource.Drawable.GoldPiece);
                        break;

                    case global::Resource.desert:
                        currentHexImage.SetImageResource(Resource.Drawable.DesertPiece);
                        break;

                    case global::Resource.harbor_brick:
                        currentHexImage.SetImageResource(Resource.Drawable.HarborPiece_Brick);
                        break;

                    case global::Resource.harbor_ore:
                        currentHexImage.SetImageResource(Resource.Drawable.HarborPiece_Ore);
                        break;

                    case global::Resource.harbor_sheep:
                        currentHexImage.SetImageResource(Resource.Drawable.HarborPiece_Wool);
                        break;

                    case global::Resource.harbor_wheat:
                        currentHexImage.SetImageResource(Resource.Drawable.HarborPiece_Grain);
                        break;

                    case global::Resource.harbor_wood:
                        currentHexImage.SetImageResource(Resource.Drawable.HarborPiece_Lumber);
                        break;

                    case global::Resource.harbor_any:
                        currentHexImage.SetImageResource(Resource.Drawable.HarborPiece_QuestionMark);
                        break;

                    case global::Resource.sea:
                        currentHexImage.SetImageResource(Resource.Drawable.HarborPiece);
                        break;

                    default:
                        currentHexImage.SetImageResource(Resource.Drawable.test);
                        break;
                    }

                    //Rotate harbor pieces
                    currentHexImage.Rotation = currentTile.Key.direction * 60;

                    //Do hex to pixel conversion
                    //var xPos = size * (Math.Sqrt(3) * currentTile.Key.x_pos + (Math.Sqrt(3) / 2) * currentTile.Key.z_pos);
                    //var yPos = size * ((3.0 / 2) * currentTile.Key.z_pos);
                    var xPos = size * ((3.0 / 2) * currentTile.Key.x_pos);
                    var yPos = size * ((Math.Sqrt(3) / 2) * currentTile.Key.x_pos + (Math.Sqrt(3)) * currentTile.Key.z_pos);

                    //Offset the board so that it is in the center of the screen
                    xPos += offsetWidth * (dimensionsWidth / 2);
                    yPos += offsetHeight * (dimensionsHeight / 2);

                    //Move the hexagon into place
                    currentHexImage.TranslationX = (int)xPos;
                    currentHexImage.TranslationY = (int)yPos;

                    //Adjust max size of the tiles
                    currentHexImage.SetMaxHeight(dimensionsHeight);
                    currentHexImage.SetMaxWidth(dimensionsWidth);
                    currentHexImage.SetAdjustViewBounds(true);

                    //If the tile produces anything
                    if (currentTile.Value.number != 0)
                    {
                        //Create a new image and add it to the layout
                        ImageView chitImage = new ImageView(this);
                        r.AddView(chitImage);

                        //Move the hexagon into place
                        chitImage.TranslationX = (int)xPos;
                        chitImage.TranslationY = (int)yPos;

                        //Adjust max size of the tiles
                        chitImage.SetMaxHeight(dimensionsHeight);
                        chitImage.SetMaxWidth(dimensionsWidth);
                        chitImage.SetAdjustViewBounds(true);

                        //Set the chit image
                        switch (currentTile.Value.number)
                        {
                        case 2:
                            chitImage.SetImageResource(Resource.Drawable.ResourceCount_2);
                            break;

                        case 3:
                            chitImage.SetImageResource(Resource.Drawable.ResourceCount_3);
                            break;

                        case 4:
                            chitImage.SetImageResource(Resource.Drawable.ResourceCount_4);
                            break;

                        case 5:
                            chitImage.SetImageResource(Resource.Drawable.ResourceCount_5);
                            break;

                        case 6:
                            chitImage.SetImageResource(Resource.Drawable.ResourceCount_6);
                            break;

                        case 8:
                            chitImage.SetImageResource(Resource.Drawable.ResourceCount_8);
                            break;

                        case 9:
                            chitImage.SetImageResource(Resource.Drawable.ResourceCount_9);
                            break;

                        case 10:
                            chitImage.SetImageResource(Resource.Drawable.ResourceCount_10);
                            break;

                        case 11:
                            chitImage.SetImageResource(Resource.Drawable.ResourceCount_11);
                            break;

                        case 12:
                            chitImage.SetImageResource(Resource.Drawable.ResourceCount_12);
                            break;
                        }
                    }

                    //If the tile is covered by fog (seafarers scenario 3)
                    if (currentTile.Key.fog)
                    {
                        //Create a new image and add it to the layout
                        ImageView fogImage = new ImageView(this);
                        r.AddView(fogImage);

                        //Move the hexagon into place
                        fogImage.TranslationX = (int)xPos;
                        fogImage.TranslationY = (int)yPos;

                        //Adjust max size of the tiles
                        fogImage.SetMaxHeight(dimensionsHeight);
                        fogImage.SetMaxWidth(dimensionsWidth);
                        fogImage.SetAdjustViewBounds(true);

                        //Set fog image
                        fogImage.SetImageResource(Resource.Drawable.FogPiece);

                        //Setup functionality for clicking fog tile
                        fogImage.Click += (sender, e) => { fogImage.Visibility = ViewStates.Gone; };
                    }
                }
            }
        }
Example #18
0
 protected override void OnDestroy()
 {
     v.StopPlayback();
     base.OnDestroy();
 }
        void OnStopRequested(object sender, EventArgs args)
        {
            _logger.Log("OnStopRequested invoked.");

            videoView.StopPlayback();
        }