Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7614695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:28:10+00:00 2026-05-31T02:28:10+00:00

I am trying to provide an option to switch between webcams used to display

  • 0

I am trying to provide an option to switch between webcams used to display preview using CaptureElement/MediaCapture. Unfortunately I tried multiple combinations of call sequences and the preview only shows up for the first device I use.

This is what I have been trying to do:

XAML:

<CaptureElement
    x:Name="captureElement"
    Stretch="UniformToFill" />

C#:

MediaCapture mediaCapture;
DeviceInformationCollection devices;
int currentDevice = 0;

private async void LayoutRoot_Tapped(object sender, Windows.UI.Xaml.Input.TappedEventArgs e)
{
    if (devices != null)
    {
        currentDevice = (currentDevice + 1) % devices.Count;
        InitializeWebCam();
    }
}

private async void InitializeWebCam()
{
    if (devices == null)
    {
        devices = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture);
        ListDeviceDetails();
    }

    if (mediaCapture != null)
    {
        await mediaCapture.StopPreviewAsync();

        this.captureElement.Source = null;
    }

    mediaCapture = new MediaCapture();
    await mediaCapture.InitializeAsync(
        new MediaCaptureInitializationSettings
        {
            VideoDeviceId = devices[currentDevice].Id
        });

    this.captureElement.Source = mediaCapture;
    await mediaCapture.StartPreviewAsync();
}

private void ListDeviceDetails()
{
    int i = 0;

    foreach (var device in devices)
    {
        Debug.WriteLine("* Device [{0}]", i++);
        Debug.WriteLine("EnclosureLocation.InDock: " + device.EnclosureLocation.InDock);
        Debug.WriteLine("EnclosureLocation.InLid: " + device.EnclosureLocation.InLid);
        Debug.WriteLine("EnclosureLocation.Panel: " + device.EnclosureLocation.Panel);
        Debug.WriteLine("Id: " + device.Id);
        Debug.WriteLine("IsDefault: " + device.IsDefault);
        Debug.WriteLine("IsEnabled: " + device.IsEnabled);
        Debug.WriteLine("Name: " + device.Name);
        Debug.WriteLine("IsDefault: " + device.IsDefault);

        foreach (var property in device.Properties)
        {
            Debug.WriteLine(property.Key + ": " + property.Value);
        }
    }
}

It seems like it does work to switch to second camera once in a while (below 10% of times) and then stays all black when I go back to the first one.

Sometimes the app hangs after I try to switch the camera once or twice (it stops responding to input, it is stuck in App.Run(), though the camera preview keeps refreshing).

Other times – it works in a way that it shows preview from the first device, but does not for the other one and when I go back to the first one – it works fine with it again.

Bugs?

There does not seem to be a Dispose or Uninitialize method anywhere. These are the properties I see (it’s Samsung’s Build 2011 tablet):

* Device [0]
EnclosureLocation.InDock: False
EnclosureLocation.InLid: False
EnclosureLocation.Panel: Front
Id: \\?\USB#VID_2232&PID_1021&MI_00#7&2469C269&0&0000#{e5323777-f976-4f5b-9b55-b94699c46e44}\GLOBAL
IsDefault: False
IsEnabled: True
Name: WebCam SC-20FHM11347N
IsDefault: False
System.ItemNameDisplay: WebCam SC-20FHM11347N
System.Devices.DeviceInstanceId: USB\VID_2232&PID_1021&MI_00\7&2469C269&0&0000
System.Devices.Icon: C:\Windows\System32\DDORes.dll,-2068
System.Devices.InterfaceEnabled: True
System.Devices.IsDefault: False
* Device [1]
EnclosureLocation.InDock: False
EnclosureLocation.InLid: False
EnclosureLocation.Panel: Back
Id: \\?\USB#VID_2232&PID_1022&MI_00#7&27072759&0&0000#{e5323777-f976-4f5b-9b55-b94699c46e44}\GLOBAL
IsDefault: False
IsEnabled: True
Name: WebCam SC-30H2L11449N
IsDefault: False
System.ItemNameDisplay: WebCam SC-30H2L11449N
System.Devices.DeviceInstanceId: USB\VID_2232&PID_1022&MI_00\7&27072759&0&0000
System.Devices.Icon: C:\Windows\System32\DDORes.dll,-2068
System.Devices.InterfaceEnabled: True
System.Devices.IsDefault: False
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T02:28:11+00:00Added an answer on May 31, 2026 at 2:28 am

    I think the problem must have been with the Developer Preview build. I have no problem switching between 3 web cams in the Consumer Preview one.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to provide login using facebook option to my website users. So,
I'm trying to use the vCard Microformat standard to provide a VCF export option
I'm trying to create a user control that will provide a draggable splitter between
I am trying to provide my users with the option to have my application
I'm trying to provide a Logger using a queue system and Timer to to
I'm trying to provide a number of clicked link to click handler. For some
I am trying to provide a simple RESTful API to my ASP MVC project.
I am trying to provide an interface to an abstract generic base class. I
This is the situation. I'm trying to provide a service where someone embedds an
trying to refactor code to provide clean association A GAME has a HOME_TEAM and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.