From 82aa9d120c05f420d4a73d982f02670020b0c71d Mon Sep 17 00:00:00 2001 From: winlin Date: Mon, 7 Mar 2016 16:02:37 +0800 Subject: [PATCH] for #5114, display metadata. --- trunk/research/players/js/winlin.utility.js | 91 ++++++- trunk/research/players/jwplayer6.html | 14 + trunk/research/players/srs_player.html | 22 ++ .../srs_player/.actionScriptProperties | 1 + .../players/srs_player/release/srs_player.swf | Bin 6820 -> 7035 bytes .../players/srs_player/src/srs_player.as | 251 ++++++++++-------- 6 files changed, 258 insertions(+), 121 deletions(-) diff --git a/trunk/research/players/js/winlin.utility.js b/trunk/research/players/js/winlin.utility.js index 8eb6e3d94..00920f24e 100644 --- a/trunk/research/players/js/winlin.utility.js +++ b/trunk/research/players/js/winlin.utility.js @@ -5,7 +5,7 @@ * depends: jquery1.10 * https://code.csdn.net/snippets/147103 * @see: http://blog.csdn.net/win_lin/article/details/17994347 - * v 1.0.11 + * v 1.0.14 */ /** @@ -96,19 +96,76 @@ function system_array_get(arr, elem_or_function) { /** * to iterate on array. * @param arr the array to iterate on. - * @param pfn the function to apply on it + * @param pfn the function to apply on it. return false to break loop. * for example, * arr = [10, 15, 20, 30, 20, 40] * system_array_foreach(arr, function(elem, index){ * console.log('index=' + index + ',elem=' + elem); * }); + * @return true when iterate all elems. */ function system_array_foreach(arr, pfn) { + if (!pfn) { + return false; + } + for (var i = 0; i < arr.length; i++) { - if (pfn) { - pfn(arr[i], i) + if (!pfn(arr[i], i)) { + return false; } } + + return true; +} + +/** + * whether the str starts with flag. + */ +function system_string_startswith(str, flag) { + if (typeof flag == "object" && flag.constructor == Array) { + for (var i = 0; i < flag.length; i++) { + if (system_string_startswith(str, flag[i])) { + return true; + } + } + } + + return str && flag && str.length >= flag.length && str.indexOf(flag) == 0; +} + +/** + * whether the str ends with flag. + */ +function system_string_endswith(str, flag) { + if (typeof flag == "object" && flag.constructor == Array) { + for (var i = 0; i < flag.length; i++) { + if (system_string_endswith(str, flag[i])) { + return true; + } + } + } + + return str && flag && str.length >= flag.length && str.indexOf(flag) == str.length - flag.length; +} + +/** + * trim the start and end of flag in str. + * @param flag a string to trim. + */ +function system_string_trim(str, flag) { + if (!flag || !flag.length || typeof flag != "string") { + return str; + } + + while (system_string_startswith(str, flag)) { + str = str.substr(flag.length); + } + + while (system_string_endswith(str, flag)) { + str = str.substr(0, str.length - flag.length); + } + + return str; } /** @@ -186,12 +243,19 @@ function parse_query_string(){ } } + // split again for angularjs. + if (query_string.indexOf("?") > 0) { + query_string = query_string.split("?")[1]; + } + var queries = query_string.split("&"); - $(queries).each(function(){ - var query = this.split("="); + for (var i = 0; i < queries.length; i++) { + var elem = queries[i]; + + var query = elem.split("="); obj[query[0]] = query[1]; obj.user_query[query[0]] = query[1]; - }); + } return obj; } @@ -244,6 +308,8 @@ function parse_rtmp_url(rtmp_url) { } var ret = { + url: rtmp_url, + schema: a.protocol.replace(":", ""), server: a.hostname, port: port, vhost: vhost, app: app, stream: stream }; @@ -500,7 +566,14 @@ AsyncRefresh2.prototype.initialize = function(pfn, timeout) { * stop refresh, the refresh pfn is set to null. */ AsyncRefresh2.prototype.stop = function() { - this.refresh_change(null, null); + this.__call.__enabled = false; +} +/** + * restart refresh, use previous config. + */ +AsyncRefresh2.prototype.restart = function() { + this.__call.__enabled = true; + this.request(0); } /** * change refresh pfn, the old pfn will set to disabled. @@ -568,4 +641,4 @@ AsyncRefresh2.prototype.request = function(timeout) { * depends: jquery1.10, boostrap2 * https://code.csdn.net/snippets/146160 * @see: http://blog.csdn.net/win_lin/article/details/17628631 - */ + */ \ No newline at end of file diff --git a/trunk/research/players/jwplayer6.html b/trunk/research/players/jwplayer6.html index 496d6d811..679803582 100644 --- a/trunk/research/players/jwplayer6.html +++ b/trunk/research/players/jwplayer6.html @@ -24,6 +24,20 @@