music: add currently playing song to private list
This commit is contained in:
parent
8d87985069
commit
dce90aa872
@ -19,9 +19,9 @@ Features added since the last commit of
|
|||||||
- Exporting/importing evidence to/from a file
|
- Exporting/importing evidence to/from a file
|
||||||
- Timers
|
- Timers
|
||||||
- Slide animations (work in progress)
|
- Slide animations (work in progress)
|
||||||
- Compatiblity with AO2 themes (pre-2.11, work in progress)
|
- Compatiblity with AO2 themes (pre-2.11, work in progress but mostly working)
|
||||||
- Player, area, and background lists
|
- Player, area, and background lists
|
||||||
- Search boxes on music list and character select
|
- Search boxes on music list, background list and character select
|
||||||
- Join a server automatically on launch
|
- Join a server automatically on launch
|
||||||
- Pick a character and join an area automatically on join
|
- Pick a character and join an area automatically on join
|
||||||
- Demo recording and playback with a seekbar, no need to send messages to OOC
|
- Demo recording and playback with a seekbar, no need to send messages to OOC
|
||||||
|
|||||||
48
gameview.py
48
gameview.py
@ -110,7 +110,7 @@ def mockString(text):
|
|||||||
|
|
||||||
class MusicDownloadThread(QtCore.QThread):
|
class MusicDownloadThread(QtCore.QThread):
|
||||||
# Part of the evil HTTPS music download hack for XP systems
|
# Part of the evil HTTPS music download hack for XP systems
|
||||||
finished_signal = QtCore.pyqtSignal(int)
|
finished_signal = QtCore.pyqtSignal(int, str)
|
||||||
|
|
||||||
def __init__(self, caller, url):
|
def __init__(self, caller, url):
|
||||||
super(MusicDownloadThread, self).__init__()
|
super(MusicDownloadThread, self).__init__()
|
||||||
@ -169,7 +169,7 @@ class MusicDownloadThread(QtCore.QThread):
|
|||||||
|
|
||||||
if not self.exiting:
|
if not self.exiting:
|
||||||
self.caller.stream = create_string_buffer(stream)
|
self.caller.stream = create_string_buffer(stream)
|
||||||
self.finished_signal.emit(file_length)
|
self.finished_signal.emit(file_length, self.url)
|
||||||
else:
|
else:
|
||||||
print "[audio] Stream is empty, aborting..."
|
print "[audio] Stream is empty, aborting..."
|
||||||
self.quit()
|
self.quit()
|
||||||
@ -1386,6 +1386,9 @@ class GUI(QtGui.QWidget):
|
|||||||
self.actMusicCopy = QtGui.QAction(QtGui.QIcon(AO2XPpath + "icons/" + "page_copy.png"), "&Copy selected song name", self.tabMusic)
|
self.actMusicCopy = QtGui.QAction(QtGui.QIcon(AO2XPpath + "icons/" + "page_copy.png"), "&Copy selected song name", self.tabMusic)
|
||||||
self.actMusicCopy.triggered.connect(self.onActMusicCopyTriggered)
|
self.actMusicCopy.triggered.connect(self.onActMusicCopyTriggered)
|
||||||
self.actMusicCopy.setDisabled(True)
|
self.actMusicCopy.setDisabled(True)
|
||||||
|
self.actMusicAddCurrent = QtGui.QAction(QtGui.QIcon(AO2XPpath + "icons/" + "add.png"), "Add current song to private list", self.tabMusic)
|
||||||
|
self.actMusicAddCurrent.triggered.connect(self.onActMusicAddCurrentTriggered)
|
||||||
|
self.actMusicAddCurrent.setDisabled(True)
|
||||||
self.actMusicSeparator = QtGui.QAction(self.tabMusic)
|
self.actMusicSeparator = QtGui.QAction(self.tabMusic)
|
||||||
self.actMusicSeparator.setSeparator(True)
|
self.actMusicSeparator.setSeparator(True)
|
||||||
self.actMusicAdd = QtGui.QAction(QtGui.QIcon(AO2XPpath + "icons/" + "add.png"), "&Add new entry", self.tabMusic)
|
self.actMusicAdd = QtGui.QAction(QtGui.QIcon(AO2XPpath + "icons/" + "add.png"), "&Add new entry", self.tabMusic)
|
||||||
@ -1413,6 +1416,7 @@ class GUI(QtGui.QWidget):
|
|||||||
self.mnuMusicOptions = QtGui.QMenu(self.tabMusic)
|
self.mnuMusicOptions = QtGui.QMenu(self.tabMusic)
|
||||||
self.mnuMusicOptions.addAction(self.actMusicRandom)
|
self.mnuMusicOptions.addAction(self.actMusicRandom)
|
||||||
self.mnuMusicOptions.addAction(self.actMusicCopy)
|
self.mnuMusicOptions.addAction(self.actMusicCopy)
|
||||||
|
self.mnuMusicOptions.addAction(self.actMusicAddCurrent)
|
||||||
self.mnuMusicOptions.addAction(self.actMusicSeparator)
|
self.mnuMusicOptions.addAction(self.actMusicSeparator)
|
||||||
self.mnuMusicOptions.addAction(self.actMusicAdd)
|
self.mnuMusicOptions.addAction(self.actMusicAdd)
|
||||||
self.mnuMusicOptions.addAction(self.actMusicEdit)
|
self.mnuMusicOptions.addAction(self.actMusicEdit)
|
||||||
@ -1717,6 +1721,7 @@ class GUI(QtGui.QWidget):
|
|||||||
self.demoPlaying = False
|
self.demoPlaying = False
|
||||||
self.musicList = {}
|
self.musicList = {}
|
||||||
self.pickedMusicItem = False
|
self.pickedMusicItem = False
|
||||||
|
self.currentMusicURL = None
|
||||||
|
|
||||||
self.slideEnabled = getOption("General", "slide", False) == 'True'
|
self.slideEnabled = getOption("General", "slide", False) == 'True'
|
||||||
self.slideAvailable = False
|
self.slideAvailable = False
|
||||||
@ -2339,6 +2344,14 @@ class GUI(QtGui.QWidget):
|
|||||||
with open(AO2XPpath + "music.ini", "ab") as f:
|
with open(AO2XPpath + "music.ini", "ab") as f:
|
||||||
f.write(("\n" + title + " = " + url).toUtf8())
|
f.write(("\n" + title + " = " + url).toUtf8())
|
||||||
self.onActMusicRefreshTriggered()
|
self.onActMusicRefreshTriggered()
|
||||||
|
|
||||||
|
def onActMusicAddCurrentTriggered(self):
|
||||||
|
title, ok = QtGui.QInputDialog.getText(self, "Add currently playing song", "Please enter a title for the song.")
|
||||||
|
if title and ok:
|
||||||
|
with open(AO2XPpath + "music.ini", "ab") as f:
|
||||||
|
f.write(("\n" + title + " = " + self.currentMusicURL).toUtf8())
|
||||||
|
if self.privateMusicSelected:
|
||||||
|
self.onActMusicRefreshTriggered()
|
||||||
|
|
||||||
def onActMusicEditTriggered(self):
|
def onActMusicEditTriggered(self):
|
||||||
pass
|
pass
|
||||||
@ -2988,6 +3001,7 @@ class GUI(QtGui.QWidget):
|
|||||||
self.OOCLogin.setText("Lo&gin")
|
self.OOCLogin.setText("Lo&gin")
|
||||||
self.login = False
|
self.login = False
|
||||||
self.privateInventorySelected = False
|
self.privateInventorySelected = False
|
||||||
|
self.setCurrentMusicURL(None)
|
||||||
if self.tcp:
|
if self.tcp:
|
||||||
self.tcp.close()
|
self.tcp.close()
|
||||||
if self.demoPlayer:
|
if self.demoPlayer:
|
||||||
@ -4254,6 +4268,7 @@ class GUI(QtGui.QWidget):
|
|||||||
def playMusic(self, mus):
|
def playMusic(self, mus):
|
||||||
self.stopMusic()
|
self.stopMusic()
|
||||||
if mus == "~stop.mp3" or not mus:
|
if mus == "~stop.mp3" or not mus:
|
||||||
|
self.setCurrentMusicURL(None)
|
||||||
return
|
return
|
||||||
|
|
||||||
_musicList = self.musicListPrivate if self.privateMusicSelected else self.musicList
|
_musicList = self.musicListPrivate if self.privateMusicSelected else self.musicList
|
||||||
@ -4289,6 +4304,7 @@ class GUI(QtGui.QWidget):
|
|||||||
if self.music:
|
if self.music:
|
||||||
audio.setHandleAttr(self.music, BASS_ATTRIB_VOL, self.sliMusicVolume.value() / 100.0)
|
audio.setHandleAttr(self.music, BASS_ATTRIB_VOL, self.sliMusicVolume.value() / 100.0)
|
||||||
audio.playHandle(self.music, True)
|
audio.playHandle(self.music, True)
|
||||||
|
self.setCurrentMusicURL(mus)
|
||||||
if self.sliMusicVolume.value() == 0:
|
if self.sliMusicVolume.value() == 0:
|
||||||
audio.pauseHandle(self.music)
|
audio.pauseHandle(self.music)
|
||||||
else:
|
else:
|
||||||
@ -4308,20 +4324,23 @@ class GUI(QtGui.QWidget):
|
|||||||
if self.music:
|
if self.music:
|
||||||
audio.setHandleAttr(self.music, BASS_ATTRIB_VOL, self.sliMusicVolume.value() / 100.0)
|
audio.setHandleAttr(self.music, BASS_ATTRIB_VOL, self.sliMusicVolume.value() / 100.0)
|
||||||
audio.playHandle(self.music, True)
|
audio.playHandle(self.music, True)
|
||||||
|
self.setCurrentMusicURL(mus)
|
||||||
if self.sliMusicVolume.value() == 0:
|
if self.sliMusicVolume.value() == 0:
|
||||||
audio.pauseHandle(self.music)
|
audio.pauseHandle(self.music)
|
||||||
else:
|
else:
|
||||||
|
# Evil HTTPS hack for XP systems
|
||||||
error = audio.getBassError()
|
error = audio.getBassError()
|
||||||
#print "[audio] Couldn't play music. Error", error
|
|
||||||
# Here comes the evil HTTPS hack for XP systems, but it also allows us to download and play modules, because, why not?
|
|
||||||
musext = os.path.splitext(basename(musl))[-1]
|
musext = os.path.splitext(basename(musl))[-1]
|
||||||
if musext in ['.xm', '.mod', '.mo3', '.it', '.s3m', '.mtm', '.umx']:
|
if musext in ['.xm', '.mod', '.mo3', '.it', '.s3m', '.mtm', '.umx']:
|
||||||
|
# BASS can play modules, so might as well support them
|
||||||
self.specialStream = True
|
self.specialStream = True
|
||||||
if (musl.startswith("https") and error == 2) or self.specialStream:
|
if (musl.startswith("https") and error == 2) or self.specialStream:
|
||||||
print "[audio] Downloading music with urllib2"
|
print "[audio] Downloading music with urllib2"
|
||||||
self.downloadThread = MusicDownloadThread(self, mus.replace(" ", "%20"))
|
self.downloadThread = MusicDownloadThread(self, mus.replace(" ", "%20"))
|
||||||
self.downloadThread.finished_signal.connect(self.playDownloadedMusic)
|
self.downloadThread.finished_signal.connect(self.playDownloadedMusic)
|
||||||
self.downloadThread.start()
|
self.downloadThread.start()
|
||||||
|
else:
|
||||||
|
print "[audio] Couldn't play music. Error", error
|
||||||
|
|
||||||
def stopMusic(self):
|
def stopMusic(self):
|
||||||
if self.music:
|
if self.music:
|
||||||
@ -4337,20 +4356,27 @@ class GUI(QtGui.QWidget):
|
|||||||
|
|
||||||
if self.downloadThread:
|
if self.downloadThread:
|
||||||
self.downloadThread.stop()
|
self.downloadThread.stop()
|
||||||
#self.downloadThread.wait()
|
|
||||||
self.downloadThread = None
|
self.downloadThread = None
|
||||||
|
|
||||||
def playDownloadedMusic(self, file_length):
|
def playDownloadedMusic(self, file_length, url):
|
||||||
# Part of the evil HTTPS music download hack for XP systems
|
# Part of the evil HTTPS music download hack for XP systems
|
||||||
print "[audio] Done downloading; playing stream"
|
|
||||||
if self.specialStream:
|
if self.specialStream:
|
||||||
self.music = audio.loadMOD(True, self.stream, 0, file_length, BASS_SAMPLE_LOOP)
|
self.music = audio.loadMOD(True, self.stream, 0, file_length, BASS_SAMPLE_LOOP)
|
||||||
else:
|
else:
|
||||||
self.music = audio.loadHandle(True, self.stream, 0, file_length, BASS_SAMPLE_LOOP)
|
self.music = audio.loadHandle(True, self.stream, 0, file_length, BASS_SAMPLE_LOOP)
|
||||||
audio.setHandleAttr(self.music, BASS_ATTRIB_VOL, self.sliMusicVolume.value() / 100.0)
|
if self.music:
|
||||||
audio.playHandle(self.music, True)
|
print "[audio] Done downloading; playing stream"
|
||||||
if self.sliMusicVolume.value() == 0:
|
audio.setHandleAttr(self.music, BASS_ATTRIB_VOL, self.sliMusicVolume.value() / 100.0)
|
||||||
audio.pauseHandle(self.music)
|
audio.playHandle(self.music, True)
|
||||||
|
self.setCurrentMusicURL(url)
|
||||||
|
if self.sliMusicVolume.value() == 0:
|
||||||
|
audio.pauseHandle(self.music)
|
||||||
|
else:
|
||||||
|
print "[audio] Done downloading, but the stream couldn't be played. Error", audio.getBassError()
|
||||||
|
|
||||||
|
def setCurrentMusicURL(self, url):
|
||||||
|
self.currentMusicURL = url
|
||||||
|
self.actMusicAddCurrent.setDisabled(url is None)
|
||||||
|
|
||||||
def loadAllMusic(self):
|
def loadAllMusic(self):
|
||||||
_musicList = self.musicListPrivate if self.privateMusicSelected else self.musicList
|
_musicList = self.musicListPrivate if self.privateMusicSelected else self.musicList
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user