本文整理汇总了C#中Windows.Media.Capture.MediaCaptureInitializationSettings类的典型用法代码示例。如果您正苦于以下问题:C# MediaCaptureInitializationSettings类的具体用法?C# MediaCaptureInitializationSettings怎么用?C# MediaCaptureInitializationSettings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MediaCaptureInitializationSettings类属于Windows.Media.Capture命名空间,在下文中一共展示了MediaCaptureInitializationSettings类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: OnLoaded
private async void OnLoaded(object sender, RoutedEventArgs e)
{
SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
m_mediaCapture = new MediaCapture();
m_mediaCapture.Failed += mediaCapture_Failed;
var settings = new MediaCaptureInitializationSettings()
{
StreamingCaptureMode = StreamingCaptureMode.Video
};
try
{
await m_mediaCapture.InitializeAsync(settings);
await m_mediaCapture.VideoDeviceController.SetMediaStreamPropertiesAsync(MediaStreamType.VideoPreview, GetHighestResolution());
}
catch (Exception)
{
return;
}
await m_mediaCapture.AddVideoEffectAsync( new VideoEffectDefinition(typeof(ExampleVideoEffect).FullName, new PropertySet()), MediaStreamType.VideoPreview);
m_previewVideoElement.Source = m_mediaCapture;
await m_mediaCapture.StartPreviewAsync();
}
开发者ID:modulexcite,项目名称:Lumia-imaging-sdk,代码行数:27,代码来源:VideoEffectView.xaml.cs
示例2: InitializeCameraAsync
internal async Task InitializeCameraAsync()
{
Debug.WriteLine("InitializeCameraAsync");
if (_mediaCapture == null)
{
// Attempt to get the back camera if one is available, but use any camera device if not
var cameraDevice = await FindCameraDeviceByPanelAsync(Windows.Devices.Enumeration.Panel.Back);
if (cameraDevice == null)
{
Debug.WriteLine("No camera device found!");
return;
}
// Create MediaCapture and its settings
_mediaCapture = new MediaCapture();
// Register for a notification when something goes wrong
_mediaCapture.Failed += MediaCapture_Failed;
var settings = new MediaCaptureInitializationSettings { VideoDeviceId = cameraDevice.Id };
// Initialize MediaCapture
try
{
await _mediaCapture.InitializeAsync(settings);
_isInitialized = true;
}
catch (UnauthorizedAccessException)
{
Debug.WriteLine("The app was denied access to the camera");
}
catch (Exception ex)
{
Debug.WriteLine("Exception when initializing MediaCapture with {0}: {1}", cameraDevice.Id, ex.ToString());
}
// If initialization succeeded, start the preview
if (_isInitialized)
{
// Figure out where the camera is located
if (cameraDevice.EnclosureLocation == null || cameraDevice.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Unknown)
{
// No information on the location of the camera, assume it's an external camera, not integrated on the device
_externalCamera = true;
}
else
{
// Camera is fixed on the device
_externalCamera = false;
// Only mirror the preview if the camera is on the front panel
_mirroringPreview = (cameraDevice.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Front);
}
await StartPreviewAsync();
}
}
}
开发者ID:RareNCool,项目名称:UWP-ImageCropper-,代码行数:60,代码来源:CameraService.cs
示例3: StartPreviewAsync
public async Task StartPreviewAsync(VideoRotation videoRotation)
{
try
{
if (mediaCapture == null)
{
var cameraDevice = await FindCameraDeviceByPanelAsync(Panel.Back);
mediaCapture = new MediaCapture();
var settings = new MediaCaptureInitializationSettings { VideoDeviceId = cameraDevice.Id };
await mediaCapture.InitializeAsync(settings);
captureElement.Source = mediaCapture;
await mediaCapture.StartPreviewAsync();
isPreviewing = true;
mediaCapture.SetPreviewRotation(videoRotation);
displayRequest.RequestActive();
}
//DisplayInformation.AutoRotationPreferences = DisplayOrientations.Landscape;
}
catch (UnauthorizedAccessException)
{
// This will be thrown if the user denied access to the camera in privacy settings
Debug.WriteLine("The app was denied access to the camera");
}
catch (Exception ex)
{
Debug.WriteLine("MediaCapture initialization failed. {0}", ex.Message);
}
}
开发者ID:builttoroam,项目名称:BuildIt,代码行数:28,代码来源:CameraFeedUtility.cs
示例4: Grid_Loaded
private async void Grid_Loaded(object sender, RoutedEventArgs e)
{
var camera = (await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture)).FirstOrDefault();
if (camera != null)
{
mediaCapture = new MediaCapture();
var settings = new MediaCaptureInitializationSettings() { VideoDeviceId = camera.Id };
await mediaCapture.InitializeAsync(settings);
displayRequest.RequestActive();
VideoPreview.Source = mediaCapture;
await mediaCapture.StartPreviewAsync();
memStream = new InMemoryRandomAccessStream();
MediaEncodingProfile mediaEncodingProfile = MediaEncodingProfile.CreateMp4(VideoEncodingQuality.Auto);
await mediaCapture.StartRecordToStreamAsync(mediaEncodingProfile, memStream);
}
//video = await captureUI.CaptureFileAsync(CameraCaptureUIMode.Video);
//if (video!=null)
//{
// MediaClip mediaClip = await MediaClip.CreateFromFileAsync(video);
// mediaComposition.Clips.Add(mediaClip);
// mediaStreamSource = mediaComposition.GeneratePreviewMediaStreamSource(600, 600);
// VideoPreview.SetMediaStreamSource(mediaStreamSource);
//}
//FFMPEGHelper.RTMPEncoder encoder = new FFMPEGHelper.RTMPEncoder();
//encoder.Initialize("rtmp://youtube.co");
}
开发者ID:krishnan-unni,项目名称:FFMPEGHelper,代码行数:28,代码来源:VideoProcessing.xaml.cs
示例5: enumerateCameras
public static async Task<List<DeviceInfo>> enumerateCameras()
{
var deviceInfo = await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync(Windows.Devices.Enumeration.DeviceClass.VideoCapture);
List<DeviceInfo> devices = new List<DeviceInfo>();
for (int i = 0; i < deviceInfo.Count; i++)
{
DeviceInfo device = new DeviceInfo();
device.deviceID = deviceInfo[i].Id;
device.deviceInfo = deviceInfo[i];
device.deviceName = deviceInfo[i].Name;
try
{
MediaCaptureInitializationSettings mediaSetting = new MediaCaptureInitializationSettings();
setCaptureSettings(out mediaSetting, device.deviceID);
MediaCapture mCapture = new MediaCapture();
await mCapture.InitializeAsync(mediaSetting);
device.resolutionList = updateResolution(mCapture);
}
catch
{
}
devices.Add(device);
}
return devices;
}
开发者ID:yjlintw,项目名称:YJToolkit,代码行数:28,代码来源:CameraUtil.cs
示例6: OnNavigatedTo
protected override async void OnNavigatedTo(NavigationEventArgs e)
{
if (_mediaCapture == null)
{
// Attempt to get te back camera if one is available, but use any camera device if not
var allVideoDevices = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture);
DeviceInformation desiredDevice = allVideoDevices.FirstOrDefault(
x => x.EnclosureLocation != null & x.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Back);
var cameraDevice = desiredDevice ?? allVideoDevices.FirstOrDefault();
if (cameraDevice == null)
{
// TODO: Implement an error experience for camera-less devices
Debug.Write("No camera device found.");
return;
}
// Create MediaCapture and its setings
_mediaCapture = new MediaCapture();
var settings = new MediaCaptureInitializationSettings { VideoDeviceId = cameraDevice.Id };
// TODO: Implement an error experience for non-authorized case
await _mediaCapture.InitializeAsync(settings);
// Startin the preview
PreviewControl.Source = _mediaCapture;
await _mediaCapture.StartPreviewAsync();
}
}
开发者ID:Alaheka,项目名称:uwp_bwcamera,代码行数:31,代码来源:MainPage.xaml.cs
示例7: StartDevice_Click
// Click event handler for the "Start Device" button.
private async void StartDevice_Click(object sender, RoutedEventArgs e)
{
try
{
StartDevice.IsEnabled = false;
// Enumerate webcams.
ShowStatusMessage("Enumerating webcams...");
var devInfoCollection = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture);
if (devInfoCollection.Count == 0)
{
ShowStatusMessage("No webcams found");
return;
}
// Initialize the MediaCapture object, choosing the first found webcam.
mediaCapture = new Windows.Media.Capture.MediaCapture();
var settings = new Windows.Media.Capture.MediaCaptureInitializationSettings();
settings.VideoDeviceId = devInfoCollection[0].Id;
await mediaCapture.InitializeAsync(settings);
// We can now take photos and enable the grayscale effect.
TakePhoto.IsEnabled = true;
AddRemoveEffect.IsEnabled = true;
ShowStatusMessage("Device initialized successfully");
}
catch (Exception ex)
{
ShowExceptionMessage(ex);
}
}
开发者ID:terryjintry,项目名称:OLSource1,代码行数:33,代码来源:walkthrough--creating-a-windows-store-app-using-wrl-and-media-foundation_8.cs
示例8: GetSettings
private MediaCaptureInitializationSettings GetSettings()
{
MediaCaptureInitializationSettings result = new MediaCaptureInitializationSettings();
result.StreamingCaptureMode = StreamingCaptureMode.Audio;
result.AudioProcessing = Windows.Media.AudioProcessing.Default;
return result;
}
开发者ID:Pavel-Durov,项目名称:PopcornAssistant,代码行数:7,代码来源:AudioService.cs
示例9: Start
public async void Start(int camIndex)
{
// devices = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture);
if (devices.Count > 0)
{
// Using Windows.Media.Capture.MediaCapture APIs to stream from webcam
mediaCaptureMgr = new MediaCapture();
///////////////////////////////////
var captureInitSettings = new Windows.Media.Capture.MediaCaptureInitializationSettings();
captureInitSettings.StreamingCaptureMode = Windows.Media.Capture.StreamingCaptureMode.Video;
captureInitSettings.PhotoCaptureSource = Windows.Media.Capture.PhotoCaptureSource.VideoPreview;
captureInitSettings.VideoDeviceId = devices[camIndex].Id;
///////////////////////////////////
await mediaCaptureMgr.InitializeAsync(captureInitSettings);
SetResolution();
camCaptureElement.Source = mediaCaptureMgr;
await mediaCaptureMgr.StartPreviewAsync();
}
}
开发者ID:valeryjacobs,项目名称:TheEyeOnThings,代码行数:25,代码来源:MainPage.xaml.cs
示例10: InitializeCameraAsync
private async Task InitializeCameraAsync()
{
if (mediaCapture == null)
{
// get camera device (back camera preferred)
var cameraDevice = await FindCameraDeviceByPanelAsync(Windows.Devices.Enumeration.Panel.Back);
if (cameraDevice == null)
{
Debug.WriteLine("no camera device found");
return;
}
// Create MediaCapture and its settings
mediaCapture = new MediaCapture();
var settings = new MediaCaptureInitializationSettings { VideoDeviceId = cameraDevice.Id };
// Initialize MediaCapture
try
{
await mediaCapture.InitializeAsync(settings);
isInitialized = true;
}
catch (UnauthorizedAccessException)
{
Debug.WriteLine("access to the camera denied");
}
}
}
开发者ID:UWPanda,项目名称:BemeRecorder,代码行数:30,代码来源:MainPage.xaml.cs
示例11: RequestMicrophonePermission
public async static Task<bool> RequestMicrophonePermission()
{
try
{
var settings = new MediaCaptureInitializationSettings
{
StreamingCaptureMode = StreamingCaptureMode.Audio,
MediaCategory = MediaCategory.Speech,
};
var capture = new MediaCapture();
await capture.InitializeAsync(settings);
}
catch (UnauthorizedAccessException)
{
return false;
}
catch (Exception ex)
{
if (ex.HResult == -1072845856)
{
// No Audio Capture devices are present on this system.
}
return false;
}
return true;
}
开发者ID:haroldma,项目名称:Audiotica,代码行数:26,代码来源:AudioUtils.cs
示例12: Page_Loaded
private async void Page_Loaded(object sender, RoutedEventArgs e)
{
MediaCaptureInitializationSettings set = new MediaCaptureInitializationSettings();
set.StreamingCaptureMode = StreamingCaptureMode.Video;
mediaCapture = new MediaCapture();
await mediaCapture.InitializeAsync(set);
}
开发者ID:hoai,项目名称:Project_Oxford_Emotions_UWP,代码行数:7,代码来源:MainPage.xaml.cs
示例13: RequestMicrophoneCapture
/// <summary>
/// On desktop/tablet systems, users are prompted to give permission to use capture devices on a
/// per-app basis. Along with declaring the microphone DeviceCapability in the package manifest,
/// this method tests the privacy setting for microphone access for this application.
/// Note that this only checks the Settings->Privacy->Microphone setting, it does not handle
/// the Cortana/Dictation privacy check, however (Under Settings->Privacy->Speech, Inking and Typing).
///
/// Developers should ideally perform a check like this every time their app gains focus, in order to
/// check if the user has changed the setting while the app was suspended or not in focus.
/// </summary>
/// <returns>true if the microphone can be accessed without any permissions problems.</returns>
///
public async static Task<bool> RequestMicrophoneCapture()
{
try
{
// Request access to the microphone only, to limit the number of capabilities we need
// to request in the package manifest.
MediaCaptureInitializationSettings settings = new MediaCaptureInitializationSettings();
settings.StreamingCaptureMode = StreamingCaptureMode.Audio;
settings.MediaCategory = MediaCategory.Speech;
MediaCapture capture = new MediaCapture();
await capture.InitializeAsync(settings);
}
catch (UnauthorizedAccessException)
{ // The user has turned off access to the microphone. If this occurs, we should show an error, or disable
// functionality within the app to ensure that further exceptions aren't generated when
// recognition is attempted.
return false;
}
catch (Exception exception)
{
// This can be replicated by using remote desktop to a system, but not redirecting the microphone input.
// Can also occur if using the virtual machine console tool to access a VM instead of using remote desktop.
if (exception.HResult == NoCaptureDevicesHResult)
{
return false;
}
else
{
throw;
}
}
return true;
}
开发者ID:intui,项目名称:SlideProjector,代码行数:46,代码来源:AudioCapturePermissions.cs
示例14: InitRecordProfileBtn_Click
/// <summary>
/// Locates a video profile for the back camera and then queries if
/// the discovered profile supports 640x480 30 FPS recording.
/// If a supported profile is located, then we configure media
/// settings to the matching profile. Else we use default profile.
/// </summary>
/// <param name="sender">Contains information regarding button that fired event</param>
/// <param name="e">Contains state information and event data associated with the event</param>
private async void InitRecordProfileBtn_Click(object sender, RoutedEventArgs e)
{
MediaCapture mediaCapture = new MediaCapture();
MediaCaptureInitializationSettings mediaInitSettings = new MediaCaptureInitializationSettings();
string videoDeviceId = string.Empty;
// Look for a video capture device Id with a video profile matching panel location
videoDeviceId = await GetVideoProfileSupportedDeviceIdAsync(Windows.Devices.Enumeration.Panel.Back);
if (string.IsNullOrEmpty(videoDeviceId))
{
await LogStatus("ERROR: No Video Device Id found, verify your device supports profiles", NotifyType.ErrorMessage);
return;
}
await LogStatusToOutputBox(string.Format(CultureInfo.InvariantCulture, "Found video capture device that supports Video Profile, Device Id:\r\n {0}", videoDeviceId));
await LogStatusToOutputBox("Retrieving all Video Profiles");
IReadOnlyList<MediaCaptureVideoProfile> profiles = MediaCapture.FindAllVideoProfiles(videoDeviceId);
await LogStatusToOutputBox(string.Format(CultureInfo.InvariantCulture, "Number of Video Profiles found: {0}", profiles.Count));
// Output all Video Profiles found, frame rate is rounded up for display purposes
foreach (var profile in profiles)
{
var description = profile.SupportedRecordMediaDescription;
foreach (var desc in description)
{
await LogStatusToOutputBox(string.Format(CultureInfo.InvariantCulture,
"Video Profile Found: Profile Id: {0}\r\n Width: {1} Height: {2} FrameRate: {3}", profile.Id, desc.Width, desc.Height, Math.Round(desc.FrameRate).ToString()));
}
}
// Look for WVGA 30FPS profile
await LogStatusToOutputBox("Querying for matching WVGA 30FPS Profile");
var match = (from profile in profiles
from desc in profile.SupportedRecordMediaDescription
where desc.Width == 640 && desc.Height == 480 && Math.Round(desc.FrameRate) == 30
select new { profile, desc }).FirstOrDefault();
if (match != null)
{
mediaInitSettings.VideoProfile = match.profile;
mediaInitSettings.RecordMediaDescription = match.desc;
await LogStatus(string.Format(CultureInfo.InvariantCulture,
"Matching WVGA 30FPS Video Profile found: \r\n Profile Id: {0}\r\n Width: {1} Height: {2} FrameRate: {3}",
mediaInitSettings.VideoProfile.Id, mediaInitSettings.RecordMediaDescription.Width,
mediaInitSettings.RecordMediaDescription.Height, Math.Round(mediaInitSettings.RecordMediaDescription.FrameRate).ToString()), NotifyType.StatusMessage);
}
else
{
// Could not locate a WVGA 30FPS profile, use default video recording profile
mediaInitSettings.VideoProfile = profiles[0];
await LogStatus("Could not locate a matching profile, setting to default recording profile", NotifyType.ErrorMessage);
}
await mediaCapture.InitializeAsync(mediaInitSettings);
await LogStatusToOutputBox("Media Capture settings initialized to selected profile");
}
开发者ID:COMIsLove,项目名称:Windows-universal-samples,代码行数:67,代码来源:Scenario1_SetRecordProfile.xaml.cs
示例15: InitializeAudioRecording
private async void InitializeAudioRecording()//初始化
{
_mediaCaptureManager = new MediaCapture();
var settings = new MediaCaptureInitializationSettings();
settings.StreamingCaptureMode = StreamingCaptureMode.Audio;//设置为音频
settings.MediaCategory = MediaCategory.Other;//设置音频种类
await _mediaCaptureManager.InitializeAsync(settings);
}
开发者ID:745322878,项目名称:Code,代码行数:9,代码来源:MainPage.xaml.cs
示例16: InitMediaCapture
private async Task InitMediaCapture()
{
CaptureMedia = new MediaCapture();
var captureInitSettings = new MediaCaptureInitializationSettings();
captureInitSettings.StreamingCaptureMode = StreamingCaptureMode.Audio;
await CaptureMedia.InitializeAsync(captureInitSettings);
CaptureMedia.Failed += MediaCaptureOnFailed;
CaptureMedia.RecordLimitationExceeded += MediaCaptureOnRecordLimitationExceeded;
}
开发者ID:vulcanlee,项目名称:Windows8Lab,代码行数:9,代码来源:MainPage.xaml.cs
示例17: Init
private async Task Init()
{
MC = new MediaCapture();
var cameras = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture);
var camera = cameras.First();
var settings = new MediaCaptureInitializationSettings() { VideoDeviceId = camera.Id };
await MC.InitializeAsync(settings);
ViewFinder.Source = MC;
await MC.StartPreviewAsync();
}
开发者ID:GoodBucket,项目名称:HackSamples,代码行数:10,代码来源:MainPage.xaml.cs
示例18: InitCamera
async void InitCamera()
{
mc = new MediaCapture();
var cameras = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture);
var camera = cameras[1];
var settings = new MediaCaptureInitializationSettings() { VideoDeviceId = camera.Id };
await mc.InitializeAsync(settings);
ce.Source = mc;
await mc.StartPreviewAsync();
}
开发者ID:jantielens,项目名称:ProjectOxfordDemo,代码行数:10,代码来源:MainPage.xaml.cs
示例19: InitializeAsync
public async Task InitializeAsync()
{
// 録音をおこなうためのオブジェクトを生成する
mediaCapture = new MediaCapture();
// 録音用の初期化を開始する
var settings = new MediaCaptureInitializationSettings();
settings.StreamingCaptureMode = StreamingCaptureMode.Audio;
await mediaCapture.InitializeAsync(settings);
}
开发者ID:runceel,项目名称:winstoreapprecipe,代码行数:10,代码来源:RecordAudio.cs
示例20: OnNavigatedTo
protected override async void OnNavigatedTo(NavigationEventArgs e)
{
try
{
var cameras = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture);
if (cameras.Count < 1)
{
Error.Text = "No camera found, decoding static image";
await DecodeStaticResource();
return;
}
MediaCaptureInitializationSettings settings;
if (cameras.Count == 1)
{
settings = new MediaCaptureInitializationSettings { VideoDeviceId = cameras[0].Id }; // 0 => front, 1 => back
}
else
{
settings = new MediaCaptureInitializationSettings { VideoDeviceId = cameras[1].Id }; // 0 => front, 1 => back
}
await _mediaCapture.InitializeAsync(settings);
VideoCapture.Source = _mediaCapture;
await _mediaCapture.StartPreviewAsync();
while (_result == null)
{
var photoStorageFile = await KnownFolders.PicturesLibrary.CreateFileAsync("scan.jpg", CreationCollisionOption.GenerateUniqueName);
await _mediaCapture.CapturePhotoToStorageFileAsync(ImageEncodingProperties.CreateJpeg(), photoStorageFile);
var stream = await photoStorageFile.OpenReadAsync();
// initialize with 1,1 to get the current size of the image
var writeableBmp = new WriteableBitmap(1, 1);
writeableBmp.SetSource(stream);
// and create it again because otherwise the WB isn't fully initialized and decoding
// results in a IndexOutOfRange
writeableBmp = new WriteableBitmap(writeableBmp.PixelWidth, writeableBmp.PixelHeight);
stream.Seek(0);
writeableBmp.SetSource(stream);
_result = ScanBitmap(writeableBmp);
await photoStorageFile.DeleteAsync(StorageDeleteOption.PermanentDelete);
}
await _mediaCapture.StopPreviewAsync();
VideoCapture.Visibility = Visibility.Collapsed;
CaptureImage.Visibility = Visibility.Visible;
ScanResult.Text = _result.Text;
}
catch (Exception ex)
{
Error.Text = ex.Message;
}
}
开发者ID:n1rvana,项目名称:ZXing.NET,代码行数:55,代码来源:MainPage.xaml.cs
注:本文中的Windows.Media.Capture.MediaCaptureInitializationSettings类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论