2.2, Jwplayer video playback (FLV,MP4) implementation and packaged PHP interface

Source: Internet
Author: User

2.2.1, PHP call method
<?PHPclassflv{var $flv _root= '/resources/jwplayer/';  Public Static functionGet_header () {Echo"<script type= ' text/javascript ' src= '/resources/jwplayer/jwplayer.js ' ></script>"; }        #$arr An array-type playlist;    #only one video does not display the playlist, the entire width is set to 800px, multiple videos show playlists, width is set to 1000px, and the playlist width is set to 200px;     Public functionflv$arr){        $width=800; $height=450; $size=1; if(Count($arr) >=2){            $size=200; $width=1000; }                $list= Json_encode ($arr); $retval= ' '; #$options = Array ();         $retval. = "<div id= ' myelement ' ></div>\n"; $retval. = "<script type= ' text/javascript ' >\n"; $retval. = "Jwplayer (' MyElement '). Setup ({\ n"); $retval. = "Flashplayer: '/resources/jwplayer/jwplayer.flash.swf ', \ n";#Player Path        $retval. = "PRIMARY: ' Flash ', \ n";#The default is played in Flash, or it can be set to HTML5        $retval. = "playlist:{$list},\n ";#Play List        $retval. = "width:{$width},\n ";#player width (including playlist)        #$retval. = "Aspectratio: ' 4:3 ', \ n"; #播放器长宽比        $retval. = "Height: {$height},\n ";#Player Height        $retval. = "Listbar:{position: ' Right ', size:{$size},layout: ' Extended '},\n ';#player list display style basic/extended        $retval. = "Captions:{color: ' #FF0000 ', backgroundcolor: ' #F1F1F1 ', Windowcolor: ' #FF6600 '},\n ';#set the node display style and load the. vtt file        $retval. = "Logo:{file: ', Link: ' http://www.hrloo.com '},\n";#address of Logo link and logo link        $retval. = "Autostart: ' false ', \ n";#whether to play automatically        $retval. = "Repeat: ' true ', \ n";#whether to loop playback        $retval. = "Startparam: ' Start ', \ n"; $retval. = "Provider: ' http ', \ n";#Video Stream protocol type        $retval. = "Stretching: ' uniform ', \ n";#video Thumbnail (video) Fill type: equal scale zoom in/out fill        $retval. = "Streamer: ' Start '";#set the video file load mode, whether to support drag loading, FLV (start)        $retval. = "}); \ n"; $retval. = "</script>"; Echo $retval; }    }?>
2.2.2, the invocation parameter format is:
<?PHP#List array is passed to the player parameters (multiple video, multiple resolutions)$list=Array(        Array(                ' Image ' = ',//Video Cover' Sources ' =Array(                                                Array(' file ' = ' flv/ssshr1024x768.flv ', ' label ' = ' 1024x768 '),//playback video path and sharpness hint selection                        Array(' file ' = ' flv/ssshr640x480.flv ', ' label ' = ' 640x480 ', ' default ' = ' true '),//default option to set the definition                        Array(' file ' = ' flv/ssshr352x288.flv ', ' label ' = ' 352x288 ')                ), ' title ' + ' Human Resources training course test ',//Video Title' Description ' = ' Training course ',//Video Introduction, playlist for picture mode can be displayed' Tracks ' =Array(                        Array(' file ' = ' mario.vtt ', ' kind ' = ' chapters '),//video node hint Fumiko                        Array(' file ' = = ', ' kind ' = ' thumbnails ')//video node thumbnail                        )                ),Array(                ' Image ' = = ', ' sources 'Array(                        Array(' file ' = ' flv/sco01_01.swf ', ' label ' = ' 720p HD '),Array(' file ' = ' mario.flv ', ' label ' = ' 720p HD ')                        ), ' title ' = ' mario1 test flv ', ' description ' = ' mario Mario ', ' tracks ' =Array(                        Array(' file ' = ' mario.vtt ')                        )                )    )?>
2.2.3, how to use:
<? PHP $flv new flv ($list); $flv-Get_header (); $flv->flv ($list);? >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.