Skip to content
Browse files

Update example app to reflect the new connect usage, update player.cl…

…j to use the global connection object.
  • Loading branch information...
1 parent 0f77b84 commit 4340934c2c9b97e74e8815cc151043010250087d Albin Stjerna committed Oct 3, 2012
Showing with 11 additions and 12 deletions.
  1. +1 −1 src/clj_mpd/core.clj
  2. +4 −3 src/clj_mpd/player.clj
  3. +6 −8 src/clj_mpd/test_app.clj
View
2 src/clj_mpd/core.clj
@@ -4,7 +4,7 @@
; which can be found in the file epl-v10.html at the root of this distribution.
; By using this software in any fashion, you are agreeing to be bound by
; the terms of this license.
- ; You must not remove this notice, or any other, from this software.
+; You must not remove this notice, or any other, from this software.
;; Large parts of this code was borrowed from monger.core, that code
;; is Copyright (c) 2011-2012 Michael S. Klishin.
View
7 src/clj_mpd/player.clj
@@ -8,12 +8,13 @@
(ns ^{:author "Jasper Lievisse Adriaanse"
:doc "Playlist related functions for clj-mpd"}
- clj-mpd.player)
+ clj-mpd.player
+ (:require clj-mpd.core))
(defn create-player
"Instantiate a MPDPlayer object"
- [mpd]
- (.getMPDPlayer mpd))
+ []
+ (.getMPDPlayer clj-mpd.core/*mpd-connection*))
(defn get-current-song
"Get current song as MPDSong"
View
14 src/clj_mpd/test_app.clj
@@ -5,20 +5,18 @@
[clj-mpd.item.song :as song]
[clj-mpd.utils :as utils]))
-(defn setup-mpd []
- (clj-mpd.core/init-mpd :hostname "localhost" :port "6600"))
-
(defn setup-player [mpd]
(player/create-player mpd))
(defn ^{:doc "Not much here, just some test code."}
-main [& args]
(do
+ (clj-mpd.core/connect! :hostname "localhost" :port "6600")
(print "Current song: ")
- (-> (setup-mpd) player/create-player player/get-current-song song/get-artist (print "- "))
- (-> (setup-mpd) player/create-player player/get-current-song song/get-title println)
+ (-> (player/create-player) player/get-current-song song/get-artist (print "- "))
+ (-> (player/create-player) player/get-current-song song/get-title println)
(print "From the album: ")
- (-> (setup-mpd) player/create-player player/get-current-song song/get-album println)
+ (-> (player/create-player) player/get-current-song song/get-album println)
(print "Time played: ")
- (-> (setup-mpd) player/create-player player/get-elapsed-time utils/format-seconds (print "/ "))
- (-> (setup-mpd) player/create-player player/get-current-song song/get-length utils/format-seconds println)))
+ (-> (player/create-player) player/get-elapsed-time utils/format-seconds (print "/ "))
+ (-> (player/create-player) player/get-current-song song/get-length utils/format-seconds println)))

0 comments on commit 4340934

Please sign in to comment.
Something went wrong with that request. Please try again.