Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejs
new Frequency.Player({
    config: {// optional
        basePath: '.'
    },
    session: {// mandatory
        'x-frequency-auth': '013ffaa2-a64e-4974-a9ee',
        'x-frequency-deviceid': '5680c4f2-e3fd'
    },
    adConfig: {// optional
        minBitrate: 100,
        maxBitrate: 5000,
        maxResolution: '720p',
        deliveryFormat: 'progressive'
    },
    video: {// mandatory
        "video_id": "12345",// mandatory
        "title": "Gangnam Style",
        "description": "Good Dance Video",
        "image_url": "http://image1.frequency.com/uri/w{width}_h{height}_ctrim_tt1406242656000/_/item/1/8/3/2/Kelsey_Grammer_Welcomes_6th_Child_183236961_thumbnail.jpg",
        "deep_link": "frequency://video/12345/-/4-895",
        "media_url": "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4",// mandatory
        "media_type": "h264",
        "media_types": ["h264", "hls"],
        "resolution": "1080p",
        "resolutions": ["1080p", "720"],
        "duration": 3600,
        "source": "Online",
        "source_id": "X8yZ4f",// mandatory
        "source_url": "http://www.eonline.com/videos/223996/kelsey-grammer-welcomes-6th-child",
        "score": 126,
        "meta_tags": [
            {"network": "Machinima"},
            {"genre": "Gaming"},
            {"subgenre": "Action"},
            {"series": "Random LOL Moments"},
            {"season": "1"},
            {"episode": "489"}
        ],
        "channel": {
            "channel_id": "4-1234",
            "title": "News",
            "image_url": "http://image1.frequency.com/uri/w{width}_h{height}/_/user/1/8/5/0/1385085551000_abc_nightly_news_1850953_avatar.jpg",
        },
        "referrer_link": "https://twitter.com/zgutierrez90/status/446459061161451520",
        "ad_tag": "https://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=%2F105934051%2FtestAdUnit&impl=s&gdfp_req=1&env=vp&output=vast&unviewed_position_start=1&url=[referrer_url]&description_url=[description_url]&correlator=1485732061110",// mandatory for ads
        "ad_cue_points": [0],// mandatory for ads
        "date_publish": "2014-07-29T14:18:10Z",
        "date_available": "2014-07-29T14:18:10Z",
        "date_expired": "2014-07-29T14:18:10Z",
        "last_updated": "2014-07-29T14:18:10Z",
        "autoplay": true
    },
    events: {// optional
    	onStateChange(state) {
			...
		}  
    }
})

           

...

State

Value

Description

UNKNOWN

undefined

Player state is unknown, player setup process did not finished.

UNSTARTED

-1

Player media ready but pending play action.

ENDED

0

Player finished playback.

PLAYING

1

Player is currently playing a video.

PAUSED

2

Player paused.

BUFFERING

3

Player is buffering.

LOCKED

4

Player locked by internal action.

 

SEEKING5Played seeking.
ERROR6Player interface returned error.

 

Code Examples

Initialization

The sequence to using the Frequency Javascript Player is as follows:

...

Code Block
var player = new Frequency.Player();

The player can be initialized with video and listener bindings so that it is one-shot ready to play or the player object can be constructed and setting the video to play and event listeners in subsequent method calls.   

Code Block
var player = new Frequency.Player(
                undefined, {
                   video: {
                      url: 'clips.vorwaerts-gmbh.de/big_buck_bunny.mp4',
                      startPosition: 50,
                      autoplay: true,
                      adsConfig: {
                          adTagUrl: '/some/url/to/vast.xml',
                          adCuePoints: [12345, 23456, 34567]
                      }
                   },
                   events: {
                      onStateChange: function(state) {
                      },
                      onProgress: function(currentTime) {
                      },
                      onVolumeChange: function(volume) {
                      },(...)
                   } 
                }      
             );

...

Add player event listeners.

Code Block
player.addEventListener(Frequency.Player.Events.onError, errorHandler);
player.addEventListener(Frequency.Player.Events.onProgress, progressHandler);

Play the video.

Code Block
player.loadVideo({url:'http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4'});
player.play();

...

Demo

Frequency Player Demo