Infrastructure compatible for all groups instead of switches.
[smartthings-infrastructure.git] / MusicPlayer / MusicPlayer.groovy
index 659476a759b61b19bf5d5a133ea1ea832938fc01..b21dbf9035f0520ae503ae0df79594de790a2c19 100644 (file)
@@ -49,6 +49,31 @@ public class MusicPlayer {
        }
 
        //methods
+       def on(LinkedHashMap metaData) {
+               on()
+       }
+       def on() {
+               if (status != "on") {
+                       println("the music player with id:$id is on!")
+                       this.status = "on"
+                       sendEvent([name: "status", value: "on", deviceId: this.id, descriptionText: "",
+                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+               }
+       }
+       def off(LinkedHashMap metaData) {
+               off()
+       }
+       def off() {
+               if (status != "off") {
+                       println("the music player with id:$id is off!")
+                       this.status = "off"
+                       sendEvent([name: "status", value: "off", deviceId: this.id, descriptionText: "",
+                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+               }
+       }
+       def mute(LinkedHashMap metaData) {
+               mute()
+       }
        def mute() {
                if (mute != "muted") {
                        println("the music player with id:$id is muted!")
@@ -57,13 +82,16 @@ public class MusicPlayer {
                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
+       def nextTrack(LinkedHashMap metaData) {
+               nextTrack()
+       }
        def nextTrack() {
                trackNumber = trackNumber+1
                def trackPlaying = trackData
                println("the $trackPlaying is selected!")
-               if (status != "playing") {
-                       this.status = "playing"
-                       sendEvent([name: "status", value: "playing", deviceId: this.id, descriptionText: "",
+               if (status != "play") {
+                       this.status = "play"
+                       sendEvent([name: "status", value: "play", deviceId: this.id, descriptionText: "",
                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
                sendEvent([name: "trackDescription", value: "someDescriptions", deviceId: this.id, descriptionText: "",
@@ -71,28 +99,37 @@ public class MusicPlayer {
                sendEvent([name: "trackData", value: "someTrack", deviceId: this.id, descriptionText: "",
                           displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
        }
+       def pause(LinkedHashMap metaData) {
+               pause()
+       }
        def pause() {
-               if (status != "paused") {
+               if (status != "pause") {
                        println("the music player with id:$id is paused!")
-                       this.status = "paused"
-                       sendEvent([name: "status", value: "paused", deviceId: this.id, descriptionText: "",
+                       this.status = "pause"
+                       sendEvent([name: "status", value: "pause", deviceId: this.id, descriptionText: "",
                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
+       def play(LinkedHashMap metaData) {
+               play()
+       }
        def play() {
-               if (status != "playing") {
+               if (status != "play") {
                        println("the music player with id:$id is starting to play!")
-                       this.status = "playing"
-                       sendEvent([name: "status", value: "playing", deviceId: this.id, descriptionText: "",
+                       this.status = "play"
+                       sendEvent([name: "status", value: "play", deviceId: this.id, descriptionText: "",
                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
+       def playTrack(LinkedHashMap metaData) {
+               playTrack()
+       }
        def playTrack(String trackToPlay) {
                def trackPlaying = trackData
                println("the $trackPlaying is selected to play!")
-               if (status != "playing") {              
-                       this.status = "playing"
-                       sendEvent([name: "status", value: "playing", deviceId: this.id, descriptionText: "",
+               if (status != "play") {         
+                       this.status = "play"
+                       sendEvent([name: "status", value: "play", deviceId: this.id, descriptionText: "",
                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
                sendEvent([name: "trackDescription", value: "someDescriptions", deviceId: this.id, descriptionText: "",
@@ -100,6 +137,9 @@ public class MusicPlayer {
                sendEvent([name: "trackData", value: "someTrack", deviceId: this.id, descriptionText: "",
                           displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
        }
+       def previousTrack(LinkedHashMap metaData) {
+               previousTrack()
+       }
        def previousTrack() {
                if (trackNumber != 1)
                        trackNumber = trackNumber-1
@@ -118,15 +158,21 @@ public class MusicPlayer {
        /*def restoreTrack(String trackToRestore) {
                musicPlayers*.restoreTrack(trackToRestore)
        }*/
+       def resumeTrack(LinkedHashMap metaData) {
+               resumeTrack()
+       }
        def resumeTrack(String trackToResume) {
                def trackPlaying = trackData
                println("the $trackPlaying is resumed!")
-               if (status != "playing") {
-                       this.status = "playing"
-                       sendEvent([name: "status", value: "playing", deviceId: this.id, descriptionText: "",
+               if (status != "play") {
+                       this.status = "play"
+                       sendEvent([name: "status", value: "play", deviceId: this.id, descriptionText: "",
                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
+       def setLevel(LinkedHashMap metaData) {
+               setLevel()
+       }
        def setLevel(int level) {
                if (level != this.level) {
                        this.level = level
@@ -135,12 +181,15 @@ public class MusicPlayer {
                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
+       def setTrack(LinkedHashMap metaData) {
+               setTrack()
+       }
        def setTrack(String trackToSet) {
                def trackPlaying = trackData
                println("the $trackPlaying is set!")
-               if (status != "playing") {
-                       this.status = "playing"
-                       sendEvent([name: "status", value: "playing", deviceId: this.id, descriptionText: "",
+               if (status != "play") {
+                       this.status = "play"
+                       sendEvent([name: "status", value: "play", deviceId: this.id, descriptionText: "",
                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
                sendEvent([name: "trackDescription", value: "someDescriptions", deviceId: this.id, descriptionText: "",
@@ -148,31 +197,37 @@ public class MusicPlayer {
                sendEvent([name: "trackData", value: "someTrack", deviceId: this.id, descriptionText: "",
                           displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
        }
+       def stop(LinkedHashMap metaData) {
+               stop()
+       }
        def stop() {
-               if (status != "stopped") {
-                       println("the music player with id:$id is stopped!")
-                       this.status = "stopped"
-                       sendEvent([name: "status", value: "stopped", deviceId: this.id, descriptionText: "",
+               if (status != "stop") {
+                       println("the music player with id:$id is stop!")
+                       this.status = "stop"
+                       sendEvent([name: "status", value: "stop", deviceId: this.id, descriptionText: "",
                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
+       def playText(LinkedHashMap metaData) {
+               playText()
+       }
        def playText(String text) {
                println("the music player with id:$id is playing the text:$text!")
-               if (status != "playing") {
-                       this.status = "playing"
-                       sendEvent([name: "status", value: "playing", deviceId: this.id, descriptionText: "",
+               if (status != "play") {
+                       this.status = "play"
+                       sendEvent([name: "status", value: "play", deviceId: this.id, descriptionText: "",
                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
 
        def currentValue(String deviceFeature) {
-               if (deviceFeature == "musicPlayer") {
+               if (deviceFeature == "playpause") {
                        return status
                }
        }
 
        def latestValue(String deviceFeature) {
-               if (deviceFeature == "musicPlayer") {
+               if (deviceFeature == "playpause") {
                        return status
                }
        }