summaryrefslogtreecommitdiffhomepage
path: root/not/MusicPlayer.lua
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2017-09-21 21:05:37 +0200
committerAki <nthirtyone@gmail.com>2017-09-21 21:05:37 +0200
commite9a450d65d4fb564691cdf651ef5771dd88303ae (patch)
treef49d29582dd6877f3b3c807c3f7d9d92d368f798 /not/MusicPlayer.lua
parenteb8302723cd85adca0fbaf505cfb315f1db0299a (diff)
parentb97985def64b8bd8f93a7b391b12333595432e52 (diff)
downloadroflnauts-e9a450d65d4fb564691cdf651ef5771dd88303ae.zip
roflnauts-e9a450d65d4fb564691cdf651ef5771dd88303ae.tar.gz
roflnauts-e9a450d65d4fb564691cdf651ef5771dd88303ae.tar.bz2
Merge branch 'maps'
Diffstat (limited to 'not/MusicPlayer.lua')
-rw-r--r--not/MusicPlayer.lua15
1 files changed, 8 insertions, 7 deletions
diff --git a/not/MusicPlayer.lua b/not/MusicPlayer.lua
index 4634ed9..17beda4 100644
--- a/not/MusicPlayer.lua
+++ b/not/MusicPlayer.lua
@@ -1,8 +1,5 @@
-require "not.Object"
-
---- `MusicPlayer`
--- Simple music player object that plays and loops selected track.
-MusicPlayer = Object:extends()
+--- Simple music player object that stores, playes and loops tracks..
+MusicPlayer = require "not.Object":extends()
function MusicPlayer:new (trackName)
self.tracks = {}
@@ -13,8 +10,9 @@ function MusicPlayer:new (trackName)
end
function MusicPlayer:delete ()
- self.tracks = nil
self:stop()
+ self.tracks = nil
+ self.source = nil
end
function MusicPlayer:setTrack (trackName)
@@ -40,7 +38,10 @@ function MusicPlayer:getCurrentTrack ()
end
end
-function MusicPlayer:play ()
+function MusicPlayer:play (trackName)
+ if trackName then
+ self:setTrack(trackName)
+ end
self.source:play()
end