Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

191
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda