forked from openlp/openlp
Add audio file support to updating songs from the service.
This commit is contained in:
parent
532ad84b87
commit
2658c94520
@ -82,6 +82,20 @@ class SongMediaItem(MediaManagerItem):
|
|||||||
self.quickPreviewAllowed = True
|
self.quickPreviewAllowed = True
|
||||||
self.hasSearch = True
|
self.hasSearch = True
|
||||||
|
|
||||||
|
def _updateBackgroundAudio(self, song, item):
|
||||||
|
song.media_files = []
|
||||||
|
for i, bga in enumerate(item.background_audio):
|
||||||
|
dest_file = os.path.join(
|
||||||
|
AppLocation.get_section_data_path(self.plugin.name),
|
||||||
|
u'audio', str(song.id), os.path.split(bga)[1])
|
||||||
|
shutil.copyfile(os.path.join(
|
||||||
|
AppLocation.get_section_data_path(
|
||||||
|
u'servicemanager'), bga),
|
||||||
|
dest_file)
|
||||||
|
song.media_files.append(MediaFile.populate(
|
||||||
|
weight=i, file_name=dest_file))
|
||||||
|
self.plugin.manager.save_object(song, True)
|
||||||
|
|
||||||
def addEndHeaderBar(self):
|
def addEndHeaderBar(self):
|
||||||
self.addToolbarSeparator()
|
self.addToolbarSeparator()
|
||||||
## Song Maintenance Button ##
|
## Song Maintenance Button ##
|
||||||
@ -517,21 +531,14 @@ class SongMediaItem(MediaManagerItem):
|
|||||||
add_song = False
|
add_song = False
|
||||||
editId = song.id
|
editId = song.id
|
||||||
break
|
break
|
||||||
|
# If there's any backing tracks, copy them over.
|
||||||
|
if len(item.background_audio) > 0:
|
||||||
|
self._updateBackgroundAudio(song, item)
|
||||||
if add_song and self.addSongFromService:
|
if add_song and self.addSongFromService:
|
||||||
song = self.openLyrics.xml_to_song(item.xml_version)
|
song = self.openLyrics.xml_to_song(item.xml_version)
|
||||||
# If there's any backing tracks, copy them over.
|
# If there's any backing tracks, copy them over.
|
||||||
if len(item.background_audio) > 0:
|
if len(item.background_audio) > 0:
|
||||||
for i, bga in enumerate(item.background_audio):
|
self._updateBackgroundAudio(song, item)
|
||||||
dest_file = os.path.join(
|
|
||||||
AppLocation.get_section_data_path(self.plugin.name),
|
|
||||||
u'audio', str(song.id), os.path.split(bga)[1])
|
|
||||||
shutil.copyfile(os.path.join(
|
|
||||||
AppLocation.get_section_data_path(
|
|
||||||
u'servicemanager'), bga),
|
|
||||||
dest_file)
|
|
||||||
song.media_files.append(MediaFile.populate(
|
|
||||||
weight=i, file_name=dest_file))
|
|
||||||
self.plugin.manager.save_object(song, True)
|
|
||||||
editId = song.id
|
editId = song.id
|
||||||
self.onSearchTextButtonClick()
|
self.onSearchTextButtonClick()
|
||||||
# Update service with correct song id.
|
# Update service with correct song id.
|
||||||
|
Loading…
Reference in New Issue
Block a user