胡斌

add recent modified push url to cookie

正在显示 1 个修改的文件 包含 79 行增加8 行删除
@@ -144,6 +144,42 @@ a:active { @@ -144,6 +144,42 @@ a:active {
144 var initload = true; 144 var initload = true;
145 var player; 145 var player;
146 var rtmp_port = 1935; 146 var rtmp_port = 1935;
  147 + var push_urls;
  148 + var push_url_array =[
  149 + "0 video=scr audio=mic rtmp://127.0.0.1/live/0",
  150 + "1 video=doc audio=mic rtmp://127.0.0.1/live/1",
  151 + "2 video=cam audio=mic rtmp://127.0.0.1/live/2",
  152 + "3 video=mov audio=mov rtmp://127.0.0.1/live/3",
  153 + "4 video=non audio=mov rtmp://127.0.0.1/live/4",
  154 + "5 video=doc audio=non rtmp://127.0.0.1/live/5",
  155 + "6 video=doc audio=mov rtmp://127.0.0.1/live/6",
  156 + ];
  157 +
  158 + function getCookieVal(offset) {
  159 + var endstr = document.cookie.indexOf(";",offset);
  160 + if(endstr == -1)
  161 + endstr = document.cookie.length;
  162 + return unescape(unescape(document.cookie.substring(offset,endstr)));
  163 + }
  164 +
  165 + function getCookie(name) {
  166 + var arg = name + "=";
  167 + var alen = arg.length;
  168 + var clen = document.cookie.length;
  169 + var i = 0;
  170 + while(i < clen) {
  171 + var j = i + alen;
  172 + if(document.cookie.substring(i,j) == arg)
  173 + return getCookieVal(j);
  174 + i = document.cookie.indexOf(" ",i) + 1;
  175 + if(i == 0) break;
  176 + }
  177 + return null;
  178 + }
  179 +
  180 + function setCookie(name,value){
  181 + document.cookie = name + "=" + value + "; "
  182 + }
147 183
148 function onOpen(evt) 184 function onOpen(evt)
149 { 185 {
@@ -660,6 +696,7 @@ a:active { @@ -660,6 +696,7 @@ a:active {
660 else if(cmdName == "start_push"){ 696 else if(cmdName == "start_push"){
661 cmd.type = 50; 697 cmd.type = 50;
662 var param = document.getElementById("start_push_input"); 698 var param = document.getElementById("start_push_input");
  699 + addPushList(param.value);
663 cmd.data = utf16to8(param.value); 700 cmd.data = utf16to8(param.value);
664 cmd.data_len = cmd.data.length; 701 cmd.data_len = cmd.data.length;
665 checkAndPlayStream(param.value); 702 checkAndPlayStream(param.value);
@@ -719,6 +756,40 @@ function getExplorerTitle() { @@ -719,6 +756,40 @@ function getExplorerTitle() {
719 } 756 }
720 return ""; 757 return "";
721 } 758 }
  759 +
  760 +function fillPushList(){
  761 + var push_option = document.getElementById('start_push_sample_list');
  762 + if(push_option != null){
  763 + push_option.innerHTML="";
  764 + var content = "";
  765 + for(var i = 0; i < push_url_array.length; i++){
  766 + content += "<option value='";
  767 + content += push_url_array[i];
  768 + content += "'>";
  769 + }
  770 + push_option.innerHTML = content;
  771 + }
  772 +}
  773 +
  774 +function addPushList(url){
  775 + for(var i = 0; i < push_url_array.length; i++){
  776 + if(url == push_url_array[i])
  777 + return;
  778 + }
  779 +
  780 + var urls = url;
  781 +
  782 + for(var i = 0; i < push_url_array.length; i++){
  783 + urls += ",";
  784 + urls += push_url_array[i];
  785 + }
  786 +
  787 + setCookie("push_urls", urls);
  788 +
  789 + push_url_array = urls.split(",");
  790 +
  791 + fillPushList();
  792 +}
722 793
723 window.onload = function () 794 window.onload = function ()
724 { 795 {
@@ -737,6 +808,13 @@ function getExplorerTitle() { @@ -737,6 +808,13 @@ function getExplorerTitle() {
737 var default_ss_start_pos = "0,0," + window.screen.width + "," + window.screen.height; 808 var default_ss_start_pos = "0,0," + window.screen.width + "," + window.screen.height;
738 document.getElementById('ds_start_coord').value = default_ss_start_pos; 809 document.getElementById('ds_start_coord').value = default_ss_start_pos;
739 810
  811 + push_urls = getCookie("push_urls");
  812 +
  813 + if(null != push_urls){
  814 + push_url_array = push_urls.split(",");
  815 + }
  816 +
  817 + fillPushList();
740 } 818 }
741 819
742 function onJavaScriptBridgeCreated(id){ 820 function onJavaScriptBridgeCreated(id){
@@ -982,14 +1060,7 @@ function getExplorerTitle() { @@ -982,14 +1060,7 @@ function getExplorerTitle() {
982 <td colspan="2"><button type="button" id="start_push" onclick="javascript:onTestClick(this);">start_push</button></td> 1060 <td colspan="2"><button type="button" id="start_push" onclick="javascript:onTestClick(this);">start_push</button></td>
983 <td colspan="4"> 1061 <td colspan="4">
984 <input id="start_push_input" size="50" list="start_push_sample_list" /><datalist id="start_push_sample_list"> 1062 <input id="start_push_input" size="50" list="start_push_sample_list" /><datalist id="start_push_sample_list">
985 - <option value="0 video=scr audio=mic rtmp://127.0.0.1/live/0"></option>  
986 - <option value="1 video=doc audio=mic rtmp://127.0.0.1/live/1"></option>  
987 - <option value="2 video=cam audio=mic rtmp://127.0.0.1/live/2"></option>  
988 - <option value="3 video=mov audio=mov rtmp://127.0.0.1/live/3"></option>  
989 - <option value="4 video=non audio=mov rtmp://127.0.0.1/live/4"></option>  
990 - <option value="5 video=doc audio=non rtmp://127.0.0.1/live/5"></option>  
991 - <option value="6 video=doc audio=mov rtmp://127.0.0.1/live/6"></option>  
992 - </datalist> 1063 + </datalist>
993 </td> 1064 </td>
994 <td colspan="2"><button type="button" id="stop_push" onclick="javascript:onTestClick(this);">stop_push</button></td> 1065 <td colspan="2"><button type="button" id="stop_push" onclick="javascript:onTestClick(this);">stop_push</button></td>
995 </tr> 1066 </tr>