From c548ab501941114e97506a3cd1b0e2da603e5181 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=A1=E2=80=94=E2=80=94=E9=97=AE=E9=A2=98?= Date: Thu, 17 Sep 2015 11:44:45 +0800 Subject: [PATCH 1/2] function set_srs_player_url(url, params) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在实际环境中,player.swf 等静态资源 和页面可能部署到不同的域名或路径下。 所以在此处提供设置 srs_player.swf 的url的方法。 --- trunk/research/players/js/srs.player.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/trunk/research/players/js/srs.player.js b/trunk/research/players/js/srs.player.js index 91dea7f16..3f1db850c 100755 --- a/trunk/research/players/js/srs.player.js +++ b/trunk/research/players/js/srs.player.js @@ -25,6 +25,7 @@ function SrsPlayer(container, width, height, private_object) { this.buffer_time = 0.3; // default to 0.3 this.volume = 1.0; // default to 100% this.callbackObj = null; + this.srs_player_url = "srs_player/release/srs_player.swf?_version="+srs_get_version_code(); // callback set the following values. this.meatadata = {}; // for on_player_metadata @@ -88,7 +89,7 @@ SrsPlayer.prototype.start = function(url) { var self = this; swfobject.embedSWF( - "srs_player/release/srs_player.swf?_version="+srs_get_version_code(), + this.srs_player_url, this.container, this.width, this.height, "11.1.0", "js/AdobeFlashPlayerInstall.swf", @@ -183,6 +184,25 @@ SrsPlayer.prototype.set_bt = function(buffer_time) { this.buffer_time = buffer_time; this.callbackObj.ref.__set_bt(buffer_time); } +/** + * set the srs_player.swf url + * @param url, srs_player.swf's url. + * @param params, object. + */ + SrsPlayer.prototype.set_srs_player_url = function(url, params) { + var query_array = [], + query_string = "", + p; + params = params || {}; + params._version = srs_get_version_code(); + for (p in params) { + if (params.hasOwnProperty(p)) { + query_array.push(p + "=" + encodeURIComponent(params[p])); + } + } + query_string = query_array.join("&"); + this.srs_player_url = url + "?" + query_string; +} SrsPlayer.prototype.on_player_ready = function() { } SrsPlayer.prototype.on_player_metadata = function(metadata) { From e8680527c3f8d57a8a0b6cbfbec438405cd3c52c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=A1=E2=80=94=E2=80=94=E9=97=AE=E9=A2=98?= Date: Thu, 17 Sep 2015 12:09:29 +0800 Subject: [PATCH 2/2] allow domain * MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在使用时,srs_player可能和所在页面部署在不同的域名下。 所以在此处添加跨域许可。 --- trunk/research/players/srs_player/src/srs_player.as | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/trunk/research/players/srs_player/src/srs_player.as b/trunk/research/players/srs_player/src/srs_player.as index 27513f0db..0c553055f 100755 --- a/trunk/research/players/srs_player/src/srs_player.as +++ b/trunk/research/players/srs_player/src/srs_player.as @@ -79,6 +79,8 @@ package this.stage.addEventListener(FullScreenEvent.FULL_SCREEN, this.user_on_stage_fullscreen); + Security.allowDomain("*"); + this.addChild(this.control_fs_mask); this.control_fs_mask.buttonMode = true; this.control_fs_mask.addEventListener(MouseEvent.CLICK, user_on_click_video); @@ -591,4 +593,4 @@ package ExternalInterface.call("console.log", msg); } } -} \ No newline at end of file +}