Skip to content
This repository has been archived by the owner on Feb 13, 2021. It is now read-only.

Example: Open Preview Dialog

PlugLynn edited this page Apr 18, 2015 · 2 revisions

The Preview Dialog is a simple dialog with a YouTube or SoundCloud video embedded.

Code

var Events = plugModules.require('plug/core/Events')
var PreviewEvent = plugModules.require('plug/events/PreviewEvent')
function showPreview(media) {
  // The PreviewEvent expects a Media model, but any Backbone Model instance will work,
  // and creating a Model instance is easier than creating a Media instance.
  media = new Backbone.Model(media)
  Events.dispatch(new PreviewEvent(PreviewEvent.PREVIEW, media))
}

Usage

showPreview({
  format: 1, // 1 for YouTube, 2 for SoundCloud
  cid: '', // YouTube or SoundCloud video ID, e.g. "e2rexvDHPZs"
  author: 'Artist Name',
  title: 'Song Name'
})
Clone this wiki locally