From b74e8f712a11cf57462c51873b1cf505d90623e3 Mon Sep 17 00:00:00 2001 From: Aki Date: Sat, 9 Sep 2017 06:24:59 +0200 Subject: Shortcut to setTrack in MusicPlayer:play --- not/MusicPlayer.lua | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'not/MusicPlayer.lua') 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 -- cgit v1.1