Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

196
Visualizações
Unable to access media inside microsoftTeams javascript library

I'm trying to use the microsoftTeams Javascript library in my Personal Tab in my Teams App. The app is written in cshtml and plain javascript.

I'm able to access the microsoftTeams object itself in my javascript file.

Ex: The following snippet works fine:

microsoftTeams.getContext(async (context) => userid = context.userObjectId );

However I need to integrate the camera/gallery into my workflow in the personal tab. I was following the instructions as per this documentation : https://docs.microsoft.com/en-us/microsoftteams/platform/concepts/device-capabilities/mobile-camera-image-permissions.

I'm facing an issue where-in the media object is undefined inside the microsoftTeams context.

The following snippet is how I'm trying to use the selectmedia api of the sdk.

function takePhotos() {
    var listOfSelectedImages = new Array();
    var imageProp = {
        sources: [microsoftTeams.media.Source.Camera, microsoftTeams.media.Source.Gallery],
        startMode: microsoftTeams.media.CameraStartMode.Photo,
        ink: false,
        cameraSwitcher: false,
        textSticker: false,
        enableFilter: true,
    };
    var mediaInput = {
        mediaType: microsoftTeams.media.MediaType.Image,
        maxMediaCount: 10,
        imageProps: imageProp
    };
    microsoftTeams.media.selectMedia(mediaInput, function (error, attachments) {
        if (error) {
            if (error.message) {
                alert(" ErrorCode: " + error.errorCode + error.message);
            }
            else {
                alert(" ErrorCode: " + error.errorCode);
            }
        }
        if (attachments)
        {
           // code for using atttachments here
        }
    });
}

I'm getting an error in both the browser and mobile client at this line microsoftTeams.media.Source.Camera, saying media is undefined.

I have included the teams.min.js file in the .layout.cshtml as follows.

<script src="https://statics.teams.cdn.office.net/sdk/v1.11.0/js/MicrosoftTeams.min.js" integrity="sha384-SCVF3m7OvDKnfAilUzYn2yozEvBeP8n/Oq0yTH8VUI70J4AzrqR70jzjdQ6DI8s2" crossorigin="anonymous"></script>

Is there something else I need to include for me to be able to access the media object?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Adding answer from comment section for more visibility:

The issue occurred due to conflicting javascript package version. Its resolved now.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda