Ejemplo n.º 1
0
        public async Task StartRecordingAsync()
        {
            _randomAccessStream = new InMemoryRandomAccessStream();
            _mediaRecording     = await MediaCapture.PrepareLowLagRecordToStreamAsync(MediaEncodingProfile.CreateMp4(VideoEncodingQuality.HD720p), _randomAccessStream);

            await _mediaRecording.StartAsync();
        }
        private async void Initialize()
        {
            this.Loaded += InstantReplayPage_Loaded;

            viewModel = new InstantReplayPageViewModel();

            viewModel.Initialize(inkCanvas);
            viewModel.TogglePlayPauseEvent += TogglePlayPause;
            Scrubber.ValueChanged          += Scrubber_ValueChanged;

            var file = await viewModel.StartCapture(null);

            //var profiles = MediaCapture.FindAllVideoProfiles(cameraId);
            MediaCapture capture = new MediaCapture();


            var devices = await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync(Windows.Devices.Enumeration.DeviceClass.VideoCapture);

            var captureInitSettings = new MediaCaptureInitializationSettings();
            var profile             = MediaEncodingProfile.CreateWmv(VideoEncodingQuality.Auto);

            captureInitSettings.StreamingCaptureMode = StreamingCaptureMode.Video;
            captureInitSettings.VideoDeviceId        = devices[0].Id;

            mediaCapture = new MediaCapture();
            await mediaCapture.InitializeAsync(captureInitSettings);

            storageFile = await KnownFolders.VideosLibrary.CreateFileAsync("InstantReplayCapture.wmv", CreationCollisionOption.GenerateUniqueName);

            StorageApplicationPermissions.FutureAccessList.Add(storageFile);

            storageFileStream = await storageFile.OpenStreamForWriteAsync();

            fileStream = new DVRRandomAccessStream(storageFileStream);

            lowLagRecord = await mediaCapture.PrepareLowLagRecordToStreamAsync(profile, fileStream);

            await lowLagRecord.StartAsync();

            VideoPlayer.SetSource(fileStream.PlaybackStream, storageFile.ContentType);

            VideoPlayer.PartialMediaFailureDetected += VideoPlayer_PartialMediaFailureDetected;
            VideoPlayer.MediaFailed         += VideoPlayer_MediaFailed;
            VideoPlayer.CurrentStateChanged += (s, e) => { Debug.WriteLine("State: " + VideoPlayer.CurrentState); };
            VideoPlayer.MediaEnded          += VideoPlayer_MediaEnded;

            this.DataContext = viewModel;
        }
Ejemplo n.º 3
0
        private async Task Start()
        {
            try
            {
                if (_state == STATE_PARTY)
                {
                    return;
                }



                _mediaCapture = new MediaCapture();
                await _mediaCapture.InitializeAsync();

                _mediaCapture.Failed += MediaCapture_Failed;

                _mediaCapture.RecordLimitationExceeded += MediaCapture_RecordLimitationExceeded;

                _stream   = new InMemoryRandomAccessStream();
                _position = 0;

                _mediaRecording = await _mediaCapture.PrepareLowLagRecordToStreamAsync(MediaEncodingProfile.CreateWav(AudioEncodingQuality.High), _stream);

                await _mediaRecording.StartAsync();

                _timer          = new DispatcherTimer();
                _timer.Tick    += timer_Tick;
                _timer.Interval = new TimeSpan(0, 0, (int)((double)BUFFER_SAMPLES / (double)RATE));
                _timer.Start();

                MQTT_BROKER_ADDRESS = txtMQTTServer.Text;
                // create client instance
                _client = new MqttClient(MQTT_BROKER_ADDRESS);

                string clientId = "publisher";//Guid.NewGuid().ToString();
                _client.Connect(clientId);

                _state = STATE_PARTY;
            }
            catch (Exception ex)
            {
                UpdateStatus(ex.Message);
            }
        }