winlin

update the bootstrap wizard, use v2

不能预览此文件类型
不能预览此文件类型
... ... @@ -197,6 +197,7 @@ vhost dev {
}
}
}
# the http hook callback vhost, srs will invoke the hooks for specified events.
vhost hooks.callback.vhost.com {
http_hooks {
... ...
.wizard {
display:none;
}
.wizard-modal form {
margin:0;
padding:0;
}
.wizard-modal.modal {
width:750px;
margin-left:-375px;
top:50%;
}
.wizard-modal-footer {
padding:0;
}
.wizard-modal-header.modal-header h3 {
line-height:35px;
display:inline
}
.wizard-modal-header.modal-header {
border-bottom:0;
}
.wizard-subtitle {
font-weight:bold;
color:#AFAFAF;
padding-left:20px;
}
.wizard-error,
.wizard-failure,
.wizard-success,
.wizard-loading,
.wizard-card {
position:relative;
padding:35px;
padding-top:20px;
overflow-y:auto;
height:300px;
display:none;
border-top: 1px solid #EEE;
margin-right: 5px;
}
.wizard-nav-link .icon-chevron-right {
float:right;
margin-top:12px;
margin-right:-6px;
opacity:.25;
}
li.wizard-nav-item.active .icon-chevron-right {
opacity:1;
}
li.wizard-nav-item {
line-height:40px;
}
.wizard-no-modal .nav-list > li > a,
.wizard-modal.modal .nav-list > li > a {
background-color:#f5f5f5;
padding:3px 15px 3px 20px;
cursor:default;
color:#B4B4B4;
}
.wizard-no-modal .nav-list li.active > a,
.wizard-modal.modal .nav-list li.active > a {
background-color:#08C;
}
.wizard-no-modal .nav-list > li.already-visited > a.wizard-nav-link,
.wizard-modal.modal .nav-list > li.already-visited > a.wizard-nav-link {
color:#08C;
cursor:pointer;
}
.wizard-no-modal .nav-list > li.active > a.wizard-nav-link,
.wizard-modal.modal .nav-list > li.active > a.wizard-nav-link {
color:white;
}
.already-visited > a.wizard-nav-link:hover {
background-color:#E4E4E4;
}
.wizard-card > h3 {
margin-top:0;
margin-bottom:20px;
font-size:21px;
line-height:40px;
font-weight:normal;
}
.wizard-progress {
padding:15px;
bottom:0;
}
.wizard-progress-container {
padding:20px;
}
.wizard-steps {
width:28%;
height:425px;
background-color:#f5f5f5;
}
.wizard-nav-container {
height:360px;
}
.nav > li > a.wizard-step-error {
background-color:#F2DEDE;
color:#B94A48;
font-weight:bold;
}
.wizard-step-error .icon-chevron-right {
opacity:0;
}
.wizard-input-section {
margin-bottom:20px;
}
.wizard-buttons-container {
padding:20px;
}
.wizard-cancel {
display:none;
margin-left:20px;
}
.wizard-close {
display: none;
}
.wizard-no-modal .popover.error-popover,
.wizard-modal .popover.error-popover {
background-color:#F2DEDE;
color:#B94A48;
border-color:#953B39;
}
.wizard-no-modal .popover.error-popover .arrow::after,
.wizard-modal .popover.error-popover .arrow::after {
border-right-color:#F2DEDE;
}
.wizard-no-modal .popover.error-popover .popover-title,
.wizard-modal .popover.error-popover .popover-title {
display:none;
}
.wizard-no-modal .popover.error-popover .arrow,
.wizard-modal .popover.error-popover .arrow {
border-right-color:#953B39;
}
... ...
... ... @@ -31,6 +31,7 @@
<ul class="nav">
<li><a id="nav_srs_player" href="srs_player.html">SRS播放器</a></li>
<li><a id="nav_srs_publisher" href="srs_publisher.html">SRS编码器</a></li>
<li><a id="nav_srs_chat" href="srs_chat.html">SRS会议</a></li>
<li><a id="nav_srs_bwt" href="srs_bwt.html">SRS测网速</a></li>
<li><a id="nav_jwplayer6" href="jwplayer6.html">JWPlayer6播放器</a></li>
<li><a id="nav_osmf" href="osmf.html">AdobeOSMF播放器</a></li>
... ...
!function(a){a.fn.wizard=function(a){return new Wizard(this,a)},a.fn.wizard.logging=!1;var b=function(a,b,c,d,e){this.wizard=a,this.index=c,this.prev=d,this.next=e,this.el=b,this.title=b.find("h3").first().text(),this.name=b.data("cardname")||this.title,this.nav=this._createNavElement(this.title,c),this._disabled=!1,this._loaded=!1,this._events={}};b.prototype={select:function(){this.log("selecting"),this.isSelected()||(this.nav.addClass("active"),this.el.show(),this._loaded||(this.trigger("loaded"),this.reload()),this.trigger("selected"));var a=this.wizard;return a.backButton.toggleClass("disabled",0==this.index),this.index>=a._cards.length-1?(this.log("on last card, changing next button to submit"),a.changeNextButton(a.args.buttons.submitText,"btn-success"),a._readyToSubmit=!0,a.trigger("readySubmit")):(a._readyToSubmit=!1,a.changeNextButton(a.args.buttons.nextText,"btn-primary")),this},_createNavElement:function(b,c){var d=a('<li class="wizard-nav-item"></li>'),e=a('<a class="wizard-nav-link"></a>');return e.data("navindex",c),d.append(e),e.append('<i class="icon-chevron-right"></i>'),e.append(b),d},markVisited:function(){return this.log("marking as visited"),this.nav.addClass("already-visited"),this.trigger("markVisited"),this},unmarkVisited:function(){return this.log("unmarking as visited"),this.nav.removeClass("already-visited"),this.trigger("unmarkVisited"),this},deselect:function(){return this.nav.removeClass("active"),this.el.hide(),this.trigger("deselect"),this},enable:function(){return this.log("enabling"),this.nav.addClass("active"),this._disabled=!1,this.trigger("enabled"),this},disable:function(a){return this.log("disabling"),this._disabled=!0,this.nav.removeClass("active already-visited"),a&&this.el.hide(),this.trigger("disabled"),this},isDisabled:function(){return this._disabled},alreadyVisited:function(){return this.nav.hasClass("already-visited")},isSelected:function(){return this.nav.hasClass("active")},reload:function(){return this._loaded=!0,this.trigger("reload"),this},on:function(){return this.wizard.on.apply(this,arguments)},trigger:function(){return this.callListener("on"+arguments[0]),this.wizard.trigger.apply(this,arguments)},toggleAlert:function(b,c){this.log("toggling alert to: "+c),c="undefined"==typeof c?!0:c,c?this.trigger("showAlert"):this.trigger("hideAlert");var d,e=this.el.children("h3").first().next("div.alert");if(0==e.length){if(!c)return this;this.log("couldn't find existing alert div, creating one"),d=a("<div />"),d.addClass("alert"),d.addClass("hide"),d.insertAfter(this.el.find("h3").first())}else this.log("found existing alert div"),d=e.first();return c?(null!=b&&(this.log("setting alert msg to",b),d.html(b)),d.show()):d.hide(),this},callListener:function(a){a=a.toLowerCase(),this.log("looking for listener "+a);var b=window[this.el.data(a)];if(b){this.log("calling listener "+a),this.wizard;try{b(this)}catch(e){this.log("exception calling listener "+a+": ",e)}}else this.log("didn't find listener "+a)},problem:function(a){this.nav.find("a").toggleClass("wizard-step-error",a)},validate:function(){var b=!1,c=this;this.el.find("[data-validate]").each(function(d,e){c.log("validating individiual inputs"),e=a(e);var f=e.data("validate");if(f){var g={status:!0,title:"Error",msg:""},h=window[f](e);if(a.extend(g,h),g.status){e.parent(".control-group").toggleClass("error",!1);try{e.popover("destroy")}catch(i){e.popover("hide")}}else b=!0,e.parent(".control-group").toggleClass("error",!0),c.wizard.errorPopover(e,g.msg)}}),this.log("after validating inputs, failures is",b);var d=window[this.el.data("validate")];if(d){this.log("running html-embedded card validator");var e=d(this);("undefined"==typeof e||null==e)&&(e=!0),e||(b=!0),this.log("after running html-embedded card validator, failures is",b)}this.log("running listener validator");var f=this.trigger("validate");("undefined"==typeof f||null==f)&&(f=!0),f||(b=!0),this.log("after running listener validator, failures is",b);var g=!b;return g?(this.log("validated, calling listeners"),this.trigger("validated")):(this.log("invalid"),this.trigger("invalid")),g},log:function(){if(window.console&&a.fn.wizard.logging){var b="card '"+this.name+"': ",c=[b];c.push.apply(c,arguments),console.log.apply(console,c)}},isActive:function(){return this.nav.hasClass("active")}},Wizard=function(b,c){var d=['<div class="modal hide wizard-modal" role="dialog">','<div class="wizard-modal-header modal-header">','<button class="wizard-close close" type="button">x</button>','<h3 class="wizard-title"></h3>','<span class="wizard-subtitle"></span>',"</div>",'<div class="pull-left wizard-steps">','<div class="wizard-nav-container">','<ul class="nav nav-list" style="padding-bottom:30px;">',"</ul>","</div>",'<div class="wizard-progress-container">',,'<div class="progress progress-striped">','<div class="bar"></div>',"</div>","</div>","</div>","<form>",'<div class="wizard-cards">','<div class="wizard-card-container">',"</div>",'<div class="wizard-modal-footer">','<div class="wizard-buttons-container">','<button class="btn wizard-cancel wizard-close" type="button">Cancel</button>','<div class="btn-group-single pull-right">','<button class="btn wizard-back" type="button">Back</button>','<button class="btn btn-primary wizard-next" type="button">Next</button>',"</div>","</div>","</div>","</div>","</form>","</div>"],e=['<div class="wizard-no-modal" role="dialog">','<div class="wizard-modal-header modal-header">','<button class="wizard-close close" type="button">x</button>','<h3 class="wizard-title"></h3>','<span class="wizard-subtitle"></span>',"</div>",'<div class="pull-left wizard-steps">','<div class="wizard-nav-container">','<ul class="nav nav-list" style="padding-bottom:30px;">',"</ul>","</div>",'<div class="wizard-progress-container">',,'<div class="progress progress-striped">','<div class="bar"></div>',"</div>","</div>","</div>","<form>",'<div class="wizard-cards">','<div class="wizard-card-container">',"</div>",'<div class="wizard-modal-footer">','<div class="wizard-buttons-container">','<button class="btn wizard-cancel wizard-close" type="button">Cancel</button>','<div class="btn-group-single pull-right">','<button class="btn wizard-back" type="button">Back</button>','<button class="btn btn-primary wizard-next" type="button">Next</button>',"</div>","</div>","</div>","</div>","</form>","</div>"];this.args={submitUrl:"",width:750,showCancel:!1,showClose:!0,progressBarCurrent:!1,increaseHeight:0,buttons:{cancelText:"Cancel",nextText:"Next",backText:"Back",submitText:"Submit",submittingText:"Submitting..."},isModal:!0},a.extend(this.args,c||{});var f=this.args.isModal?d:e;this.args.isModal||(this.args.showCancel=!1,this.args.showClose=!1),this.markup=a(b),this.submitCards=this.markup.find(".wizard-error,.wizard-failure,.wizard-success,.wizard-loading"),this.el=a(f.join("\n")),this.el.find(".wizard-card-container").append(this.markup.find(".wizard-card")).append(this.submitCards),a("body").append(this.el),this.closeButton=this.el.find("button.wizard-close"),this.footer=this.el.find(".wizard-modal-footer"),this.cancelButton=this.footer.find(".wizard-cancel"),this.backButton=this.footer.find(".wizard-back"),this.nextButton=this.footer.find(".wizard-next"),this.progress=this.el.find(".progress"),this._cards=[],this.cards={},this._readyToSubmit=!1,this.percentComplete=0,this._submitting=!1,this._events={},this._firstShow=!0,this._createCards(),this.nextButton.click(this,this._handleNextClick),this.backButton.click(this,this._handleBackClick),this.cancelButton.text(this.args.buttons.cancelText),this.backButton.text(this.args.buttons.backText),this.nextButton.text(this.args.buttons.nextText);var g=360,h=g+this.args.increaseHeight;this.el.find(".wizard-nav-container").css("height",h),this.el.find(".wizard-steps").css("height",h+65+"px"),this.el.find(".wizard-card").css("height",h-60+"px"),this.submitCards.css("height",h-60+"px"),this.args.isModal&&this.el.css("margin-top",-(this.el.height()/2)),this.el.css("width",this.args.width),this.args.isModal&&this.el.css("margin-left",-(this.args.width/2));var j=this;this.closeButton.click(function(){j.reset(),j.close(),j.trigger("closed")}),this.el.find(".wizard-steps").on("click","li.already-visited a.wizard-nav-link",this,function(b){var c=parseInt(a(b.target).data("navindex"));b.data.setCard(c)});var k=this.markup.children("h1").first();k.length&&this.setTitle(k.text()),this.on("submit",this._defaultSubmit)},Wizard.prototype={errorPopover:function(a,b){this.log("launching popover on",a);var c=a.popover({content:b,trigger:"manual"}).popover("show").next(".popover");return c.addClass("error-popover"),c},destroyPopover:function(b){b=a(b),b.parent(".control-group").toggleClass("error",!1);var c=b.prev();try{c.popover("destroy")}catch(d){c.popover("hide")}},hidePopovers:function(){this.log("hiding all popovers");var b=this;this.el.find(".error-popover").each(function(a,c){b.destroyPopover(c)})},eachCard:function(b){return a.each(this._cards,b),this},getActiveCard:function(){this.log("getting active card");var b=null;return a.each(this._cards,function(a,c){return c.isActive()?(b=c,!1):void 0}),b?this.log("found active card",b):this.log("couldn't find an active card"),b},setTitle:function(a){return this.log("setting title to",a),this.el.find(".wizard-title").first().text(a),this},setSubtitle:function(a){return this.log("setting subtitle to",a),this.el.find(".wizard-subtitle").first().text(a),this},changeNextButton:function(a,b){return this.log("changing next button, text: "+a,"class: "+b),"undefined"!=typeof b&&this.nextButton.removeClass("btn-success btn-primary"),b&&this.nextButton.addClass(b),this.nextButton.text(a),this},hide:function(){return this.log("hiding"),this.args.isModal?this.el.modal("hide"):this.el.css("display","none"),this},close:function(){return this.log("closing"),this.args.isModal?this.el.modal("hide"):this.el.css("display","none"),this},show:function(a){return this.log("showing"),this._firstShow&&(this.setCard(0),this._firstShow=!1),this.args.showCancel&&this.cancelButton.show(),this.args.showClose&&this.closeButton.show(),this.args.isModal?this.el.modal(a):this.el.css("display","block"),this},on:function(a,b){return this.log("adding listener to event "+a),this._events[a]=b,this},trigger:function(){var a=arguments[0],b=Array.prototype.slice.call(arguments);b.shift(),b.unshift(this),this.log("firing event "+a);var c=this._events[a],d=null;if("function"==typeof c){this.log("found event handler, calling "+a);try{d=c.apply(this,b)}catch(e){this.log("event handler "+a+" had an exception")}}else this.log("couldn't find an event handler for "+a);return d},reset:function(){return this.log("resetting"),this.updateProgressBar(0),this.hideSubmitCards(),this.setCard(0),this.lockCards(),this.enableNextButton(),this.showButtons(),this.hidePopovers(),this.trigger("reset"),this},log:function(){if(window.console&&a.fn.wizard.logging){var b="wizard "+this.el.id+": ",c=[b];c.push.apply(c,arguments),console.log.apply(console,c)}},_abstractIncrementStep:function(a,b){var d,c=this.getActiveCard();if(c)for(this.log("searching for valid next card");;){if(d=b(c)){if(this.log("looking at card",d.index),d.isDisabled()){this.log("card "+d.index+" is disabled/locked, continuing"),c=d;continue}return this.setCard(c.index+a)}this.log("next card is not defined, breaking");break}else this.log("current card is undefined")},incrementCard:function(){this.log("incrementing card");var a=this._abstractIncrementStep(1,function(a){return a.next});return this.trigger("incrementCard"),a},decrementCard:function(){this.log("decrementing card");var a=this._abstractIncrementStep(-1,function(a){return a.prev});return this.trigger("decrementCard"),a},setCard:function(a){this.log("setting card to "+a),this.hideSubmitCards();var b=this.getActiveCard();if(this._submitting)return this.log("we're submitting the wizard already, can't change cards"),b;var c=this._cards[a];if(c){if(c.isDisabled())return this.log("new card is currently disabled, returning"),b;if(b){if(a>b.index){for(var d=b,e=!1;d.index!=c.index;){if(d.index!=b.index&&(d.prev.deselect(),d.prev.markVisited(),d.select()),e=d.validate(),!e)return d;d=d.next}d.prev.deselect(),d.prev.markVisited()}b.deselect(),b.markVisited()}if(c.select(),this.args.progressBarCurrent)this.percentComplete=100*a/this._cards.length,this.updateProgressBar(this.percentComplete);else{var f=this.percentComplete;this.percentComplete=100*a/this._cards.length,this.percentComplete=Math.max(f,this.percentComplete),this.updateProgressBar(this.percentComplete)}return c}this.log("couldn't find card "+a)},updateProgressBar:function(a){this.log("updating progress to "+a+"%"),this.progress.find(".bar").css({width:a+"%"}),this.percentComplete=a,this.trigger("progressBar",a),100==a?(this.log("progress is 100, animating progress bar"),this.progress.addClass("active")):0==a&&(this.log("progress is 0, disabling animation"),this.progress.removeClass("active"))},getNextCard:function(){var a=this.getActiveCard();return a?a.next:void 0},lockCards:function(){return this.log("locking nav cards"),this.eachCard(function(a,b){b.unmarkVisited()}),this},disableCards:function(){return this.log("disabling all nav cards"),this.eachCard(function(a,b){b.disable()}),this},enableCards:function(){return this.log("enabling all nav cards"),this.eachCard(function(a,b){b.enable()}),this},hideCards:function(){return this.log("hiding cards"),this.eachCard(function(a,b){b.deselect()}),this.hideSubmitCards(),this},hideButtons:function(){return this.log("hiding buttons"),this.cancelButton.hide(),this.closeButton.hide(),this.nextButton.hide(),this.backButton.hide(),this},showButtons:function(){return this.log("showing buttons"),this.args.showCancel&&this.cancelButton.show(),this.args.showClose&&this.closeButton.show(),this.nextButton.show(),this.backButton.show(),this},getCard:function(b){var c=a(b).parents(".wizard-card").first()[0];if(c){var d=null;return this.eachCard(function(a,b){return c==b.el[0]?(d=b,!1):!0}),d}return null},_createCards:function(){var c=null,d=null,e=null,f=this,g=this,h=this.el.find(".wizard-cards .wizard-card");a.each(h,function(h,i){i=a(i),c=e,e=new b(f,i,h,c,d),g._cards.push(e),e.name&&(g.cards[e.name]=e),c&&(c.next=e),g.el.find(".wizard-steps .nav-list").append(e.nav)})},showSubmitCard:function(a){this.log("showing "+a+" submit card");var b=this.el.find(".wizard-"+a);b.length?(this.hideCards(),this.el.find(".wizard-"+a).show()):this.log("couldn't find submit card "+a)},hideSubmitCard:function(a){this.log("hiding "+a+" submit card"),this.el.find(".wizard-"+a).hide()},hideSubmitCards:function(){var b=this;a.each(["success","error","failure","loading"],function(a,c){b.hideSubmitCard(c)})},enableNextButton:function(){return this.log("enabling next button"),this.nextButton.removeAttr("disabled"),this},disableNextButton:function(){return this.log("disabling next button"),this.nextButton.attr("disabled","disabled"),this},serializeArray:function(){var a=this.el.children("form").first();return a.serializeArray()},serialize:function(){var a=this.el.children("form").first();return a.serialize()},submitSuccess:function(){this.log("submit success"),this._submitting=!1,this.showSubmitCard("success"),this.trigger("submitSuccess")},submitFailure:function(){this.log("submit failure"),this._submitting=!1,this.showSubmitCard("failure"),this.trigger("submitFailure")},submitError:function(){this.log("submit error"),this._submitting=!1,this.showSubmitCard("error"),this.trigger("submitError")},_submit:function(){this.log("submitting wizard"),this._submitting=!0,this.lockCards(),this.cancelButton.hide(),this.closeButton.hide(),this.backButton.hide(),this.showSubmitCard("loading"),this.updateProgressBar(100),this.changeNextButton(this.args.buttons.submittingText,!1),this.disableNextButton(),this.trigger("submit"),this.trigger("loading")},_onNextClick:function(){this.log("handling 'next' button click");var a=this.getActiveCard();this._readyToSubmit&&a.validate()?this._submit():a=this.incrementCard()},_onBackClick:function(){this.log("handling 'back' button click"),this.decrementCard()},_handleNextClick:function(a){var b=a.data;b._onNextClick.call(b)},_handleBackClick:function(a){var b=a.data;b._onBackClick.call(b)},_defaultSubmit:function(b){a.ajax({type:"POST",url:b.args.submitUrl,data:b.serialize(),dataType:"json",success:function(){b.submitSuccess(),b.hideButtons(),b.updateProgressBar(0)},error:function(){b.submitFailure(),b.hideButtons()}})}}}(window.jQuery);
\ No newline at end of file
... ...
... ... @@ -20,6 +20,7 @@ function padding(number, length, prefix) {
function update_nav() {
$("#nav_srs_player").attr("href", "srs_player.html" + window.location.search);
$("#nav_srs_publisher").attr("href", "srs_publisher.html" + window.location.search);
$("#nav_srs_chat").attr("href", "srs_chat.html" + window.location.search);
$("#nav_srs_bwt").attr("href", "srs_bwt.html" + window.location.search);
$("#nav_jwplayer6").attr("href", "jwplayer6.html" + window.location.search);
$("#nav_osmf").attr("href", "osmf.html" + window.location.search);
... ...
... ... @@ -83,6 +83,7 @@
<ul class="nav">
<li><a id="nav_srs_player" href="srs_player.html">SRS播放器</a></li>
<li><a id="nav_srs_publisher" href="srs_publisher.html">SRS编码器</a></li>
<li><a id="nav_srs_chat" href="srs_chat.html">SRS会议</a></li>
<li><a id="nav_srs_bwt" href="srs_bwt.html">SRS测网速</a></li>
<li class="active"><a id="nav_jwplayer6" href="jwplayer6.html">JWPlayer6播放器</a></li>
<li><a id="nav_osmf" href="osmf.html">AdobeOSMF播放器</a></li>
... ...
... ... @@ -79,6 +79,7 @@
<ul class="nav">
<li><a id="nav_srs_player" href="srs_player.html">SRS播放器</a></li>
<li><a id="nav_srs_publisher" href="srs_publisher.html">SRS编码器</a></li>
<li><a id="nav_srs_chat" href="srs_chat.html">SRS会议</a></li>
<li><a id="nav_srs_bwt" href="srs_bwt.html">SRS测网速</a></li>
<li><a id="nav_jwplayer6" href="jwplayer6.html">JWPlayer6播放器</a></li>
<li class="active"><a id="nav_osmf" href="osmf.html">AdobeOSMF播放器</a></li>
... ...
... ... @@ -28,6 +28,7 @@
<ul class="nav">
<li><a id="nav_srs_player" href="srs_player.html">SRS播放器</a></li>
<li><a id="nav_srs_publisher" href="srs_publisher.html">SRS编码器</a></li>
<li><a id="nav_srs_chat" href="srs_chat.html">SRS会议</a></li>
<li class="active"><a id="nav_srs_bwt" href="srs_bwt.html">SRS测网速</a></li>
<li><a id="nav_jwplayer6" href="jwplayer6.html">JWPlayer6播放器</a></li>
<li><a id="nav_osmf" href="osmf.html">AdobeOSMF播放器</a></li>
... ...
<!DOCTYPE html>
<html>
<head>
<title>SRS</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"/>
<link rel="stylesheet" type="text/css" href="css/bootstrap-wizard.css"/>
<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/bootstrap-wizard.min.js"></script>
<script type="text/javascript" src="js/swfobject.js"></script>
<script type="text/javascript" src="js/srs.js"></script>
<style>
body{
padding-top: 55px;
}
</style>
<script type="text/javascript">
var srs_publisher = null;
var remote_player = null;
var realtime_player = null;
var wizard = null;
$(function(){
// get the vhost and port to set the default url.
// for example: http://192.168.1.213/players/jwplayer6.html?port=1935&vhost=demo
// url set to: rtmp://demo:1935/live/livestream
srs_init("#txt_url", null, null);
$("#btn_video_settings").click(function(){
$("#video_modal").modal({show:true});
});
$("#btn_audio_settings").click(function(){
$("#audio_modal").modal({show:true});
});
$("#remote_tips").tooltip({
title: "为了支持HLS输出,FLASH编码器输出的流需要经过转码(VP6=>H264,MP3=>aac),所以会黑屏较长时间,请耐心等待"
});
$("#low_latecy_tips").tooltip({
title: "服务器不转码直接转发FLASH编码器的流,所以延迟比支持HLS的流要低很多"
});
$("#btn_publish").click(on_user_publish);
// for publish, we use randome stream name.
$("#txt_url").val($("#txt_url").val() + "." + new Date().getTime());
// start the publisher.
srs_publisher = new SrsPublisher("local_publisher", 430, 185);
srs_publisher.on_publisher_ready = function(cameras, microphones) {
$("#sl_cameras").empty();
for (var i = 0; i < cameras.length; i++) {
$("#sl_cameras").append("<option value='" + i + "'>" + cameras[i] + "</option");
}
// optional: select the first no "virtual" signed.
for (var i = 0; i < cameras.length; i++) {
if (cameras[i].toLowerCase().indexOf("virtual") == -1) {
$("#sl_cameras option[value='" + i + "']").attr("selected", true);
break;
}
}
$("#sl_microphones").empty();
for (var i = 0; i < microphones.length; i++) {
$("#sl_microphones").append("<option value='" + i + "'>" + microphones[i] + "</option");
}
$("#sl_vcodec").empty();
var vcodecs = ["h264", "vp6"];
for (var i = 0; i < vcodecs.length; i++) {
$("#sl_vcodec").append("<option value='" + vcodecs[i] + "'>" + vcodecs[i] + "</option");
}
$("#sl_profile").empty();
var profiles = ["baseline", "main"];
for (var i = 0; i < profiles.length; i++) {
$("#sl_profile").append("<option value='" + profiles[i] + "'>" + profiles[i] + "</option");
}
$("#sl_level").empty();
var levels = ["1", "1b", "1.1", "1.2", "1.3",
"2", "2.1", "2.2", "3", "3.1", "3.2", "4", "4.1", "4.2", "5", "5.1"];
for (var i = 0; i < levels.length; i++) {
$("#sl_level").append("<option value='" + levels[i] + "'>" + levels[i] + "</option");
}
$("#sl_level option[value='4.1']").attr("selected", true);
$("#sl_gop").empty();
var gops = ["0.3", "0.5", "1", "2", "3", "4",
"5", "6", "7", "8", "9", "10", "15", "20"];
for (var i = 0; i < gops.length; i++) {
$("#sl_gop").append("<option value='" + gops[i] + "'>" + gops[i] + "秒</option");
}
$("#sl_gop option[value='5']").attr("selected", true);
$("#sl_size").empty();
var sizes = ["176x144", "320x240", "352x240",
"352x288", "460x240", "640x480", "720x480", "720x576", "800x600",
"1024x768", "1280x720", "1360x768", "1920x1080"];
for (i = 0; i < sizes.length; i++) {
$("#sl_size").append("<option value='" + sizes[i] + "'>" + sizes[i] + "</option");
}
$("#sl_size option[value='460x240']").attr("selected", true);
$("#sl_fps").empty();
var fpses = ["5", "10", "15", "20", "24", "25", "29.97", "30"];
for (i = 0; i < fpses.length; i++) {
$("#sl_fps").append("<option value='" + fpses[i] + "'>" + Number(fpses[i]).toFixed(2) + " 帧/秒</option");
}
$("#sl_fps option[value='15']").attr("selected", true);
$("#sl_bitrate").empty();
var bitrates = ["50", "200", "350", "500", "650", "800",
"950", "1000", "1200", "1500", "1800", "2000", "3000", "5000"];
for (i = 0; i < bitrates.length; i++) {
$("#sl_bitrate").append("<option value='" + bitrates[i] + "'>" + bitrates[i] + " kbps</option");
}
$("#sl_bitrate option[value='350']").attr("selected", true);
};
srs_publisher.on_publisher_error = function(code, desc) {
error(code, desc);
};
srs_publisher.on_publisher_warn = function(code, desc) {
warn(code, desc);
};
srs_publisher.start();
//wizard = $("#main_wizard").wizard({});
//wizard.show();
// if no play specified, donot show the player, for debug the publisher.
var query = parse_query_string();
if (query.no_play != "true") {
// start the normal player with HLS supported.
remote_player = new SrsPlayer("remote_player", 430, 185);
remote_player.on_player_ready = function() {
remote_player.set_bt(0.8);
remote_player.set_fs("screen", 100);
};
remote_player.start();
// start the realtime player.
realtime_player = new SrsPlayer("realtime_player", 430, 185);
realtime_player.on_player_ready = function() {
realtime_player.set_bt(0.8);
realtime_player.set_fs("screen", 100);
};
realtime_player.start();
}
});
/**
* we generate the transcoded stream url for flash publish donot support HLS
* which requires aac, so the publish vhost maybe players for example, we
* use players_pub vhost(transcoded stream to which) for all clients,
* both players and players_pub are write HLS to the sample dir,
* it's ok for the players vhost disabled the HLS, only the
* players_pub enalbed HLS.
*/
function update_play_url() {
var url = $("#txt_url").val();
var ret = srs_parse_rtmp_url(url);
var query = parse_query_string();
var srs_player_url = "http://" + query.host + query.dir + "/srs_player.html?";
srs_player_url += "vhost=" + srs_get_player_publish_vhost(ret.vhost) + "&port=" + ret.port + "&app=" + ret.app + "&stream=" + ret.stream;
srs_player_url += "&autostart=true";
var srs_player_rt_url = "http://" + query.host + query.dir + "/srs_player.html?";
srs_player_rt_url += "vhost=" + ret.vhost + "&port=" + ret.port + "&app=" + ret.app + "&stream=" + ret.stream;
srs_player_rt_url += "&autostart=true";
var jwplayer_url = "http://" + query.host + query.dir + "/jwplayer6.html?";
jwplayer_url += "vhost=" + srs_get_player_publish_vhost(ret.vhost) + "&port=" + ret.port + "&app=" + ret.app + "&stream=" + ret.stream;
jwplayer_url += "&hls_autostart=true";
var hls_url = "http://" + ret.server + ":" + query.http_port + "/" + ret.app + "/" + ret.stream + ".m3u8";
$("#txt_play_realtime").text("RTMP低延时(点击打开)").attr("href", srs_player_rt_url).attr("target", "_blank");
$("#txt_play_url").text("RTMP已转码(点击打开)").attr("href", srs_player_url).attr("target", "_blank");
$("#txt_play_hls").text("HLS-m3u8(点击打开或右键复制)").attr("href", hls_url).attr("target", "_blank");
$("#txt_play_jwplayer").text("HLS-JWPlayer(点击打开)").attr("href", jwplayer_url).attr("target", "_blank");
}
function on_user_publish() {
if ($("#btn_publish").text() == "停止发布") {
srs_publisher.stop();
$("#btn_publish").text("发布视频");
$("#txt_play_realtime").text("RTMP低延时(请发布视频)").attr("href", "#").attr("target", "_self");
$("#txt_play_url").text("RTMP已转码(请发布视频)").attr("href", "#").attr("target", "_self");
$("#txt_play_hls").text("HLS-m3u8(请发布视频)").attr("href", "#").attr("target", "_self");
$("#txt_play_jwplayer").text("HLS-JWPlayer(请发布视频)").attr("href", "#").attr("target", "_self");
return;
}
$("#btn_publish").text("停止发布");
update_play_url();
var url = $("#txt_url").val();
var vcodec = {};
var acodec = {};
acodec.device_code = $("#sl_microphones").val();
acodec.device_name = $("#sl_microphones").text();
vcodec.device_code = $("#sl_cameras").find("option:selected").val();
vcodec.device_name = $("#sl_cameras").find("option:selected").text();
vcodec.codec = $("#sl_vcodec").find("option:selected").val();
vcodec.profile = $("#sl_profile").find("option:selected").val();
vcodec.level = $("#sl_level").find("option:selected").val();
vcodec.fps = $("#sl_fps").find("option:selected").val();
vcodec.gop = $("#sl_gop").find("option:selected").val();
vcodec.size = $("#sl_size").find("option:selected").val();
vcodec.bitrate = $("#sl_bitrate").find("option:selected").val();
info("开始推流到服务器");
srs_publisher.publish(url, vcodec, acodec);
if (realtime_player) {
// directly play the url for the realtime player.
realtime_player.stop();
realtime_player.play(url);
}
if (remote_player) {
// the normal player should play the transcoded stream in another vhost.
// for example, publish stream to vhost players,
// the realtime player play the vhost players, which may donot support HLS,
// the normal player play the vhost players_pub, which transcoded to h264/aac with HLS.
var ret = srs_parse_rtmp_url(url);
var pub_url = "rtmp://" + ret.server + ":" + ret.port + "/" + ret.app;
pub_url += "?vhost=" + srs_get_player_publish_vhost(ret.vhost) + "/" + ret.stream;
remote_player.stop();
remote_player.play(pub_url);
}
}
function info(desc) {
$("#txt_log").addClass("alert-info").removeClass("alert-error").removeClass("alert-warn");
$("#txt_log_title").text("Info:");
$("#txt_log_msg").text(desc);
}
function warn(code, desc) {
$("#txt_log").removeClass("alert-info").removeClass("alert-error").addClass("alert-warn");
$("#txt_log_title").text("Warn:");
$("#txt_log_msg").text("code: " + code + ", " + desc);
}
function error(code, desc) {
$("#txt_log").removeClass("alert-info").addClass("alert-error").removeClass("alert-warn");
$("#txt_log_title").text("Error:");
$("#txt_log_msg").text("code: " + code + ", " + desc);
}
</script>
</head>
<body>
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="brand" href="index.html">SRS</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li><a id="nav_srs_player" href="srs_player.html">SRS播放器</a></li>
<li><a id="nav_srs_publisher" href="srs_publisher.html">SRS编码器</a></li>
<li class="active"><a id="nav_srs_chat" href="srs_chat.html">SRS会议</a></li>
<li><a id="nav_srs_bwt" href="srs_bwt.html">SRS测网速</a></li>
<li><a id="nav_jwplayer6" href="jwplayer6.html">JWPlayer6播放器</a></li>
<li><a id="nav_osmf" href="osmf.html">AdobeOSMF播放器</a></li>
<li><a id="nav_vlc" href="vlc.html">VLC播放器</a></li>
</ul>
</div>
</div>
</div>
</div>
<div class="container">
<div class="alert alert-info fade in" id="txt_log">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong><span id="txt_log_title">Usage:</span></strong>
<span id="txt_log_msg">设置编码参数,点“发布视频”,允许Flash访问摄像头即可推流</span>
</div>
<!-- http://www.panopta.com/2013/02/06/bootstrap-application-wizard/ -->
<!-- https://github.com/amoffat/bootstrap-application-wizard -->
<div class="wizard" id="main_wizard" data-title="Wizard Title">
<div class="wizard-card" data-cardname="card1">
<h3>Card 1</h3>
Some content
</div>
<div class="wizard-card" data-cardname="card2">
<h3>Card 2</h3>
Some content
</div>
</div>
<div class="control-group">
<div class="form-inline">
<button class="btn" id="btn_video_settings">视频编码配置</button>
<button class="btn" id="btn_audio_settings">音频编码配置</button>
</div>
</div>
<div class="control-group">
<div class="form-inline">
发布地址:
<input type="text" id="txt_url" class="input-xxlarge" value=""></input>
<button class="btn btn-primary" id="btn_publish">发布视频</button>
</div>
</div>
<div class="control-group">
<div class="form-inline">
播放地址
1.<a id="txt_play_realtime" class="input-xxlarge" href="#">RTMP低延时(请发布视频)</a>
2.<a id="txt_play_url" class="input-xxlarge" href="#">RTMP已转码(请发布视频)</a>
3.<a id="txt_play_hls" class="input-xxlarge" href="#">HLS-m3u8(请发布视频)</a>
4.<a id="txt_play_jwplayer" class="input-xxlarge" href="#">HLS-JWPlayer(请发布视频)</a>
</div>
</div>
<div id="video_modal" class="modal hide fade">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3>视频编码</h3>
</div>
<div class="modal-body">
<div class="form-horizontal">
<div class="control-group">
<label class="control-label" for="sl_cameras">
摄像头
<a id="sl_cameras_tips" href="#" data-toggle="tooltip" data-placement="right" title="">
<img src="img/tooltip.png"/>
</a>
</label>
<div class="controls">
<select class="span4" id="sl_cameras"></select>
</div>
</div>
<div class="control-group">
<label class="control-label" for="sl_vcodec">
Codec
<a id="sl_cameras_tips" href="#" data-toggle="tooltip" data-placement="right" title="">
<img src="img/tooltip.png"/>
</a>
</label>
<div class="controls">
<select class="span2" id="sl_vcodec"></select>
</div>
</div>
<div class="control-group">
<label class="control-label" for="sl_profile">
Profile
<a id="sl_profile_tips" href="#" data-toggle="tooltip" data-placement="right" title="">
<img src="img/tooltip.png"/>
</a>
</label>
<div class="controls">
<select class="span2" id="sl_profile"></select>
</div>
</div>
<div class="control-group">
<label class="control-label" for="sl_level">
Level
<a id="sl_level_tips" href="#" data-toggle="tooltip" data-placement="right" title="">
<img src="img/tooltip.png"/>
</a>
</label>
<div class="controls">
<select class="span2" id="sl_level"></select>
</div>
</div>
<div class="control-group">
<label class="control-label" for="sl_gop">
GOP
<a id="sl_gop_tips" href="#" data-toggle="tooltip" data-placement="right" title="">
<img src="img/tooltip.png"/>
</a>
</label>
<div class="controls">
<select class="span2" id="sl_gop"></select>
</div>
</div>
<div class="control-group">
<label class="control-label" for="sl_size">
尺寸
<a id="sl_size_tips" href="#" data-toggle="tooltip" data-placement="right" title="">
<img src="img/tooltip.png"/>
</a>
</label>
<div class="controls">
<select class="span2" id="sl_size"></select>
</div>
</div>
<div class="control-group">
<label class="control-label" for="sl_fps">
帧率
<a id="sl_fps_tips" href="#" data-toggle="tooltip" data-placement="right" title="">
<img src="img/tooltip.png"/>
</a>
</label>
<div class="controls">
<select class="span2" id="sl_fps"></select>
</div>
</div>
<div class="control-group">
<label class="control-label" for="sl_bitrate">
码率
<a id="sl_bitrate_tips" href="#" data-toggle="tooltip" data-placement="right" title="">
<img src="img/tooltip.png"/>
</a>
</label>
<div class="controls">
<select class="span2" id="sl_bitrate"></select>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-primary" data-dismiss="modal" aria-hidden="true">设置</button>
</div>
</div>
<div id="audio_modal" class="modal hide fade">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3>音频编码</h3>
</div>
<div class="modal-body">
<div class="form-horizontal">
<div class="control-group">
<label class="control-label" for="sl_microphones">
麦克风
<a id="worker_id_tips" href="#" data-toggle="tooltip" data-placement="right" title="">
<img src="img/tooltip.png"/>
</a>
</label>
<div class="controls">
<select class="span4" id="sl_microphones"></select>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-primary" data-dismiss="modal" aria-hidden="true">设置</button>
</div>
</div>
<div class="container">
<div class="row-fluid">
<div class="span6">
<div class="accordion-group">
<div class="accordion-heading">
<span class="accordion-toggle" data-toggle="collapse" href="#collapse1">
<strong>本地摄像头</strong>
</span>
</div>
<div id="collapse1" class="accordion-body collapse in">
<div class="accordion-inner">
<div id="local_publisher"></div>
</div>
</div>
</div>
</div>
<div class="span6">
<div class="accordion-group">
<div class="accordion-heading">
<span class="accordion-toggle" data-toggle="collapse" href="#collapse2">
<strong>远程服务器</strong>
<a id="remote_tips" href="#" data-toggle="tooltip" data-placement="top" title="">
黑屏<img src="img/tooltip.png"/>
</a>
</span>
</div>
<div id="collapse2" class="accordion-body collapse in">
<div class="accordion-inner">
<div id="remote_player"></div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="container">
<div class="row-fluid">
<div class="span6">
<div class="accordion-group">
<div class="accordion-heading">
<span class="accordion-toggle" data-toggle="collapse" href="#collapse3">
<strong>远程服务器</strong>
<a id="low_latecy_tips" href="#" data-toggle="tooltip" data-placement="top" title="">
低延时<img src="img/tooltip.png"/>
</a>
</span>
</div>
<div id="collapse3" class="accordion-body collapse in">
<div class="accordion-inner">
<div id="realtime_player"></div>
</div>
</div>
</div>
</div>
<div class="span6">
</div>
</div>
</div>
<footer>
<p><a href="https://github.com/winlinvip/simple-rtmp-server">SRS Team &copy; 2013</a></p>
</footer>
</div>
</body>
... ...
... ... @@ -269,6 +269,7 @@
<ul class="nav">
<li class="active"><a id="nav_srs_player" href="srs_player.html">SRS播放器</a></li>
<li><a id="nav_srs_publisher" href="srs_publisher.html">SRS编码器</a></li>
<li><a id="nav_srs_chat" href="srs_chat.html">SRS会议</a></li>
<li><a id="nav_srs_bwt" href="srs_bwt.html">SRS测网速</a></li>
<li><a id="nav_jwplayer6" href="jwplayer6.html">JWPlayer6播放器</a></li>
<li><a id="nav_osmf" href="osmf.html">AdobeOSMF播放器</a></li>
... ...
... ... @@ -257,6 +257,7 @@
<ul class="nav">
<li><a id="nav_srs_player" href="srs_player.html">SRS播放器</a></li>
<li class="active"><a id="nav_srs_publisher" href="srs_publisher.html">SRS编码器</a></li>
<li><a id="nav_srs_chat" href="srs_chat.html">SRS会议</a></li>
<li><a id="nav_srs_bwt" href="srs_bwt.html">SRS测网速</a></li>
<li><a id="nav_jwplayer6" href="jwplayer6.html">JWPlayer6播放器</a></li>
<li><a id="nav_osmf" href="osmf.html">AdobeOSMF播放器</a></li>
... ...
... ... @@ -29,6 +29,7 @@
<ul class="nav">
<li><a id="nav_srs_player" href="srs_player.html">SRS播放器</a></li>
<li><a id="nav_srs_publisher" href="srs_publisher.html">SRS编码器</a></li>
<li><a id="nav_srs_chat" href="srs_chat.html">SRS会议</a></li>
<li><a id="nav_srs_bwt" href="srs_bwt.html">SRS测网速</a></li>
<li><a id="nav_jwplayer6" href="jwplayer6.html">JWPlayer6播放器</a></li>
<li><a id="nav_osmf" href="osmf.html">AdobeOSMF播放器</a></li>
... ... @@ -39,7 +40,7 @@
</div>
</div>
<div class="container">
<iframe id="main_frame" width="100%" height="800" frameBorder="0"></iframe>
<iframe id="main_frame" width="100%" height="600" frameBorder="0"></iframe>
</div>
<div class="container">
<hr>
... ...