SOURCE URL: https://flowplayer.org/docs/setup.html
At the top of your page declare the HTML5 doctype:
<!DOCTYPE html>
Otherwise HTML5 video will not work in some browsers, notably Internet Explorer 9.
<!-- 1. skin -->
<link rel="stylesheet" href="//releases.flowplayer.org/5.4.6/skin/minimalist.css">
<!-- 2. jquery library -->
<script src="//code.jquery.com/jquery-1.10.2.min.js"></script>
<!-- 3. flowplayer -->
<script src="//releases.flowplayer.org/5.4.6/flowplayer.min.js"></script>
For each player you need this HTML snippet
<div class="flowplayer">
<video>
<source type="video/webm" src="http://mydomain.com/path/to/intro.webm">
<source type="video/mp4" src="http://mydomain.com/path/to/intro.mp4">
</video>
</div>
ratio
configuration optionThe HEAD and BODY tags shown above create a minimal setup.
This is the automatic installation method. The quickest and easiest way to get you going with a simple setup.
Here is a customized setup to give you an idea of the possibilities:
<div class="player" data-ratio="0.4167">
<video preload="none">
<source type="video/webm" src="http://mydomain.org/intro.webm">
<source type="video/mp4" src="http://mydomain.org/intro.mp4">
<source type="video/ogg" src="http://mydomain.org/intro.ogv">
</video>
</div>
<script>
// run script after document is ready
$(function () {
// install flowplayer to an element with CSS class "player"
$(".player").flowplayer({ swf: "/swf/5.4.6/flowplayer.swf" });
});
</script>
flowplayer
jQuery plugin.flowplayer
call.preload
attribute.source
tags.See this example.
v5.4 With the manual installation method you can install the player with JavaScript only without providing a HTML video tag on your page. Simply specify the video sources as item(s) of the playlist configuration:
$(function () { // ensure DOM is ready
// this will install flowplayer into an element with id="player"
$("#player").flowplayer({
// one video: a one-member playlist
playlist: [
// a list of type-url mappings in picking order
[
{ webm: "http://mydomain.org/video.webm" },
{ mp4: "http://mydomain.org/video.mp4" },
{ ogg: "http://mydomain.org/video.ogv" }
]
],
ratio: 3/4 // video with 4:3 aspect ratio
});
});
You can put the above incantation anywhere on your page, also in the HEAD section - after loading jQuery and the flowplayer script. jQuery ensures that the document is ready for the player installation. Then all you need on your page is this:
<!-- empty container element with unique id="player" -->
<div id="player"></div>
Check out the demo.
There are two ways to initialize Flowplayer
$(".my-custom-player-container").flowplayer({ ratio: 5/12 });
The size of the player is determined by the container element's dimensions. For example:
.flowplayer {
width: 600px;
height: 338px;
}
Using hard coded width and height is not recommended since the player size is fixed no matter what the screen size is. Flowplayer is designed in such a way that it will adjust itself to various screen sizes.
By default Flowplayer uses all the width that it is given, and the height of the player is determined by the ratio
configuration setting which defaults to 9/16
. Under the premise that letterboxing or empty sidebars on the video screen are to be avoided, this assumes a video of 16/9 aspect ratio. Note how the notation is the inverse ratio of how one usually specifies the aspect ratio of a video: height/width (container) as opposed to width/height (video).
You can change the ratio in the player configuration:
flowplayer.conf.ratio = 3/4;
Or you can set the ratio in the HTML configuration using the data-ratio
attribute of the container element as follows:
<div class="player" data-ratio="0.417">
<video>...</video>
</div>
The default value of data-ratio
is "0.5625"
, i.e. the default ratio of 9/16.
Alternatively you can change the container's ratio via CSS:
.flowplayer .fp-ratio {
padding-top 41.7%
}
Now when you resize the browser the video size will adjust accordingly, and the video's width/height ratio is kept.
Since v5.4.2 you can also let the player size dynamically be determined by the video's aspect ratio: Set the adaptiveRatio
JavaScript configuration option to true
.
This comes in handy for quick setups when you do not happen to know the exact dimensions of the video, but still want the player's screen size to match the aspect ratio of the video. By consequence refrain from configuring adaptiveRatio
for a splash setup as the video's dimensions - and therefore its aspect ratio are only available once the video is loaded and the player is ready.
The poster setup is recommended when you want to preload the video at startup while giving the player a custom look and feel.
Since v5.2 Flowplayer features an extended and flexible concept of the poster
VIDEO tag attribute: If the poster
attribute is given, it will also be used as CSS background image of the container element. Par consequence you can also choose to omit the poster attribute, and instead specify a background image or background color (treated as monochrome "poster") CSS directive to the same effect.
The advantages of this approach:
To sum up, a poster setup requires that
background-image
or background-color
CSS rule applies to the container element orposter
attribute andIf both background-image
for the container and poster
attribute for the VIDEO tag are given, the poster image takes precedence and replaces the background image.
When the above conditions are met, the CSS "is-poster" state class is assigned to the container at startup. This allows you for instance to create a loading animation for the entire player area with a few CSS rules, like in this example poster setup.
Flowplayer has a unique feature called "splash screen" which is similar to the poster setup except that the nested VIDEO or Flash OBJECT tag initially is not present on the page, but is inserted on demand. The player is installed on the fly when the user clicks on the splash screen. This has the following benefits:
By design the splash setup also disables preloading of the video.
Please have a look at the poster and splash comparison page.
To set up splash screens you either add the state class name "is-splash" to the CSS class of the container element:
<div class="flowplayer is-splash"
style="background:#777 url(/path/to/splash.jpg) no-repeat;">
<video>
<source type="video/webm" src="http://mydomain.com/path/to/intro.webm">
<source type="video/mp4" src="http://mydomain.com/path/to/intro.mp4">
</video>
</div>
Or you script the addition of the "is-splash" state class by turning the splash
configuration option on. For instance this global configuration applies the splash setup to all players on the page:
flowplayer.conf = {
splash: true
};
The splash image is given in the CSS background or background-image
directives for the container element. However, providing an image is not mandatory to set up a Flowplayer splash screen; in fact there is no CSS requirement for the splash setup. Usually you want at least a background-color
to discern the player from its surroundings.
Here is how it works:
splash
option the VIDEO tag is temporarily removed from the container element.unload
API method.Splash screens are used heavily in our demo area. They are one of the main reasons why people use Flowplayer.
Currently 3 major video formats are used on the web.
Since v5.3 Flowplayer also supports HLS (Apple HTTP Live Streaming) from M3U8 files (demo).
Browser | ogg | mp4 | webm | m3u8 |
Internet Explorer | - | 9.0 | - | - |
Firefox | 3.5 | - | 4.0 | - |
Chrome | 3.0 | 3.0 | 6.0 | - |
Safari | - | 3.1 | - | 6.0 |
Opera | 10.5 | - | 10.6 | - |
Taken from Wikipedia.
By default Flowplayer attempts to use HTML5 video, and if it's not supported then Flash (9.0+) and MP4 is used. MP4 is enough for complete browser support, but providing WebM and/or OGG video gives you broader support for HTML5 video which is the preferred technology. Also note that Flash does not support byte-range requests, therefore random seeking will not work with MP4 in Flash mode.
Note that browser support of video formats is subject to changes - Chrome is planning to remove MP4 support, and Firefox is planning to add MP4 support. Your best bet for reliable HTML5 video is to provide MP4 and WEBM variants for each of your videos.
Safari on Windows is capable to play HTML5 video when QuickTime is installed.
HLS support so far is confined to on-demand streams because of the lack of HTML5 live video alternatives.
Check out this detailed table which shows what formats your current browser can play.
<div class="flowplayer">
<video preload="none">
<source type="video/mp4" src="http://mydomain.com/path/to/intro.mp4">
</video>
</div>
Always use a SOURCE tag inside the VIDEO tag and specify the video type. Flowplayer will then tweak the VIDEO tag as needed by platform or browser. Or, for the Flash engine, replace it with a Flash object
.
Important: If you intend to offer embedding the value of the src
attribute must be an absolute URL - unless it is a RTMP location. Enforcing the HTTP protocol is also recommended for playback quality.
<div class="flowplayer">
<video>
<source type="application/x-mpegurl" src="http://mydomain.com/intro.m3u8">
<source type="video/webm" src="http://mydomain.com/intro.webm">
<source type="video/mp4" src="http://mydomain.com/intro.mp4">
<source type="video/ogg" src="http://mydomain.com/intro.ogv">
</video>
</div>
v5.4 With the manual installation method you can provide the formats in the JavaScript configuration as described in the section for installation into an empty container.
The syntax is the same as for the API's load method: a list of type-url mappings in picking order.
First Flowplayer decides which engine to use, depending on the engine
configuration or the capabability of the browser, and will choose from the HTML5 sources or pick the Flash source.
The HTML5 sources will be tested and picked in the order you list them in the video tag or in the JavaScript array. For example, if you deploy a HLS stream (application/x-mpegurl), it must listed before the MP4 source, otherwise the HLS stream will never be picked because only browsers which can play MP4 also play M3U8 files.
Due to a bug in some Chrome versions you should also list WEBM before MP4.
It is recommended to provide the OGG format only in addition to WEBM and MP4 and as a last resort for older browsers. Many Opera versions for instance have problems in processing the necessary metadata and might not be able to load OGG in spite of claiming to support it.
Make sure that all the files are available on the server and that the server transmits them with the correct Content-Type. Depending on your server you might have to extend the .htaccess
or mime.types
files (Apache), use the IIS manager (Internet Information Server) or set the header via Metadata (Amazon S3). Example .htaccess
file:
AddType video/webm .webm
AddType video/mp4 .mp4
AddType video/ogg .ogv
AddType application/x-mpegurl .m3u8
# hls transport stream segments:
AddType video/mp2t .ts
The nested VIDEO tag accepts various arguments. For example:
<video autoplay loop>
Both the HTML5 video tag and the Flash component respect these attributes. Particularly have a look at Flowplayer's poster implementation.
Note that there are few browser issues.
By default Flowplayer uses the HTML5 video tag and falls back to Flash when HTML5 video is not supported. Alternatively Flowplayer can be configured to use Flash first and then fall back to HTML5 when Flash support is not present. The primary engine can be configured with the engine
option or the data-engine
attribute:
This will play intro.mp4
using the Flash engine if Flash is enabled in the browser:
<div class="flowplayer" data-engine="flash">
<video>
<source type="video/webm" src="http://mydomain.com/path/to/intro.webm">
<source type="video/mp4" src="http://mydomain.com/path/to/intro.mp4">
</video>
</div>
The Flowplayer Flash component requires Flash version 9.0.0. To play mp4 files the browser needs at least Flash version 9.0.115 to be installed. If you want to support v9.0.0 you need to provide a FLV file.
This will play intro.flv
if HTML5 video is not supported and Flash version greater or equal 9.0.0 is installed:
<div class="flowplayer">
<video>
<source type="video/webm" src="http://mydomain.com/path/to/intro.webm">
<source type="video/mp4" src="http://mydomain.com/path/to/intro.mp4">
<source type="video/flash" src="http://mydomain.com/path/to/intro.flv">
</video>
</div>
Flowplayer supports a special video/flash
source type to target video specifically for Flash. For example:
<div class="flowplayer">
<video>
<source type="video/webm" src="http://mydomain.com/path/to/intro.webm">
<source type="video/mp4" src="http://mydomain.com/path/to/intro.mp4">
<source type="video/flash" src="http://mydomain.com/path/to/intro-flash.mp4">
</video>
</div>
The Flash engine will always pick the source of type video/flash
("intro-flash.mp4" here) regardless of the order in which the sources are listed. This special support is handy when you want to optimize your video encoding specifically for the Flash engine, or load the flash video from an alternate location, or use the rtmp protocol.
All these are supported by Flowplayer Flash and currently not by Flowplayer HTML5.
The Flowplayer HTML5 Flash engine supports the RTMP protocol so you can do streaming. DRM and quality switching are not supported at the moment. We have plans and will keep a close eye on the future of Flash.
Here's an overview of the available keyboard shortcuts to control the player:
Key | Action |
space | play/pause |
q | stop | unload (in a splash setup) |
f | fullscreen |
shift + left arrow | slower (see the speeds option) |
shift + right arrow | faster (see the speeds option) |
down arrow | volume down |
up arrow | volume up |
m | mute |
left arrow | seek backward |
right arrow | seek forward |
. | seek to previous position |
number | seek to number times 10 percent of duration |
Keyboard shortcuts can be turned off by setting the keyboard
configuration option to false
.
A cheat sheet of the shortcuts is always available to the user when she types ?
while hovering over the player area. See also the tooltip
configuration option.
The player supports various configuration options. For example:
<script>
$(".myplayer").flowplayer({
// option 1
swf: '/swf/flowplayer.swf',
// option 2
rtmp: 'rtmp://s3b78u0kbtx79q.cloudfront.net/cfx/st'
});
</script>
option | default value | description |
adaptiveRatio | False | v5.4.2 whether the player's ratio adapts vertically to the video's aspect ratio. Only available as JavaScript configuration option. Do not apply in conjunction with the ratio and flashfit options. |
bufferTime | 0.1 | v5.4.4 specifies how long to buffer messages before starting to display the stream. See Adobe's docs for NetStream.bufferTime for more info. Affects the Flash engine only and only available as JavaScript configuration option. |
debug | False | show debug messages on the console. Causes errors if window.console is not present |
disabled | False | whether playback should be forced by disabling the UI. Seeking, pausing etc. is impossible. API still works. Typically used in ads. |
engine | 'html5' | the first engine to try. currently supported values are "html5" and "flash" |
flashfit | False | v5.3 whether video aspect ratio in Flash non-fullscreen mode is preserved. Only set this to true if the container's dimensions do not fit the video's aspect ratio, e.g. for playlists with clips of different aspect ratio. Note that setups with dynamic container resizing require the container to be of the same ratio as the video. The option also cannot deal with anamorphic videos as Flash is agnostic of a video's display aspect ratio. |
fullscreen | True | v5.2 whether fullscreen is enabled. Defaults to false when the player is viewed in an IFRAME. |
errors | Array | An array of error messages. The default list can be found in the API documentation. |
keyboard | True | use keyboard shortcuts - enabled by default |
live | False | v5.4.4 whether the player is set up for live streaming (experimental); skinning alternative: is-live state class |
muted | False | v5.2 whether player should start in muted state |
native_fullscreen | False | v5.1 Use native fullscreen on mobile webkit browsers (iPad, Android) instead of full browser window. The screen will be bigger but native video controls will be in use instead of customizable Flowplayer controls. |
ratio | 9 / 16 | A decimal number representing the height of the player in proportion to its width. You usually want to change this setting for videos with a different aspect ratio than 16/9. You can override this by explicitly setting the height CSS property for the container in which case the player height stays the same on all devices and screen sizes. |
rtmp | Location of the Flash streaming server. When provided it's possible to jump randomly on the video timeline on Flash mode. Read more about server side. | |
speeds | [0.25, 0.5, 1, 1.5, 2] | v5.1 the available speed levels that are used with SHIFT + arrow keys or with speed() API method. 1 is the default speed and values less than 1 means slow motion and values greater than 1 means fast forward. Not supported by the Flash engine, older browsers and many mobile devices. |
swf | location of the Flash file. path can be absolute or relative. By default this is "//releases.flowplayer.org/5.4.6/flowplayer.swf" for the free version. | |
splash | False | Enables splash screen; skinning alternative: is-splash state class |
tooltip | True | v5.2.1 Whether "Hit ? for help" tooltip is shown |
volume | 1 | initial volume level |
Various plugins accept additional configuration options:
The provided configuration can also be just a string, in which case it is interpreted as the swf
option.
The commercial version allows you to get rid of the Flowplayer logo and optionally use your own. By default this will be displayed in the bottom/left corner of the player in the embedded players. When a user clicks the logo she will be redirected to the originating page.
Here are the configuration variables for the commercial version:
option | default | description |
key | A valid license key removes the Flowplayer branding from the player. Since v5.1 the value can be a comma separated string of keys to support multiple domains. For example: '$688345122773207, $334773811075656' |
|
logo | Location of your logo. URL or path. | |
swf | Location of the Flash file. URL or path. By default this is "//releases.flowplayer.org/5.4.6/commercial/flowplayer.swf" for the commercial version. |
Here is a minimal commercial setup. Take a look at its source code and you can see how the key is provided. You create the key on your account page after purchase by entering the domain name you wish to license into the "Add domain" field.
Make sure to deploy the commercial release available at your Flowplayer account, or to load the commercial API script from //releases.flowplayer.org/5.4.6/commercial/flowplayer.min.js
. Also update the location of flowplayer.swf
- in case you previously configured it explicitly via data-swf
or flowplayer.conf.swf
- to point to the commercial version. Both the commercial API script flowplayer.min.js
and Flash file flowplayer.swf
are required for license validation.
By default the logo is not shown on your own site (origin domain) because your branding is already there. You can change this with CSS:
.flowplayer .fp-logo {
display: block;
opacity: 1;
}
To always show your logo, even while the mouse does not hover over the player area, use:
.flowplayer .fp-logo {
display: block;
opacity: 1 !important;
}
Here we provide global settings for all players on the page:
<script src="//releases.flowplayer.org/5.4.6/flowplayer.min.js"></script>
<!-- global options -->
<script>
flowplayer.conf = {
ratio: 5/12,
swf: "/media/swf/flowplayer.swf",
analytics: "UA-27182341-1"
};
</script>
The flowplayer.conf
object contains the configuration for Flowplayer. You should customize its properties right after Flowplayer has been included in your page (with script src
). Another common place to put site-wide Flowplayer defaults is in an external javascript file which contains the website logic and is loaded after the basic assets. This is a nice way to set up global settings such as the Google Analytics ID and paths to embedding and flash files.
Each player will have these as defaults but they can be overridden for individual players.
You can set individual options as follows:
<script src="//releases.flowplayer.org/5.4.6/flowplayer.min.js"></script>
<script>
flowplayer.conf.ratio = 5/12;
</script>
Remember to set these after the flowplayer.conf = {...}
setting if you have one because setting the entire conf
object will discard any individual property settings.
This is the way to configure specific players on the page in conjunction with a manual installation when the document is ready:
$(function () {
// install player into container elements of class="selected"
$(".selected").flowplayer({
// configuration for this player
splash: true,
analytics: "UA-27182341-1"
});
});
The configuration is normally passed as in JavaScript Object Notation as argument to the flowplayer()
call. If the argument is a simple string it is treated as the location of the flowplayer swf file.
In this case you avoid to set the hard-coded "flowplayer" class for the container element to avoid processing overhead by an attempted automatic install.
See the manual installation details, installation into an empty container or the JavaScript playlists for further examples.
Selective configuration overrides global configuration.
Configuration options can also be defined directly in HTML code with "data-" prefix:
<div class="flowplayer" data-ratio="0.5625" data-volume="0.5">
<video autoplay>
<source type="video/webm" src="http://mydomain.com/path/to/myvideo.webm">
<source type="video/mp4" src="http://mydomain.com/path/to/myvideo.mp4">
</video>
</div>
By taking advantage of the hard-coded "flowplayer" class name, global configuration and data attributes you can set up players with just HTML and CSS.
Camel cased option names like adaptiveRatio
must be written as compound lower cased attributes: data-adaptive-ratio
.
HTML configuration overrides global configuration and selective JavaScript configuration.
The above override rules result in this order of precedence regarding the possibilities to configure the player:
If you want to jump randomly on the timeline without caring how much video has been downloaded, your server needs to support both byte-range requests (for HTML5 video) and the RTMP protocol (for Flash). Note that you cannot seek in MP4s with byte-range requests in Flash mode, therefore, in case you cannot deliver via RTMP, you should always provide an alternative video source (WEBM or OGG video) for e.g. Firefox.
The easiest way to do this is to use a content delivery network such as Amazon Cloudfront which supports both of these technologies and serves the video files from locations closest to your audience.
For HTML5 video you don't have to do any client side configuration. If your server supports byte-range requests then seeking should work on the fly. Most servers including Apache, Nginx and Lighttpd support this.
RTMP support is provided by streaming servers such as Adobe FMS or Wowza. Once it's been set up you need to configure the server connection URL (also called Net Connection URL) via the rtmp
option and add an additional source
tag of type="video/flash"
with the path to the video file in its src
attribute.
<!-- flowplayer with RTMP configuration option -->
<div class="flowplayer" data-rtmp="rtmp://s3b78u0kbtx79q.cloudfront.net/cfx/st">
<video>
<!-- consumed by flash -->
<source type="video/flash" src="mp4:path/to/myvideo.mp4">
<!-- consumed by html5 video tag -->
<source type="video/webm" src="http://my.stream.com/myvideo.webm">
<source type="video/mp4" src="http://my.stream.com/myvideo.mp4">
</video>
</div>
For players shown in an IFRAME fullscreen is disabled by default. It would not work in browsers without native fullscreen support, and some browsers forbid fullscreen from IFRAMEs, notably from a remote orgin, without offering a reliable detection mechanism.
If you are in control of the IFRAME's source and the page where the IFRAME is shown you can allow fullscreen by excplicitly setting the fullscreen
configuration option to true
on the originating page and specifying the allowfullscreen
attributes for the IFRAME:
<iframe src="http://example.com/iframe-src.html"
width="800" height="500"
webkitallowfullscreen="true"
mozallowfullscreen="true"
allowfullscreen="true"></iframe>
Check out the iframe demo.