1.0.0 • Published 3 years ago

js-dadan-sdk v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

Dadan Sdk CDN

A lightweight JavaScript sample shows how to use Google Dadan Extension for checking, validating, and manipulating videos

How It Works ?

we add the following scripts into index.html web page

<script src="https://resources-dadan-io.s3.eu-central-1.amazonaws.com/sdk/dadan-extension-core.js"></script>
<scrip src="https://resources-dadan-io.s3.eu-central-1.amazonaws.com/sdk/dadan-extension-cdn.js"></script>

Usage

In your html page we include the follwing

<div id="record-video-button"></div>
<!--the div container which holds the button-->
<input type="text" id="return-control-id" />
<!--the input text which will holds sharedUrl-->

In script tag we include the following

const recordVideoButton = new RecordVideoButton(
  {
    containerId: "record-video-button",
    title: "Select Video",
    type: "select",
    buttonClass: "dd__record__button__default__class",
    buttonStyle: "",
    showSvg: true,
    showPreview: true,
    copyToClipboard: true,
    returnControlId: "return-control-id",
  },
  handleResponse, // handle success
  handleResponse // handle failure
);

the handleResponse function , is a callback function which accept object with three parameters

function handleResponse({ success, data, message }) {
  if (success) {
    // only false when user close extension
    if (data) {
      // represnts the selected videos , or recorded video object after stop recording
      console.table(data);
    }
  } else {
    console.error(message); //User Closed Extension
  }
}

Record Button Object Options

ParameterTypeDescription
containerIdstringRequired. the container id that holds the button
titlestringRequired. button title
typestringRequired. either record or select , else will show error
buttonClassstringOptional. the default class , or your custom class
buttonStylestringOptional. the default style , or your custom style as string
showSvgbooleanOptional. to show Svg icon in button
showPreviewbooleanOptional. to show preview dialog of recorded video
copyToClipboardbooleanOptional. to notify user that video shared url was copied to clipboard as toast message
returnControlIdstringOptional. the input text id which will holds sharedUrl of recorded video

License

MIT