Using jQuery to embed a movie using Flowplayer

Share this article

Follow these simple steps to embed a movie using Flowplayer (an Open Source video player). There are heaps of customisations that you can make to the player which I will share in seperate posts in more detail – including ipad support, custom controls, RTMP/RTSP live streaming, auto play, clip scaling, player debugging, changing resolution, dynamic video size etc… This post details the minimal setup for the player to get you started.

Related Posts:


scaling-fit

HTML


    

Status Ready.

jQuery

//video or stream address
var streamAddressFull = "http://streamaddress/mp4:filename/playlist.m3u8",
    vidElem = $('#fms'),
    statusElem = $('#video-stream-status .status');

$f('fms', "http://releases.flowplayer.org/swf/flowplayer-3.2.7.swf",
{
    /** ------- Error Handling -------- **/

    debug: debug,  //output all events triggered by the Flash component to the console

    onError: function(e)
    {
        statusElem.html("Error: (code:"+e+").");
    },

    // we need at least this version of flash
    version: [9, 115],

    // older versions will see a custom message
    onFail: function()
    {
          statusElem.html("You need the latest Flash version to view MP4 movies. " + "Your version is " + this.getVersion());
    },

    onBeforeLoad:function()
    {
        statusElem.html("Loading...");
    },

    /** ------- Clip Configurations -------- **/

    clip:
    {
        url: streamAddressFull,
        scaling: 'fit', //fit, scale, orig, half
        autoPlay: true,
        autoBuffering: true,

        onStart: function(clip)
        {
            statusElem.html("Playing.");
        }
    },

    plugins:
    {
        controls:
        {
            // display properties such as size, location and opacity
            right: 0,
            bottom: 0,
            opacity: 0.95,
            backgroundGradient: 'low', //faded slightly
        }
    },

    /** ------- Look and Feel -------- **/

    canvas:
    {
        backgroundGradient: 'none',
        backgroundColor: '#000000'
    }

});

Frequently Asked Questions (FAQs) about jQuery Embed Movie Flowplayer

How can I install Flowplayer on my website?

Installing Flowplayer on your website is a straightforward process. First, you need to download the Flowplayer script from the official website. Once downloaded, you can include the script in your HTML file. You will also need to include the Flowplayer CSS file in your HTML file. After that, you can initialize Flowplayer by calling the Flowplayer function and passing the ID of the HTML element where you want the player to appear. You can also pass configuration options to customize the player’s appearance and behavior.

Can I use Flowplayer with jQuery?

Yes, you can use Flowplayer with jQuery. Flowplayer provides a jQuery plugin that you can use to control the player using jQuery. This allows you to take advantage of jQuery’s powerful features and syntax to create more complex and interactive video experiences.

How can I customize the appearance of Flowplayer?

Flowplayer allows you to customize its appearance using CSS. You can change the player’s size, colors, and other visual elements by modifying the CSS properties of the player’s elements. You can also use the configuration options provided by Flowplayer to change the player’s behavior and features.

Can I use Flowplayer to play videos from different sources?

Yes, Flowplayer supports playing videos from different sources. You can play videos from your own server, from a CDN, or from other video hosting services. You just need to provide the URL of the video file when initializing the player.

How can I control the playback of a video using Flowplayer?

Flowplayer provides a JavaScript API that you can use to control the playback of a video. You can play, pause, stop, seek, and adjust the volume of a video programmatically using this API. You can also listen to various events, such as when the video starts playing, when it ends, or when an error occurs.

Is Flowplayer compatible with all browsers?

Flowplayer is designed to be compatible with all modern web browsers. It uses HTML5 video technology, which is supported by all major browsers, including Chrome, Firefox, Safari, and Edge. However, it may not work correctly in older browsers that do not support HTML5 video.

Can I use Flowplayer on mobile devices?

Yes, Flowplayer is fully responsive and works on mobile devices. It automatically adjusts its size and controls to fit the screen size of the device. It also supports touch controls for playing, pausing, and seeking the video.

Can I embed multiple Flowplayer instances on the same page?

Yes, you can embed multiple Flowplayer instances on the same page. Each player operates independently and can play different videos. You just need to provide a unique ID for each player when initializing it.

Can I use Flowplayer to play live streams?

Yes, Flowplayer supports playing live streams. You can play live streams from your own server or from other streaming services. You just need to provide the URL of the stream when initializing the player.

How can I troubleshoot problems with Flowplayer?

If you encounter problems with Flowplayer, you can check the JavaScript console for error messages. Flowplayer provides detailed error messages that can help you identify and fix problems. You can also refer to the documentation and the community forums for help.

Sam DeeringSam Deering
View Author

Sam Deering has 15+ years of programming and website development experience. He was a website consultant at Console, ABC News, Flight Centre, Sapient Nitro, and the QLD Government and runs a tech blog with over 1 million views per month. Currently, Sam is the Founder of Crypto News, Australia.

jQuery
Share this article
Read Next
Get the freshest news and resources for developers, designers and digital creators in your inbox each week