Playlist API

HapYak provides a playlist API for certain player types:

  • Wistia

To enable, include the following script after hapyak.js:

<script src="//d2qrdklrsxowl2.cloudfront.net/js/hapyak.api.js"></script>

API methods

hapyak.playlist.embed(type, id, typeOptions, callback)

hapyak.playlist.embed(type, id, callback)

Supported type values: "wistia"

Function callback will be executed whenever a video is loaded, and receives the HapYak Playlist API instance as its first argument

hapyak.playlist.embed('wistia', PLAYLIST_ID, function (playlist) {
    playlist.viewer({
        apiKey: HAPYAK_API_KEY
    });
});

JavaScript object typeOptions will be passed to native playlist API for type, if available

hapyak.playlist.embed('wistia', PLAYLIST_ID, {
    version: 'v1',
    theme: 'tab',
    videoOptions: {
        videoWidth: VIDEO_WIDTH,
        videoHeight: VIDEO_HEIGHT
    }
}, function (playlist) {
    playlist.viewer({
        apiKey: HAPYAK_API_KEY
    });
});

hapyak.playlist.all

Return array of all known HapYak Playlist instances on page

hapyak.playlist.get(playlistId)

Retrieve single HapYak Playlist instance by playlistId (e.g. instance.pid)

Instance methods

back()

Load previously loaded video

isFirst()

Return boolean for whether current video is first in playlist

isLast()

Return boolean for whether current video is first in playlist

first()

Load first video in playlist

last()

Load last video in playlist

next()

Load next video in playlist (if on last, will load first video)

pause()

Pause currently displayed video

play()

Play currently displayed video

play(value)

Supported as value

  • number: Either the playlist's zero-based index number for the video, or its internal ID number

    • play(3): Play fourth video in playlist
    • play(11837055): Play video matching internal id
  • string: Either the video's source_id or a string for searching against video title, e.g.

    • play('y2230tyl5c'): Play video matching source_id
    • play('happy holidays'): Play first video matching string

play(value, seconds)

Same as previous, providing seconds to seek to after video load

previous()

Load previous video in playlist (if on first, load play last video)

volume(value)

Set volume to value

volume()

Return current volume

viewer(options)

Attach HapYak Viewer to playlist video player