You are here

Single Sign-On (SSO) Implementation for HKU Video Streaming Service

Introduction

The Single Sign-On (SSO) Implementation of the HKU video streaming service allows you to apply access control to your videos.  It is assumed that your videos are stored in the HKU video server and that they support RTMP streaming.  Departments can upload files to the video server through a video streaming account created by ITS. To apply for this account, please fill in CF43.

Publicly Accessible Videos With No Access Control (Public Videos)
These videos can be accessed by anyone on the Internet.  They can be played by Adobe Flash player (or compatibles). Details about how to upload the video files and render the webpage can be found in the following link:
http://www.its.hku.hk/documentation/guide/communication/streaming/flash

SSO Controlled Videos (SSO Videos)
These videos are restricted to users with HKU Portal accounts.  There are two levels of access control: one is that the videos can be accessed by all HKU Portal users; the other is that the videos are limited to selected group of HKU Portal users.  Details on how to configure access control will be given in a later section.

There are some basic requirements for playing SSO videos:

  1. The web browser must support Adobe Flash Player Version 10.1.0 or above
  2. The video must be played by the HKUITS Video Player (a customized video player provided in the HKU Video Server).
  3. The user must have a valid HKU Portal account.

In order to create a SSO controlled video, there are several steps

  1. Uploading  videos to the HKU video server
  2. Embedding the HKUITS video player in the webpage
  3. Applying access control configuration
  4. Registering URLs for SSO access

Uploading SSO videos to the HKU Video Server
The uploading procedure of SSO videos is similar to that of public videos. Public videos are placed in a pre-defined directory called ‘vod’ but SSO videos can be placed in other user-created directories.

(a) Install the CoreFTP program on your PC.

(b) Run the program: Start > All Programs > CoreFTP > CoreFTP Lite

(c) Input the followings:
Site Name: HKU_Video_Server
Host / IP /URL: fmis1.hku.hk
Username: <your account>
Password: <your password>
Connection: SSH/SFTP

(d) Click “Connect”

(e) SFTP your videos’ to /mnt/webroot/user/<yourDept>/<SSO>
where:
<yourDept> stands for the directory name assigned to your department on the HKU Video Server.
<SSO> stands for the directory name where SSO videos are placed (there can be more than one such directory).

HKUITS Video Player (HKUITS  VP)

This section describes:

  • How to embed the HKUITS VP player in your web page
  • Some Java Script API functions

How to embed the HKUITS VP in your web page

  • HKUITS VP is a customized flash player for playing SSO videos. The HKUITS VP has to be embedded into the HTML of a webpage using embedded codes. It is possible to use SWFObject:

swfobject.embedSWF(
 <swf_src>, <replaceElemIDStr>, <widthStr>,<heightStr>,<swfVersionStr>, <xiSwfUrlStr>, <flashVarsObj>, <params>,<Attributes>) ;

where

swf_src: Location of the HKUITS VP.
             For .flv file: "rtmp://fmis.hku.hk/yourDept/sso/myvideo"
             For .f4v file: "rtmp://fmis.hku.hk/yourDept/mp4:/sso/myvideo.f4v"

replaceElemIDStr: This is the HTML DIV id, to be replaced with the embedded content.

widthStr: This is the width of the player.
heightStr: This is the height of the player.
swfVersionStr: The required version of the Adobe Flash player to see the content. Because the  HKUITS VP must be used, , Version 10.1.0 or above is required.
xiSwfUrlStr (optional): It specifies the URL of your express install .swf file.
flashVarsObj: It lists the HKUITS VP configuration options. See 'Basic configuration option'.
params (Optional): It includes the Flash plugin parameters. HKUITS VP sets 'allowfullScreen' to true.
Attributes:(Optional): It includes the HTML attributes of the player.

  • Basic configuration option

Setting

Name

Possible values

Description

Control bar visibility

controlBarAutoHide

true(default), false

Whether the player's controls are visible at all times. With the default value (true), the controls are not displayed unless the user is hovering the mouse over the player. When this occurs, the controls remain visible while the user interacts with the player and for an additional period of time equal to the controlBarAutoHideTimeout setting. With a value of false, the controls are continuously visible and may reduce the amount of the player window avaliable to display content.

Duration of control bar visibility

controlBarAutoHideTimeout

Number

A duration, in seconds, for the control bar to remain visible, after the user has stopped interacting with the player. Default is 3. This value is used when controlBarAutoHide is set to true.

Automatic playback

autoPlay

false (default), true

Starts playing the media automatically, without user input. The default  behavior for the player is to require the user to start playback.

Mute the volume

Muted

false (default), true

Specifies whether the player initially loads content with its volume on or off.

Set the volume

Volume

Number

The initial volume of the media. Allowable values range from 0 (silent) to 1 (full volume).

Ticket obtained after HKUPortal login

Hkuticket

String

The initial value of ticket to access the SSO videos.

URL registered under CAS

Hkuservice

String

The initial value of service to access the SSO videos. It is a URL.

Options

Hkuoption

String

The value is ‘default’.

(c) Sample code on HTML:


<script type="text/javascript" src="http://fmis2.hku.hk/swfs/swfobject.js"></script>
<SCRIPT language=JavaScript>

var swfsrc="http://fmis2.hku.hk/swfs/hku_vp.swf";
                                                        
             var flashvars =                                                       
          { src: queryParameters['source']
                            ,         autoPlay: true
                                           ,controlBarAutoHide: false
                     ,   javascriptCallbackFunction: "onJavaScriptBridgeCreated"
                                ,backgroundColor: "000345"
                                ,hkuticket: queryParameters['ticket']
                                ,hkuservice: queryParameters['url']
                                ,hkuoption: "default"                                                              
                                };
                    
              var params ={};
                     params.quality ="high";
                params.bgcolor="#ffffff";
                params.allowscriptaccess="always";
                params.allowfullscreen="true";
              var attributes={};
                  attributes.name="strobeMediaPlayback";
   
                     // Embed the player SWF:                
                     swfobject.embedSWF
                                ( swfsrc
                                , "champion"
                                , 640
                                , 390
                                , "10.1.0"
                                , {}
                                , flashvars
                                , params
                                , attributes
                                );
     

(d) Click here to see a demonstration of SSO video (you need to login with your HKU Portal account)

Some Java Script API functions
There are some APIs available to give more control on running the HKUITS VP:
(a) pause();
    It controls the player to pause if it is playing.

(b) play2();
    It controls the player to play the video. It would not change the pre-defined parameters of the player.

(c) setautoPlay(true);
    It change the 'autoPlay' parameter of the player.

(d) playHKUMedia( <Ticket>, <Service>, <Option>, <Video source>);
    Ticket: ticket parameter is obtained after successfully logging in HKU Portal.
    Service: a url which is registered under CAS.
    Option: the value is "default"
    Video source: the url of the video source e.g.: "rtmp://fmis.hku.hk/<dept>/sso/myvideo"

(e) player.getState();
    It returns 'playing', 'ready' or 'paused' status of the player.

(f) player.gethkuticket
    It returns the value of 'hkuticket' parameter.

(g) player.gethkuservice();
    It returns the value of 'hkuservice' parameter.

(h) player.gethkuoption();
    It returns the value of 'hkuoption' parameter.

(i) Sample code:


var state = player.getState();
if(state==”ready” || state ==”paused”)s{
player.play2();
}
else
if (state == "playing") {
                                    player.pause();
}

function getHKUvalue()
{
             if(player!=null)
             {
                var t1 = player.gethkuticket();
                var t2 = player.gethkuservice();
                var t3 = player.gethkuoption();                              
                document.getElementById( 'inputURL' ).value =  t1+ " "+t2+ " "+t3;
            player.setautoPlay(true);
                player.playHKUMedia("","",null,"rtmp://fmis.hku.hk/vod/cctest/HDVideo");
              }
}

Applying Access Control Configuration
By default, the SSO videos uploaded to the HKU Video Server are limited to HKU Portal users’ access only. One may, however, further limit access to a selected group of HKU Portal users. This can be done by including the eligible users’ HKU Portal IDs, staff number or student number in a pre-defined text file 'act.txt'. For instance, you would like 10 users to watch a video call 'myaclvideo.flv'. On the HKU video server and under your departmental directory, you should create a folder and place ‘myaclvideo.flv’ and the file ‘acl.txt’ under it. It involves two steps:
1. Edit your ‘acl.txt’, which is simply a text file listing the eligible users’ HKU Portal IDs, Staff ID or Student number. A sample of 'acl.txt' as below:


HKUPortalID1
StudentNumber
Staff Number
HKUPortalID2
HKUPortalID3
HKUPortalID4
.....
HKUPortalID10

2. Upload the restricted videos and ‘acl.txt’ to the HKU Video Server

(a) Install the CoreFTP program on your PC.

(b) Run the program: Start > All Programs > CoreFTP > CoreFTP Lite

(c) Input the followings:
Site Name: HKU_Video_Server
Host / IP /URL: fmis1.hku.hk
Username: <your account>
Password: <your password>
Connection: SSH/SFTP

(d) Click “Connect”

(e) SFTP your videos and ‘acl.txt’ to /mnt/webroot/user/<yourDept>/<SSO>/<acl1>
where:
<yourDept> stands for the directory name assigned to your department on the HKU Video Server.
<acl1> stands for the directory where restricted videos and acl.txt are placed.   

Registering URLs for SSO Access
Finally, the URLs of the SSO videos have to be registered with us before they can be effective. To register the URLs of the videos enabled with SSO, please fill in CF109. The registration is available to departments/offices of HKU only.

Last Updated: 30 November 2017