MediaPlayer - fix, improve
Reload Sound system only if media already playing. and also stop sound after relog/reload
This commit is contained in:
+6
-1
@@ -12407,12 +12407,13 @@ function LeaPlusLC:FriendCheck(name)
|
|||||||
|
|
||||||
-- Store currently playing track number
|
-- Store currently playing track number
|
||||||
local tracknumber = 1
|
local tracknumber = 1
|
||||||
|
local isPlayingTrack = 0
|
||||||
|
|
||||||
-- Function to play a track and show the static highlight bar
|
-- Function to play a track and show the static highlight bar
|
||||||
local function PlayTrack()
|
local function PlayTrack()
|
||||||
-- Play tracks
|
-- Play tracks
|
||||||
-- if musicHandle then StopSound(musicHandle) end
|
-- if musicHandle then StopSound(musicHandle) end
|
||||||
Sound_GameSystem_RestartSoundSystem()
|
if isPlayingTrack == 1 then Sound_GameSystem_RestartSoundSystem() end
|
||||||
-- Sound_GameSystem_RestartSoundSystem()
|
-- Sound_GameSystem_RestartSoundSystem()
|
||||||
local file, soundID, trackTime
|
local file, soundID, trackTime
|
||||||
if strfind(playlist[tracknumber], "#") then
|
if strfind(playlist[tracknumber], "#") then
|
||||||
@@ -12428,10 +12429,12 @@ function LeaPlusLC:FriendCheck(name)
|
|||||||
cleanFile = "sound/music/" .. cleanFile
|
cleanFile = "sound/music/" .. cleanFile
|
||||||
end
|
end
|
||||||
willPlay, musicHandle = PlaySoundFile(cleanFile, "Master", false, true)
|
willPlay, musicHandle = PlaySoundFile(cleanFile, "Master", false, true)
|
||||||
|
isPlayingTrack = 1
|
||||||
else
|
else
|
||||||
-- Sound kit without track time
|
-- Sound kit without track time
|
||||||
file, soundID = playlist[tracknumber]:match("([^,]+)%#([^,]+)")
|
file, soundID = playlist[tracknumber]:match("([^,]+)%#([^,]+)")
|
||||||
willPlay, musicHandle = PlaySound(soundID, "Master", false, true)
|
willPlay, musicHandle = PlaySound(soundID, "Master", false, true)
|
||||||
|
isPlayingTrack = 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- Cancel existing music timer for a sound file
|
-- Cancel existing music timer for a sound file
|
||||||
@@ -12446,6 +12449,7 @@ function LeaPlusLC:FriendCheck(name)
|
|||||||
tracknumber = 1
|
tracknumber = 1
|
||||||
end
|
end
|
||||||
PlayTrack()
|
PlayTrack()
|
||||||
|
isPlayingTrack = 1
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -12832,6 +12836,7 @@ function LeaPlusLC:FriendCheck(name)
|
|||||||
LeaPlusLC["Page9"]:SetScript("OnEvent", function(self, event)
|
LeaPlusLC["Page9"]:SetScript("OnEvent", function(self, event)
|
||||||
if event == "PLAYER_LOGOUT" then
|
if event == "PLAYER_LOGOUT" then
|
||||||
-- Stop playing at reload or logout
|
-- Stop playing at reload or logout
|
||||||
|
if isPlayingTrack == 1 then Sound_GameSystem_RestartSoundSystem() end
|
||||||
if musicHandle then
|
if musicHandle then
|
||||||
StopSound(musicHandle)
|
StopSound(musicHandle)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user