Project

General

Profile

Statistics
| Revision:

root / trunk / web / dojo / dojox / av / widget / Status.js @ 10

History | View | Annotate | Download (2.83 KB)

1 9 andrej.cim
/*
2
        Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
3
        Available via Academic Free License >= 2.1 OR the modified BSD license.
4
        see: http://dojotoolkit.org/license for details
5
*/
6
7
8
if(!dojo._hasResource["dojox.av.widget.Status"]){
9
dojo._hasResource["dojox.av.widget.Status"]=true;
10
dojo.provide("dojox.av.widget.Status");
11
dojo.require("dijit._Widget");
12
dojo.require("dijit._Templated");
13
dojo.declare("dojox.av.widget.Status",[dijit._Widget,dijit._Templated],{templateString:dojo.cache("dojox.av.widget","resources/Status.html","<table class=\"Status\">\n    <tr>\n        <td class=\"Time\"><span dojoAttachPoint=\"timeNode\">0.00</span></td>\n        <td class=\"Status\"><div dojoAttachPoint=\"titleNode\">Loading...</div></td>\n        <td class=\"Duration\"><span dojoAttachPoint=\"durNode\">0.00</span></td>\n    </tr>\n</table>\n"),postCreate:function(){
14
this.titleNode=dojo.query(".Status",this.domNode);
15
this.durNode=dojo.query(".Duration",this.domNode);
16
this.timeNode=dojo.query(".Time",this.domNode);
17
},setMedia:function(_1){
18
this.media=_1;
19
dojo.connect(this.media,"onMetaData",this,function(_2){
20
this.duration=_2.duration;
21
this.durNode.innerHTML=this.toSeconds(this.duration);
22
});
23
dojo.connect(this.media,"onPosition",this,function(_3){
24
});
25
var _4=["onMetaData","onPosition","onStart","onBuffer","onPlay","onPause","onStop","onEnd","onError","onLoad"];
26
dojo.forEach(_4,function(c){
27
dojo.connect(this.media,c,this,c);
28
},this);
29
},onMetaData:function(_5){
30
this.duration=_5.duration;
31
this.durNode.innerHTML=this.toSeconds(this.duration);
32
if(this.media.title){
33
this.title=this.media.title;
34
}else{
35
var a=this.media.mediaUrl.split("/");
36
var b=a[a.length-1].split(".")[0];
37
this.title=b;
38
}
39
},onBuffer:function(_6){
40
this.isBuffering=_6;
41
console.warn("status onBuffer",this.isBuffering);
42
if(this.isBuffering){
43
this.setStatus("buffering...");
44
}else{
45
this.setStatus("Playing");
46
}
47
},onPosition:function(_7){
48
},onStart:function(){
49
this.setStatus("Starting");
50
},onPlay:function(){
51
this.setStatus("Playing");
52
},onPause:function(){
53
this.setStatus("Paused");
54
},onStop:function(){
55
this.setStatus("Stopped");
56
},onEnd:function(){
57
this.setStatus("Stopped");
58
},onError:function(_8){
59
var _9=_8.info.code;
60
if(_9=="NetStream.Play.StreamNotFound"){
61
_9="Stream Not Found";
62
}
63
this.setStatus("ERROR: "+_9,true);
64
},onLoad:function(){
65
this.setStatus("Loading...");
66
},setStatus:function(_a,_b){
67
if(_b){
68
dojo.addClass(this.titleNode,"statusError");
69
}else{
70
dojo.removeClass(this.titleNode,"statusError");
71
if(this.isBuffering){
72
_a="buffering...";
73
}
74
}
75
this.titleNode.innerHTML="<span class=\"statusTitle\">"+this.title+"</span> <span class=\"statusInfo\">"+_a+"</span>";
76
},toSeconds:function(_c){
77
var ts=_c.toString();
78
if(ts.indexOf(".")<0){
79
ts+=".00";
80
}else{
81
if(ts.length-ts.indexOf(".")==2){
82
ts+="0";
83
}else{
84
if(ts.length-ts.indexOf(".")>2){
85
ts=ts.substring(0,ts.indexOf(".")+3);
86
}
87
}
88
}
89
return ts;
90
}});
91
}