mirror of
https://github.com/ossrs/srs.git
synced 2025-02-15 04:42:04 +00:00
36 lines
952 B
ActionScript
36 lines
952 B
ActionScript
|
package
|
||
|
{
|
||
|
import flash.external.ExternalInterface;
|
||
|
import flash.utils.setTimeout;
|
||
|
|
||
|
/**
|
||
|
* the utility functions.
|
||
|
*/
|
||
|
public class Utility
|
||
|
{
|
||
|
/**
|
||
|
* initialize the player by flashvars for config.
|
||
|
* @param flashvars the config.
|
||
|
*/
|
||
|
public static function stringEndswith(s:String, f:String):Boolean {
|
||
|
return s && f && s.indexOf(f) == s.length - f.length;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* write log to trace and console.log.
|
||
|
* @param msg the log message.
|
||
|
*/
|
||
|
public static function log(js_id:String, msg:String):void {
|
||
|
msg = "[" + new Date() +"][srs-player][" + js_id + "] " + msg;
|
||
|
|
||
|
trace(msg);
|
||
|
|
||
|
if (!flash.external.ExternalInterface.available) {
|
||
|
flash.utils.setTimeout(log, 300, msg);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
ExternalInterface.call("console.log", msg);
|
||
|
}
|
||
|
}
|
||
|
}
|