mirror of
https://github.com/antos-rde/antosdk-apps.git
synced 2024-11-07 22:18:29 +01:00
add packages
This commit is contained in:
parent
1d4957b4c5
commit
2d7acf3f35
24
About/README.md
Normal file
24
About/README.md
Normal file
@ -0,0 +1,24 @@
|
||||
# About
|
||||
This is an example project, generated by AntOS Development Kit
|
||||
|
||||
## Howto
|
||||
|
||||
1. Open the project.apj file with AntOSDK (simply double Click on it)
|
||||
2. Modify the UI in *assets/scheme.html*
|
||||
3. Modify application code in *coffees/main.coffee*
|
||||
4. Modify CSS style in *css/main.css*
|
||||
5. Other files need to be copied: put in to assets
|
||||
|
||||
## Set up build target
|
||||
|
||||
Click **Menu> Build > Build Option** or simply hit **ALT-Y**
|
||||
|
||||
In the build options dialog, add or remove files that need to be
|
||||
included into the build
|
||||
|
||||
Click **Save**
|
||||
|
||||
## Build application
|
||||
* To build: **Menu > Build > Build** or **ALT-C**
|
||||
* To build and run: **Menu > Build > Build and Run** or **CTRL-R**
|
||||
* To release: **Menu > Build > Build release** or **ALT-P**
|
5
About/assets/scheme.html
Normal file
5
About/assets/scheme.html
Normal file
@ -0,0 +1,5 @@
|
||||
<afx-app-window apptitle="__(About AntOS)" width="450" height="500" data-id="About">
|
||||
<afx-hbox >
|
||||
<div data-id="container" style="padding:10px;overflow:auto;"></div>
|
||||
</afx-hbox>
|
||||
</afx-app-window>
|
24
About/build/debug/README.md
Normal file
24
About/build/debug/README.md
Normal file
@ -0,0 +1,24 @@
|
||||
# About
|
||||
This is an example project, generated by AntOS Development Kit
|
||||
|
||||
## Howto
|
||||
|
||||
1. Open the project.apj file with AntOSDK (simply double Click on it)
|
||||
2. Modify the UI in *assets/scheme.html*
|
||||
3. Modify application code in *coffees/main.coffee*
|
||||
4. Modify CSS style in *css/main.css*
|
||||
5. Other files need to be copied: put in to assets
|
||||
|
||||
## Set up build target
|
||||
|
||||
Click **Menu> Build > Build Option** or simply hit **ALT-Y**
|
||||
|
||||
In the build options dialog, add or remove files that need to be
|
||||
included into the build
|
||||
|
||||
Click **Save**
|
||||
|
||||
## Build application
|
||||
* To build: **Menu > Build > Build** or **ALT-C**
|
||||
* To build and run: **Menu > Build > Build and Run** or **CTRL-R**
|
||||
* To release: **Menu > Build > Build release** or **ALT-P**
|
28
About/build/debug/main.js
Normal file
28
About/build/debug/main.js
Normal file
@ -0,0 +1,28 @@
|
||||
(function() {
|
||||
var About;
|
||||
|
||||
About = class About extends this.OS.GUI.BaseApplication {
|
||||
constructor(args) {
|
||||
super("About", args);
|
||||
}
|
||||
|
||||
main() {
|
||||
var me;
|
||||
me = this;
|
||||
this.container = this.find("container");
|
||||
return "os://README.md".asFileHandler().read(function(txt) {
|
||||
var converter;
|
||||
converter = new showdown.Converter();
|
||||
return ($(me.container)).html(converter.makeHtml(txt));
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
About.singleton = true;
|
||||
|
||||
About.dependencies = ["showdown.min"];
|
||||
|
||||
this.OS.register("About", About);
|
||||
|
||||
}).call(this);
|
13
About/build/debug/package.json
Normal file
13
About/build/debug/package.json
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"app":"About",
|
||||
"name":"About",
|
||||
"description":"AntOS about",
|
||||
"info":{
|
||||
"author": "Xuan Sang LE",
|
||||
"email": "xsang.le@gmail.com"
|
||||
},
|
||||
"version":"0.0.1-a",
|
||||
"category":"Other",
|
||||
"iconclass":"fa fa-question-circle",
|
||||
"mimes":["none"]
|
||||
}
|
5
About/build/debug/scheme.html
Normal file
5
About/build/debug/scheme.html
Normal file
@ -0,0 +1,5 @@
|
||||
<afx-app-window apptitle="__(About AntOS)" width="450" height="500" data-id="About">
|
||||
<afx-hbox >
|
||||
<div data-id="container" style="padding:10px;overflow:auto;"></div>
|
||||
</afx-hbox>
|
||||
</afx-app-window>
|
14
About/coffees/main.coffee
Normal file
14
About/coffees/main.coffee
Normal file
@ -0,0 +1,14 @@
|
||||
class About extends this.OS.GUI.BaseApplication
|
||||
constructor: ( args ) ->
|
||||
super "About", args
|
||||
|
||||
main: () ->
|
||||
me = @
|
||||
@container = @find "container"
|
||||
"os://README.md".asFileHandler().read (txt) ->
|
||||
converter = new showdown.Converter()
|
||||
($ me.container).html converter.makeHtml txt
|
||||
|
||||
About.singleton = true
|
||||
About.dependencies = [ "showdown.min" ]
|
||||
this.OS.register "About", About
|
13
About/package.json
Normal file
13
About/package.json
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"app":"About",
|
||||
"name":"About",
|
||||
"description":"AntOS about",
|
||||
"info":{
|
||||
"author": "Xuan Sang LE",
|
||||
"email": "xsang.le@gmail.com"
|
||||
},
|
||||
"version":"0.0.1-a",
|
||||
"category":"Other",
|
||||
"iconclass":"fa fa-question-circle",
|
||||
"mimes":["none"]
|
||||
}
|
8
About/project.apj
Normal file
8
About/project.apj
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"name": "About",
|
||||
"root": "home://workspace/About",
|
||||
"css": [],
|
||||
"javascripts": [],
|
||||
"coffees": ["coffees/main.coffee"],
|
||||
"copies": ["assets/scheme.html", "package.json", "README.md"]
|
||||
}
|
24
MediaPlayer/README.md
Normal file
24
MediaPlayer/README.md
Normal file
@ -0,0 +1,24 @@
|
||||
# MediaPlayer
|
||||
This is an example project, generated by AntOS Development Kit
|
||||
|
||||
## Howto
|
||||
|
||||
1. Open the project.apj file with AntOSDK (simply double Click on it)
|
||||
2. Modify the UI in *assets/scheme.html*
|
||||
3. Modify application code in *coffees/main.coffee*
|
||||
4. Modify CSS style in *css/main.css*
|
||||
5. Other files need to be copied: put in to assets
|
||||
|
||||
## Set up build target
|
||||
|
||||
Click **Menu> Build > Build Option** or simply hit **ALT-Y**
|
||||
|
||||
In the build options dialog, add or remove files that need to be
|
||||
included into the build
|
||||
|
||||
Click **Save**
|
||||
|
||||
## Build application
|
||||
* To build: **Menu > Build > Build** or **ALT-C**
|
||||
* To build and run: **Menu > Build > Build and Run** or **CTRL-R**
|
||||
* To release: **Menu > Build > Build release** or **ALT-P**
|
44
MediaPlayer/assets/scheme.html
Normal file
44
MediaPlayer/assets/scheme.html
Normal file
@ -0,0 +1,44 @@
|
||||
<afx-app-window apptitle="__(Media Player)" width="300" height="450" resizable="false" data-id="MediaPlayer">
|
||||
<afx-vbox >
|
||||
<afx-hbox data-height="85">
|
||||
<afx-vbox>
|
||||
<div data-height="5"></div>
|
||||
<afx-hbox>
|
||||
<div data-width="5"></div>
|
||||
<afx-label data-id="play-time" data-width="50" ></afx-label>
|
||||
<afx-label data-id = "song-name" ></afx-label>
|
||||
<afx-label data-id="total-time" data-width="50"></afx-label>
|
||||
<div data-width="5"></div>
|
||||
</afx-hbox>
|
||||
<afx-hbox>
|
||||
<div data-width="5"></div>
|
||||
<afx-slider data-id="play-slide" value="0" max="100"></afx-slider>
|
||||
<div data-width="5"></div>
|
||||
</afx-hbox>
|
||||
|
||||
<afx-hbox class = "play-control" data-height="50">
|
||||
<div data-width="5"></div>
|
||||
<afx-switch data-width = "22" data-id="play-random"></afx-switch>
|
||||
<div data-id="animation" class="animation">
|
||||
<span></span>
|
||||
<span></span>
|
||||
<span></span>
|
||||
<span></span>
|
||||
<span></span>
|
||||
</div>
|
||||
<afx-button class = "ctlbtn" data-width="26" data-id="play-prev" iconclass="fa fa-step-backward" ></afx-button>
|
||||
<afx-switch data-width="38" data-id="play-pause" ></afx-switch>
|
||||
<afx-button class = "ctlbtn" data-width="26" data-id="play-next" iconclass="fa fa-step-forward"></afx-button>
|
||||
<afx-slider data-id="vol-control" max="100"></afx-slider>
|
||||
<afx-switch data-width = "22" data-id="play-vol"></afx-switch>
|
||||
</afx-hbox>
|
||||
</afx-vbox>
|
||||
</afx-hbox>
|
||||
<afx-hbox>
|
||||
<div data-width="5"></div>
|
||||
<afx-list-view data-id="playlist"></afx-list-view>
|
||||
<div data-width="5"></div>
|
||||
</afx-hbox>
|
||||
<div data-height="5"></div>
|
||||
</afx-vbox>
|
||||
</afx-app-window>
|
24
MediaPlayer/build/debug/README.md
Normal file
24
MediaPlayer/build/debug/README.md
Normal file
@ -0,0 +1,24 @@
|
||||
# MediaPlayer
|
||||
This is an example project, generated by AntOS Development Kit
|
||||
|
||||
## Howto
|
||||
|
||||
1. Open the project.apj file with AntOSDK (simply double Click on it)
|
||||
2. Modify the UI in *assets/scheme.html*
|
||||
3. Modify application code in *coffees/main.coffee*
|
||||
4. Modify CSS style in *css/main.css*
|
||||
5. Other files need to be copied: put in to assets
|
||||
|
||||
## Set up build target
|
||||
|
||||
Click **Menu> Build > Build Option** or simply hit **ALT-Y**
|
||||
|
||||
In the build options dialog, add or remove files that need to be
|
||||
included into the build
|
||||
|
||||
Click **Save**
|
||||
|
||||
## Build application
|
||||
* To build: **Menu > Build > Build** or **ALT-C**
|
||||
* To build and run: **Menu > Build > Build and Run** or **CTRL-R**
|
||||
* To release: **Menu > Build > Build release** or **ALT-P**
|
108
MediaPlayer/build/debug/main.css
Normal file
108
MediaPlayer/build/debug/main.css
Normal file
@ -0,0 +1,108 @@
|
||||
|
||||
afx-app-window[data-id="MediaPlayer"] afx-hbox.play-control afx-button button{
|
||||
border: 0;
|
||||
font-size: 25px;
|
||||
padding-top:9px;
|
||||
background-color: transparent;
|
||||
}
|
||||
afx-app-window[data-id="MediaPlayer"] afx-hbox.play-control afx-switch[data-id="play-pause"]{
|
||||
padding-top:5px;
|
||||
}
|
||||
afx-app-window[data-id="MediaPlayer"] afx-hbox.play-control afx-switch[data-id="play-pause"] span::before{
|
||||
content: "\f144";
|
||||
font-size: 40px;
|
||||
}
|
||||
afx-app-window[data-id="MediaPlayer"] afx-hbox.play-control afx-switch[data-id="play-pause"] .swon::before{
|
||||
content: "\f28b";
|
||||
}
|
||||
afx-app-window[data-id="MediaPlayer"] afx-label[data-id="play-time"] {
|
||||
text-align: left;
|
||||
}
|
||||
afx-app-window[data-id="MediaPlayer"] afx-label[data-id="total-time"] {
|
||||
text-align: right;
|
||||
}
|
||||
afx-app-window[data-id="MediaPlayer"] afx-label[data-id="song-name"] {
|
||||
text-align: center;
|
||||
display: inline;
|
||||
overflow: hidden;
|
||||
}
|
||||
afx-app-window[data-id="MediaPlayer"] afx-slider .dragpoint {
|
||||
width:12px;
|
||||
height: 12px;
|
||||
}
|
||||
afx-app-window[data-id="MediaPlayer"] afx-slider[data-id="vol-control"] .progress {
|
||||
background-color: #a6a6a6;
|
||||
}
|
||||
afx-app-window[data-id="MediaPlayer"] afx-hbox.play-control afx-switch[data-id="play-vol"] {
|
||||
margin-top:10px;
|
||||
}
|
||||
afx-app-window[data-id="MediaPlayer"] afx-hbox.play-control afx-switch[data-id="play-vol"] span::before{
|
||||
content: "\f026";
|
||||
font-size: 19px;
|
||||
}
|
||||
afx-app-window[data-id="MediaPlayer"] afx-hbox.play-control afx-switch[data-id="play-vol"] .swon::before{
|
||||
content: "\f028";
|
||||
}
|
||||
afx-app-window[data-id="MediaPlayer"] afx-hbox.play-control afx-switch[data-id="play-random"] span::before{
|
||||
content: "\f074";
|
||||
font-size: 16px;
|
||||
}
|
||||
afx-app-window[data-id="MediaPlayer"] afx-hbox.play-control afx-switch[data-id="play-random"] .swon::before{
|
||||
content: "\f074";
|
||||
}
|
||||
afx-app-window[data-id="MediaPlayer"] afx-hbox.play-control afx-switch[data-id="play-random"] {
|
||||
margin-top:10px;
|
||||
}
|
||||
afx-app-window[data-id="MediaPlayer"] afx-list-view[data-id="playlist"] {
|
||||
border:1px solid #a6a6a6;
|
||||
}
|
||||
afx-app-window[data-id="MediaPlayer"] afx-button.ctlbtn button:active{
|
||||
background-color: transparent;
|
||||
color:#2786F3;
|
||||
}
|
||||
afx-app-window[data-id="MediaPlayer"] .animation {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
afx-app-window[data-id="MediaPlayer"] .animation span{
|
||||
width:5px;
|
||||
height: 5px;
|
||||
bottom:18px;
|
||||
position:absolute;
|
||||
-webkit-animation: bodong 0.5s infinite ease;
|
||||
}
|
||||
|
||||
afx-app-window[data-id="MediaPlayer"] .animation span:first-child{
|
||||
left:10px;
|
||||
-webkit-animation-delay:.3s;
|
||||
background-color: red;
|
||||
}
|
||||
|
||||
afx-app-window[data-id="MediaPlayer"] .animation span:nth-child(2){
|
||||
left:17px;
|
||||
-webkit-animation-delay:.4s;
|
||||
background-color:orange ;
|
||||
}
|
||||
afx-app-window[data-id="MediaPlayer"] .animation span:nth-child(3){
|
||||
left:24px;
|
||||
-webkit-animation-delay:.6s;
|
||||
background-color: #2786F3;
|
||||
}
|
||||
afx-app-window[data-id="MediaPlayer"] .animation span:nth-child(4){
|
||||
left:31px;
|
||||
-webkit-animation-delay:.8s;
|
||||
background-color: chocolate;
|
||||
}
|
||||
afx-app-window[data-id="MediaPlayer"] .animation span:nth-child(5){
|
||||
left:38px;
|
||||
-webkit-animation-delay:1s;
|
||||
background-color: blue;
|
||||
}
|
||||
|
||||
@-webkit-keyframes bodong{
|
||||
0%{height:5px; background:bule;}
|
||||
30%{height:15px; background:bule;}
|
||||
60%{height:20px; background:bule;}
|
||||
80%{height:15px; background:bule;}
|
||||
100%{height:5px; background:bule;}
|
||||
}
|
444
MediaPlayer/build/debug/main.js
Normal file
444
MediaPlayer/build/debug/main.js
Normal file
File diff suppressed because one or more lines are too long
13
MediaPlayer/build/debug/package.json
Normal file
13
MediaPlayer/build/debug/package.json
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"app":"MediaPlayer",
|
||||
"name":"Media Player",
|
||||
"description":"MP3 player for AntOS",
|
||||
"info":{
|
||||
"author": "Xuan Sang LE",
|
||||
"email": "xsang.le@gmail.com"
|
||||
},
|
||||
"version":"0.0.8-a",
|
||||
"category":"Multimedia",
|
||||
"iconclass":"fa fa-headphones",
|
||||
"mimes":["none"]
|
||||
}
|
44
MediaPlayer/build/debug/scheme.html
Normal file
44
MediaPlayer/build/debug/scheme.html
Normal file
@ -0,0 +1,44 @@
|
||||
<afx-app-window apptitle="__(Media Player)" width="300" height="450" resizable="false" data-id="MediaPlayer">
|
||||
<afx-vbox >
|
||||
<afx-hbox data-height="85">
|
||||
<afx-vbox>
|
||||
<div data-height="5"></div>
|
||||
<afx-hbox>
|
||||
<div data-width="5"></div>
|
||||
<afx-label data-id="play-time" data-width="50" ></afx-label>
|
||||
<afx-label data-id = "song-name" ></afx-label>
|
||||
<afx-label data-id="total-time" data-width="50"></afx-label>
|
||||
<div data-width="5"></div>
|
||||
</afx-hbox>
|
||||
<afx-hbox>
|
||||
<div data-width="5"></div>
|
||||
<afx-slider data-id="play-slide" value="0" max="100"></afx-slider>
|
||||
<div data-width="5"></div>
|
||||
</afx-hbox>
|
||||
|
||||
<afx-hbox class = "play-control" data-height="50">
|
||||
<div data-width="5"></div>
|
||||
<afx-switch data-width = "22" data-id="play-random"></afx-switch>
|
||||
<div data-id="animation" class="animation">
|
||||
<span></span>
|
||||
<span></span>
|
||||
<span></span>
|
||||
<span></span>
|
||||
<span></span>
|
||||
</div>
|
||||
<afx-button class = "ctlbtn" data-width="26" data-id="play-prev" iconclass="fa fa-step-backward" ></afx-button>
|
||||
<afx-switch data-width="38" data-id="play-pause" ></afx-switch>
|
||||
<afx-button class = "ctlbtn" data-width="26" data-id="play-next" iconclass="fa fa-step-forward"></afx-button>
|
||||
<afx-slider data-id="vol-control" max="100"></afx-slider>
|
||||
<afx-switch data-width = "22" data-id="play-vol"></afx-switch>
|
||||
</afx-hbox>
|
||||
</afx-vbox>
|
||||
</afx-hbox>
|
||||
<afx-hbox>
|
||||
<div data-width="5"></div>
|
||||
<afx-list-view data-id="playlist"></afx-list-view>
|
||||
<div data-width="5"></div>
|
||||
</afx-hbox>
|
||||
<div data-height="5"></div>
|
||||
</afx-vbox>
|
||||
</afx-app-window>
|
262
MediaPlayer/coffees/main.coffee
Normal file
262
MediaPlayer/coffees/main.coffee
Normal file
@ -0,0 +1,262 @@
|
||||
class MediaPlayer extends this.OS.GUI.BaseApplication
|
||||
constructor: ( args ) ->
|
||||
super "MediaPlayer", args
|
||||
|
||||
main: () ->
|
||||
me = @
|
||||
@volsw = @find "play-vol"
|
||||
@volctl = @find "vol-control"
|
||||
@volsw.set "swon", true
|
||||
@volctl.set "onchange", (v) ->
|
||||
return unless (me.volsw.get "swon")
|
||||
Howler.volume (me.volctl.get "value")/100
|
||||
@volctl.set "value", 70
|
||||
@playlist = @find "playlist"
|
||||
@playtime = @find "play-time"
|
||||
@songname = @find "song-name"
|
||||
@totaltime = @find "total-time"
|
||||
@playpause = @find "play-pause"
|
||||
@progress = @find "play-slide"
|
||||
@playran = @find "play-random"
|
||||
@history = []
|
||||
@currsong = undefined
|
||||
@timer = undefined
|
||||
@animator = @find "animation"
|
||||
|
||||
@volsw.set "onchange", (e) ->
|
||||
return Howler.volume 0 if not e.data
|
||||
Howler.volume (me.volctl.get "value")/100
|
||||
@playlist.set "buttons", [
|
||||
{
|
||||
text: "+",
|
||||
onbtclick: () ->
|
||||
me.openDialog "FileDiaLog", (d,n,p,f) ->
|
||||
return me.scanDir f if f.type is "dir"
|
||||
f.text = f.filename
|
||||
f.iconclass = "fa fa-music"
|
||||
me.playlist.push f, true
|
||||
, "__(Select MP3 file or a folder)"
|
||||
, { mimes: ["dir", "audio/mpeg"] }
|
||||
},
|
||||
{
|
||||
text: "-",
|
||||
onbtclick: () ->
|
||||
sel = me.playlist.get "selected"
|
||||
return unless sel
|
||||
me.stop() if sel is me.currsong
|
||||
me.playlist.remove sel, true
|
||||
},
|
||||
{
|
||||
text: "",
|
||||
onbtclick: () ->
|
||||
me.openDialog "PromptDialog", (link) ->
|
||||
return unless link and link isnt ""
|
||||
data = {
|
||||
text: link,
|
||||
path: link,
|
||||
iconclass: "fa fa-link",
|
||||
broadcast: true
|
||||
}
|
||||
me.playlist.push data, true
|
||||
, "__(MP3 Radio broadcast)", { label:"Enter radio broadcast link" }
|
||||
, iconclass: "fa fa-link"
|
||||
},
|
||||
{
|
||||
text:"",
|
||||
iconclass: "fa fa-save",
|
||||
onbtclick: () ->
|
||||
playlist = []
|
||||
for v in me.playlist.get "items"
|
||||
playlist.push {
|
||||
text: v.text,
|
||||
path: v.path,
|
||||
iconclass: v.iconclass,
|
||||
broadcast: if v.broadcast then v.broadcast else false
|
||||
}
|
||||
fp = "Untitled".asFileHandler()
|
||||
me.openDialog "FileDiaLog", (d,n,p,f) ->
|
||||
fp = "#{d}/#{n}".asFileHandler()
|
||||
fp.cache = playlist
|
||||
fp.write "object", (r) ->
|
||||
return me.error __("Cannot save playlist: {0}", r.error) if r.error
|
||||
me.notify __("Playlist saved")
|
||||
, "__(Save Playlist)", { file: fp }
|
||||
},
|
||||
{
|
||||
text:"",
|
||||
iconclass: "fa fa-folder",
|
||||
onbtclick: () ->
|
||||
me.openDialog "FileDiaLog", (d,n,p,f) ->
|
||||
f.path.asFileHandler().read (d) ->
|
||||
me.stop()
|
||||
me.playlist.set "items", d
|
||||
, "json"
|
||||
, "__(Open Playlist)", { mimes: ["application/json"] }
|
||||
}
|
||||
]
|
||||
@playlist.set "onlistdbclick", (e) ->
|
||||
return unless e
|
||||
e.data.index = e.idx
|
||||
me.play e.data
|
||||
@progress.set "onchange", (s) ->
|
||||
me.seek s
|
||||
@playpause.set "onchange", (e) ->
|
||||
me.togglePlayPause()
|
||||
(@find "play-prev").set "onbtclick", () ->
|
||||
me.prevSong()
|
||||
(@find "play-next").set "onbtclick", () ->
|
||||
me.nextSong()
|
||||
$(@animator).css("visibility", "hidden")
|
||||
scanDir: (f) ->
|
||||
me = @
|
||||
f.path.asFileHandler().read (d) ->
|
||||
return me.error __("Unable to read {0}", d.error) if d.error
|
||||
for v in d.result when v.mime.match /audio\/mpeg/
|
||||
v.iconclass = "fa fa-music"
|
||||
v.text = v.filename
|
||||
me.playlist.push v, true
|
||||
|
||||
|
||||
togglePlayPause: () ->
|
||||
return @playpause.set "swon",false unless @currsong and @currsong.howl
|
||||
sound = @currsong.howl
|
||||
if sound.playing()
|
||||
sound.pause()
|
||||
else
|
||||
sound.play()
|
||||
|
||||
nextSong: () ->
|
||||
idx = -1
|
||||
if (@playran.get "swon")
|
||||
idx = @randomSong()
|
||||
else
|
||||
len = (@playlist.get "items").length
|
||||
if len > 0
|
||||
idx = 0
|
||||
idx = @currsong.index + 1 if @currsong
|
||||
idx = 0 if idx >= len
|
||||
return if idx is -1
|
||||
@history.pop() if history.length >= 10
|
||||
@history.unshift @currsong.index if @currsong
|
||||
@playlist.set "selected", idx
|
||||
sel = @playlist.get "selected"
|
||||
sel.index = idx
|
||||
@play sel
|
||||
|
||||
prevSong: () ->
|
||||
idx = -1
|
||||
if (@playran.get "swon")
|
||||
idx = @history.shift() if @history.length > 0
|
||||
else
|
||||
len = (@playlist.get "items").length
|
||||
if len > 0
|
||||
idx = @currsong.index - 1 if @currsong
|
||||
idx = 0 if idx < 0
|
||||
return if idx is -1
|
||||
@playlist.set "selected", idx
|
||||
sel = @playlist.get "selected"
|
||||
sel.index = idx
|
||||
@play sel
|
||||
|
||||
randomSong: () ->
|
||||
len = (@playlist.get "items").length
|
||||
return -1 unless len > 0
|
||||
return Math.floor(Math.random() * Math.floor(len))
|
||||
|
||||
play: (file) ->
|
||||
me = @
|
||||
@stop()
|
||||
@currsong = file
|
||||
sound = file.howl
|
||||
if not sound
|
||||
sound = file.howl = new Howl {
|
||||
src: [
|
||||
file.path.asFileHandler().getlink()
|
||||
],
|
||||
preload:true,
|
||||
buffer: true,
|
||||
html5: true, # Force to HTML5 so that the audio can stream in (best for large files).
|
||||
format: ['mp3', 'aac'],
|
||||
onplay: () ->
|
||||
$(me.animator).css("visibility", "visible")
|
||||
#Display the duration.
|
||||
me.playpause.set "swon", true
|
||||
console.log "play"
|
||||
me.songname.set "text", file.text
|
||||
duration = Math.round(sound.duration())
|
||||
if duration isnt Infinity
|
||||
me.totaltime.set "text", me.formatDuration duration
|
||||
me.progress.set "max", duration
|
||||
else
|
||||
me.totaltime.set "text", "--:--"
|
||||
me.progress.set "max", 0
|
||||
if not file.broadcast
|
||||
func = () ->
|
||||
if sound.playing()
|
||||
seek = Math.round(sound.seek()) || 0
|
||||
me.progress.set "value", seek
|
||||
me.playtime.set "text", me.formatDuration seek
|
||||
me.timer = setTimeout (() -> func()), 1000
|
||||
func()
|
||||
else
|
||||
me.totaltime.set "text", "--:--"
|
||||
me.progress.set "value", (me.progress.get "max")
|
||||
func = () ->
|
||||
if sound.playing()
|
||||
seek = Math.round(sound.seek()) || 0
|
||||
me.playtime.set "text", me.formatDuration seek
|
||||
me.timer = setTimeout (() -> func()), 1000
|
||||
func()
|
||||
onload: () ->
|
||||
# Start the wave animation.
|
||||
console.log "load"
|
||||
$(me.animator).css("visibility", "hidden")
|
||||
sound.play() if not file.broadcast
|
||||
|
||||
onend: () ->
|
||||
# Stop the wave animation.
|
||||
me.progress.set "value", 0
|
||||
clearTimeout me.timer if me.timer
|
||||
me.playpause.set "swon", false
|
||||
$(me.animator).css("visibility", "hidden")
|
||||
me.nextSong()
|
||||
onpause: ()->
|
||||
# Stop the wave animation.
|
||||
console.log "pause"
|
||||
clearTimeout me.timer if me.timer
|
||||
me.playpause.set "swon", false
|
||||
$(me.animator).css("visibility", "hidden")
|
||||
|
||||
onstop: () ->
|
||||
me.progress.set "value", 0
|
||||
clearTimeout me.timer if me.timer
|
||||
me.playpause.set "swon", false
|
||||
$(me.animator).css("visibility", "hidden")
|
||||
console.log "stop"
|
||||
}
|
||||
sound.play() if file.broadcast
|
||||
else
|
||||
sound.play()
|
||||
$(@animator).css("visibility", "visible")
|
||||
stop: () ->
|
||||
if @currsong and @currsong.howl
|
||||
@currsong.howl.stop() if @currsong.howl.playing()
|
||||
|
||||
seek: (v) ->
|
||||
return unless @currsong and @currsong.howl and not @currsong.broadcast
|
||||
return unless (@progress.get "max") > 0
|
||||
sound = @currsong.howl
|
||||
sound.seek(v)
|
||||
|
||||
formatDuration: (s) ->
|
||||
min = Math.floor(s/60)
|
||||
sec = s % 60
|
||||
min = if min < 10 then "0#{min}" else "#{min}"
|
||||
sec = if sec < 10 then "0#{sec}" else "#{sec}"
|
||||
"#{min}:#{sec}"
|
||||
|
||||
cleanup: (evt) ->
|
||||
@stop()
|
||||
# only one instance is allow
|
||||
MediaPlayer.singleton = true
|
||||
this.OS.register "MediaPlayer", MediaPlayer
|
107
MediaPlayer/css/main.css
Normal file
107
MediaPlayer/css/main.css
Normal file
@ -0,0 +1,107 @@
|
||||
afx-app-window[data-id="MediaPlayer"] afx-hbox.play-control afx-button button{
|
||||
border: 0;
|
||||
font-size: 25px;
|
||||
padding-top:9px;
|
||||
background-color: transparent;
|
||||
}
|
||||
afx-app-window[data-id="MediaPlayer"] afx-hbox.play-control afx-switch[data-id="play-pause"]{
|
||||
padding-top:5px;
|
||||
}
|
||||
afx-app-window[data-id="MediaPlayer"] afx-hbox.play-control afx-switch[data-id="play-pause"] span::before{
|
||||
content: "\f144";
|
||||
font-size: 40px;
|
||||
}
|
||||
afx-app-window[data-id="MediaPlayer"] afx-hbox.play-control afx-switch[data-id="play-pause"] .swon::before{
|
||||
content: "\f28b";
|
||||
}
|
||||
afx-app-window[data-id="MediaPlayer"] afx-label[data-id="play-time"] {
|
||||
text-align: left;
|
||||
}
|
||||
afx-app-window[data-id="MediaPlayer"] afx-label[data-id="total-time"] {
|
||||
text-align: right;
|
||||
}
|
||||
afx-app-window[data-id="MediaPlayer"] afx-label[data-id="song-name"] {
|
||||
text-align: center;
|
||||
display: inline;
|
||||
overflow: hidden;
|
||||
}
|
||||
afx-app-window[data-id="MediaPlayer"] afx-slider .dragpoint {
|
||||
width:12px;
|
||||
height: 12px;
|
||||
}
|
||||
afx-app-window[data-id="MediaPlayer"] afx-slider[data-id="vol-control"] .progress {
|
||||
background-color: #a6a6a6;
|
||||
}
|
||||
afx-app-window[data-id="MediaPlayer"] afx-hbox.play-control afx-switch[data-id="play-vol"] {
|
||||
margin-top:10px;
|
||||
}
|
||||
afx-app-window[data-id="MediaPlayer"] afx-hbox.play-control afx-switch[data-id="play-vol"] span::before{
|
||||
content: "\f026";
|
||||
font-size: 19px;
|
||||
}
|
||||
afx-app-window[data-id="MediaPlayer"] afx-hbox.play-control afx-switch[data-id="play-vol"] .swon::before{
|
||||
content: "\f028";
|
||||
}
|
||||
afx-app-window[data-id="MediaPlayer"] afx-hbox.play-control afx-switch[data-id="play-random"] span::before{
|
||||
content: "\f074";
|
||||
font-size: 16px;
|
||||
}
|
||||
afx-app-window[data-id="MediaPlayer"] afx-hbox.play-control afx-switch[data-id="play-random"] .swon::before{
|
||||
content: "\f074";
|
||||
}
|
||||
afx-app-window[data-id="MediaPlayer"] afx-hbox.play-control afx-switch[data-id="play-random"] {
|
||||
margin-top:10px;
|
||||
}
|
||||
afx-app-window[data-id="MediaPlayer"] afx-list-view[data-id="playlist"] {
|
||||
border:1px solid #a6a6a6;
|
||||
}
|
||||
afx-app-window[data-id="MediaPlayer"] afx-button.ctlbtn button:active{
|
||||
background-color: transparent;
|
||||
color:#2786F3;
|
||||
}
|
||||
afx-app-window[data-id="MediaPlayer"] .animation {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
afx-app-window[data-id="MediaPlayer"] .animation span{
|
||||
width:5px;
|
||||
height: 5px;
|
||||
bottom:18px;
|
||||
position:absolute;
|
||||
-webkit-animation: bodong 0.5s infinite ease;
|
||||
}
|
||||
|
||||
afx-app-window[data-id="MediaPlayer"] .animation span:first-child{
|
||||
left:10px;
|
||||
-webkit-animation-delay:.3s;
|
||||
background-color: red;
|
||||
}
|
||||
|
||||
afx-app-window[data-id="MediaPlayer"] .animation span:nth-child(2){
|
||||
left:17px;
|
||||
-webkit-animation-delay:.4s;
|
||||
background-color:orange ;
|
||||
}
|
||||
afx-app-window[data-id="MediaPlayer"] .animation span:nth-child(3){
|
||||
left:24px;
|
||||
-webkit-animation-delay:.6s;
|
||||
background-color: #2786F3;
|
||||
}
|
||||
afx-app-window[data-id="MediaPlayer"] .animation span:nth-child(4){
|
||||
left:31px;
|
||||
-webkit-animation-delay:.8s;
|
||||
background-color: chocolate;
|
||||
}
|
||||
afx-app-window[data-id="MediaPlayer"] .animation span:nth-child(5){
|
||||
left:38px;
|
||||
-webkit-animation-delay:1s;
|
||||
background-color: blue;
|
||||
}
|
||||
|
||||
@-webkit-keyframes bodong{
|
||||
0%{height:5px; background:bule;}
|
||||
30%{height:15px; background:bule;}
|
||||
60%{height:20px; background:bule;}
|
||||
80%{height:15px; background:bule;}
|
||||
100%{height:5px; background:bule;}
|
||||
}
|
4
MediaPlayer/javascripts/howler.min.js
vendored
Normal file
4
MediaPlayer/javascripts/howler.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
13
MediaPlayer/package.json
Normal file
13
MediaPlayer/package.json
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"app":"MediaPlayer",
|
||||
"name":"Media Player",
|
||||
"description":"MP3 player for AntOS",
|
||||
"info":{
|
||||
"author": "Xuan Sang LE",
|
||||
"email": "xsang.le@gmail.com"
|
||||
},
|
||||
"version":"0.0.8-a",
|
||||
"category":"Multimedia",
|
||||
"iconclass":"fa fa-headphones",
|
||||
"mimes":["none"]
|
||||
}
|
1
MediaPlayer/project.apj
Normal file
1
MediaPlayer/project.apj
Normal file
@ -0,0 +1 @@
|
||||
{"name":"MediaPlayer","root":"home://workspace/MediaPlayer","css":["css/main.css"],"javascripts":["javascripts/howler.min.js"],"coffees":["coffees/main.coffee"],"copies":["assets/scheme.html","package.json","README.md"]}
|
Loading…
Reference in New Issue
Block a user