Skip to content

Commit b34d1d3

Browse files
author
Steve Labus
committed
Added 2 new functions
getCurrentTrackElapsedSeconds(); and getCurrentTrackRemainingSeconds(); mainly because I needed them for iTunes-Discord.
1 parent 6e8aaf6 commit b34d1d3

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

itunes-bridge.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,16 @@ var exports = module.exports = {};
2929
var elapsedTimeInSeconds = applescript.sync('tell application "iTunes" to get the player position');
3030
var remainingTime = durationInSeconds - elapsedTimeInSeconds;
3131
return secToMin(remainingTime);
32-
3332
};
33+
exports.getCurrentTrackElapsedSeconds = function() {
34+
var elapsedTimeInSeconds = applescript.sync('tell application "iTunes" to get the player position');
35+
return elapsedTimeInSeconds;
36+
};
37+
exports.getCurrentTrackRemainingSeconds = function() {
38+
var durationInSeconds = applescript.sync('tell application "iTunes" to get the duration of the current track');
39+
var elapsedTimeInSeconds = applescript.sync('tell application "iTunes" to get the player position');
40+
return durationInSeconds - elapsedTimeInSeconds;
41+
};
3442
exports.getCurrentTrackReleaseYear = function() {
3543
return applescript.sync('tell application "iTunes" to get the year of the current track');
3644
};
@@ -47,4 +55,4 @@ var exports = module.exports = {};
4755
// TODO: Supports for arguments in the track count (album, artist, playlist...)
4856
exports.getTrackCount = function() {
4957
return applescript.sync('tell application "iTunes" to get the count of tracks');
50-
};
58+
};

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "itunes-bridge",
3-
"version": "0.1.6",
3+
"version": "0.1.7",
44
"description": "A NodeJS package to control and get informations from iTunes through AppleScript",
55
"main": "itunes-bridge.js",
66
"repository": {

0 commit comments

Comments
 (0)