Skip to content

Commit

Permalink
Migrate to dbus-next
Browse files Browse the repository at this point in the history
Migration to dbus-next (a fork of dbus-native) is a rewrite, but fixes
some outstanding bugs in the project related to variant types.

The project is now transpiled to use the experimental decorator feature
that will be available in the language at some later time. gulpfile.js
contains build instructions. Build with `npm run build`. The dist/
folder contains what will be published on npm.

Interfaces are implemented as classes with decorators specifying the
properties of the member that is exported on the bus.

Update examples and add a new tracklist example.

Other bugfixes may have been a side effect of the rewrite.

fixes dbusjs#1
fixes dbusjs#6
fixes dbusjs#13
  • Loading branch information
Tony Crisci committed Nov 8, 2018
1 parent 1c44ad3 commit 4993dea
Show file tree
Hide file tree
Showing 17 changed files with 854 additions and 582 deletions.
6 changes: 6 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"plugins": [
[ "@babel/plugin-proposal-decorators", { "decoratorsBeforeExport": true, "legacy": false } ],
"@babel/plugin-proposal-class-properties"
]
}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/dist
/package-lock.json
/yarn.lock
*.swp

# Logs
logs
*.log
Expand Down
Empty file added .npmignore
Empty file.
5 changes: 5 additions & 0 deletions .tern-project
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"plugins": {
"node": {}
}
}
12 changes: 8 additions & 4 deletions examples/player.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var Player = require('..');
var Player = require('../dist');

var player = Player({
name: 'nodejs',
Expand All @@ -9,7 +9,7 @@ var player = Player({
});

// Events
var events = ['raise', 'quit', 'next', 'previous', 'pause', 'playpause', 'stop', 'play', 'seek', 'position', 'open', 'volume'];
var events = ['raise', 'quit', 'next', 'previous', 'pause', 'playpause', 'stop', 'play', 'seek', 'position', 'open', 'volume', 'loopStatus', 'shuffle'];
events.forEach(function (eventName) {
player.on(eventName, function () {
console.log('Event:', eventName, arguments);
Expand All @@ -28,10 +28,14 @@ setTimeout(function () {
'mpris:artUrl': 'http://www.adele.tv/images/facebook/adele.jpg',
'xesam:title': 'Lolol',
'xesam:album': '21',
'xesam:artist': 'Adele'
'xesam:artist': ['Adele']
};

player.playbackStatus = 'Playing';

console.log('Now playing: Lolol - Adele - 21');
}, 3000);
}, 1000);

setTimeout(() => {
player.seeked(0);
}, 2000);
4 changes: 2 additions & 2 deletions examples/playlists.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var player = Player({
identity: 'Node.js media player',
supportedUriSchemes: ['file'],
supportedMimeTypes: ['audio/mpeg', 'application/ogg'],
supportedInterfaces: ['player', 'playlists']
supportedInterfaces: ['playlists']
});

player.on('quit', function () {
Expand Down Expand Up @@ -38,4 +38,4 @@ player.setPlaylists([
Name: 'The coolest playlist',
Icon: ''
}
]);
]);
36 changes: 36 additions & 0 deletions examples/tracklist.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
var Player = require('../dist');

var player = Player({
name: 'nodejs',
identity: 'Node.js media player',
supportedUriSchemes: ['file'],
supportedMimeTypes: ['audio/mpeg', 'application/ogg'],
supportedInterfaces: ['trackList']
});

// Events
var events = ['addTrack', 'removeTrack', 'goTo'];
events.forEach(function (eventName) {
player.on(eventName, function () {
console.log('Event:', eventName, arguments);
});
});

player.tracks = [
{
'mpris:trackid': player.objectPath('track/0'),
'mpris:length': 60 * 1000 * 1000,
'mpris:artUrl': 'http://www.adele.tv/images/facebook/adele.jpg',
'xesam:title': 'Lolol',
'xesam:album': '21',
'xesam:artist': 'Adele'
},
{
'mpris:trackid': player.objectPath('track/1'),
'mpris:length': 60 * 1000 * 1000,
'mpris:artUrl': 'file:///home/emersion/anime/waifu.jpg',
'xesam:title': 'Shake It Off',
'xesam:album': '21',
'xesam:artist': 'Taylor Swift'
}
];
19 changes: 19 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const gulp = require('gulp');
const babel = require('gulp-babel');
const sourcemaps = require('gulp-sourcemaps');
var path = require('path');

function handleError(error) {
console.log(error.toString());
this.emit('end');
process.exit(1);
}

gulp.task('default', () =>
gulp.src('src/**/*.js')
.pipe(sourcemaps.init())
.pipe(babel())
.on('error', handleError)
.pipe(sourcemaps.write('.', { sourceRoot: path.join('../src/') }))
.pipe(gulp.dest('dist'))
);
Loading

0 comments on commit 4993dea

Please sign in to comment.