Skip to content

Commit cb70bf6

Browse files
author
android-js
authored
Merge pull request #6 from DeveshPankaj/master
Added: Music App
2 parents c65f5f8 + 24d4470 commit cb70bf6

File tree

1,008 files changed

+134267
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,008 files changed

+134267
-0
lines changed

music app/.idea/app.iml

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

music app/.idea/misc.xml

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

music app/.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

music app/.idea/workspace.xml

Lines changed: 245 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

music app/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
## Build
3+
```bash
4+
$ androidjs b
5+
```
6+
27.5 KB
Loading
9.27 KB
Loading

music app/assets/icon/icon.png

25.7 KB
Loading

music app/assets/ipc/androidjs.js

Lines changed: 306 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

music app/main.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
var mp3Duration = require('mp3-duration');
2+
var convert = require('convert-seconds');
3+
const path = require('path');
4+
const fs = require('fs');
5+
6+
const {back} = require('androidjs');
7+
8+
9+
// let __dir = '/media/devesh/Data/Songs/';
10+
let __dir = undefined;
11+
12+
13+
async function buildList() {
14+
15+
const items = fs.readdirSync(__dir);
16+
17+
for (let i = 0; i < items.length; i++) {
18+
19+
let item = {
20+
track: undefined,
21+
name: undefined,
22+
duration: undefined,
23+
file: undefined
24+
};
25+
26+
item.track = i;
27+
item.name = items[i];
28+
item.duration = undefined;
29+
item.file = 'file://' + path.join(__dir, items[i]);
30+
31+
32+
if (path.parse(items[i]).ext === '.mp3') {
33+
mp3Duration(path.join(__dir, items[i]), function (err, duration) {
34+
if (err) return console.log(err.message);
35+
let t = convert(duration);
36+
item.duration = t.hours + ':' + t.minutes + ':' + t.seconds;
37+
console.log(item);
38+
back.send('playListSong', item);
39+
});
40+
}
41+
}
42+
}
43+
44+
back.on('getList', (dir) => {
45+
__dir = dir;
46+
buildList();
47+
});

0 commit comments

Comments
 (0)