Skip to content

Instantly share code, notes, and snippets.

@ytkhs
Last active September 6, 2015 05:36
Show Gist options
  • Save ytkhs/c201b44a95b0ffab6500 to your computer and use it in GitHub Desktop.
Save ytkhs/c201b44a95b0ffab6500 to your computer and use it in GitHub Desktop.
javascript(JAX)でiTunesの曲をランダムに一曲取得して通知に渡してみる
var app = Application.currentApplication(),
iTunes = Application('iTunes');
app.includeStandardAdditions = true;
var allTracks = iTunes.playlists[0].tracks();
var randomTrack = allTracks[Math.floor(Math.random() * allTracks.length)];
app.displayNotification(randomTrack.artist(), {
withTitle: randomTrack.name(),
subtitle: randomTrack.album(),
soundName: 'Glass'
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment