Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • MediaLink

Index

Constructors

Properties

Methods

Constructors

constructor

  • new MediaLink(connection: ClientConnection): MediaLink

Properties

Private connection

connection: ClientConnection

message-event-channel connection

Methods

getImage

  • This method will trigger an image browser. It returns a promise that will resolve to the chosen Image Link.

    Example of fetching an image from DC

    try {
      // open browser and waits for image
      // returns object that should be saved to the model
      const image = await sdk.mediaLink.getImage()
    
    } catch (e) {
      // no image returned
    }
    

    Example of displaying a image in your custom control

    import { init } from 'dc-extensions-sdk';
    import { Image: ImageBuilder } from 'dc-delivery-sdk-js';
    
    async function start() {
      const sdk = await init();
      const img = document.querySelector('img');
      const button = document.querySelector('button')
    
      function onClick() {
        sdk.mediaLink
         .getImage()
         .then(image => {
            setImage(image)
          })
         .catch(err => console.log('not selected'));
      }
    
      function setImage(image) {
         img.src = (
            new ImageBuilder(image, { stagingEnvironment: sdk.stagingEnvironment })
            .url()
            .build()
         )
      }
    
      button.onclick = onClick;
    }
    
    start()
    

    Returns Promise<MediaImageLink>

getImages

  • getImages(__namedParameters?: { max: null | number }): Promise<MediaImageLink[]>
  • This method will trigger an image browser. It returns a promise that will resolve to the chosen Image Links.

    Example of fetching an image from DC

    try {
      // open browser and waits for image
      // returns object that should be saved to the model
      const images = await sdk.mediaLink.getImages({ max: 10 })
    
    } catch (e) {
      // no image returned
    }
    

    Parameters

    • Default value __namedParameters: { max: null | number } = { max: null }
      • max: null | number

    Returns Promise<MediaImageLink[]>

getVideo

  • This method will trigger a video browser. It returns a promise that will resolve to the chosen Video Link.

    Example of fetching an video from DC

    try {
      // open browser and waits for video
      // returns object that should be saved to the model
      const video = await sdk.mediaLink.getVideo()
    
    } catch (e) {
      // no video returned
    }
    

    Returns Promise<MediaVideoLink>

getVideos

  • getVideos(__namedParameters?: { max: null | number }): Promise<MediaVideoLink[]>
  • This method will trigger a video browser. It returns a promise that will resolve to the chosen Video Links.

    Example of fetching an video from DC

    try {
      // open browser and waits for video
      // returns object that should be saved to the model
      const videos = await sdk.mediaLink.getVideos()
    
    } catch (e) {
      // no video returned
    }
    

    Parameters

    • Default value __namedParameters: { max: null | number } = { max: null }
      • max: null | number

    Returns Promise<MediaVideoLink[]>

Legend

  • Constructor
  • Property
  • Method
  • Private property
  • Private method
  • Property
  • Inherited property
  • Protected property

Generated using TypeDoc