From 47d4e1c229adfffb70b3c984d00049bcebcfc183 Mon Sep 17 00:00:00 2001 From: Aki Date: Wed, 12 Jul 2017 09:04:23 +0200 Subject: All music playing moved to single instance of MusicPlayer --- not/MusicPlayer.lua | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'not/MusicPlayer.lua') diff --git a/not/MusicPlayer.lua b/not/MusicPlayer.lua index d2a89c3..e838d96 100644 --- a/not/MusicPlayer.lua +++ b/not/MusicPlayer.lua @@ -6,12 +6,15 @@ MusicPlayer = Object:extends() function MusicPlayer:new (trackName) self.tracks = {} - self:setTrack(trackName) + if trackName then + self:setTrack(trackName) + self:play() + end end function MusicPlayer:delete () self.tracks = nil - self.source:stop() + self:stop() end function MusicPlayer:setTrack (trackName) @@ -27,7 +30,14 @@ function MusicPlayer:setTrack (trackName) self.source = source self.tracks[trackName] = source end +end + +function MusicPlayer:play () self.source:play() end +function MusicPlayer:stop () + self.source:stop() +end + return MusicPlayer -- cgit v1.1