Calling a JavaScript function when a video starts playing in the CFMEDIAPLAYER tag in ColdFusion 9

Readability

Calling a JavaScript function when a video starts playing in the CFMEDIAPLAYER tag in ColdFusion 9

In a pre­vi­ous exam­ple, “Dis­play­ing videos using the CFME­DI­APLAYER tag in Cold­Fu­sion 9, we saw how you could dis­play an .FLV video in your Cold­Fu­sion web­site using the <CFME­DI­APLAYER> tag and spec­i­fy­ing the source property.

The fol­low­ing exam­ple shows how you can call a cus­tom JavaScript func­tion when a video starts play­ing in the <CFME­DI­APLAYER> tag by spec­i­fy­ing the onStart attribute.



    



    
 


And the out­put of the <CFME­DI­APLAYER> tag is as fol­lows:

In a previous example, “Displaying videos using the CFMEDIAPLAYER tag in ColdFusion 9”, we saw how you could display an .FLV video in your ColdFusion website using the <CFMEDIAPLAYER> tag and specifying the source property.

The following example shows how you can call a custom JavaScript function when a video starts playing in the <CFMEDIAPLAYER> tag by specifying the onStart attribute.

<html>
<head>
    <script type="text/javascript">
        function cfmediaplayer_onStartHandler() {
            alert("media player is starting!");
        }
    </script>
</head>
<body style="padding:20px;">
 
    <cfmediaplayer name="flvPlayer"
            source="http://helpexamples.com/flash/video/caption_video.flv"
            onStart="cfmediaplayer_onStartHandler" />
 
</body>
</html>

And the output of the <CFMEDIAPLAYER> tag is as follows:

Leave a Reply

Your email address will not be published.