forked from openlp/openlp
Media item for media functions basically. No previews, and no live/preview control
This commit is contained in:
parent
2b13e84c73
commit
45d9f436ab
|
@ -122,6 +122,8 @@ class MediaManagerItem(QtGui.QWidget):
|
||||||
# self.ListViewWithDnD_class - there is a base list class with DnD assigned to it (openlp.core.lib.BaseListWithDnD())
|
# self.ListViewWithDnD_class - there is a base list class with DnD assigned to it (openlp.core.lib.BaseListWithDnD())
|
||||||
# each plugin needs to inherit a class from this and pass that *class* (not an instance) to here
|
# each plugin needs to inherit a class from this and pass that *class* (not an instance) to here
|
||||||
# via the ListViewWithDnD_class member
|
# via the ListViewWithDnD_class member
|
||||||
|
# self.ServiceItemIconName - string referring to an icon file or a resource icon
|
||||||
|
|
||||||
# The assumption is that given that at least two plugins are of the form
|
# The assumption is that given that at least two plugins are of the form
|
||||||
# "text with an icon" then all this will help
|
# "text with an icon" then all this will help
|
||||||
# even for plugins of another sort, the setup of the right-click menu, common toolbar
|
# even for plugins of another sort, the setup of the right-click menu, common toolbar
|
||||||
|
@ -219,25 +221,25 @@ class MediaManagerItem(QtGui.QWidget):
|
||||||
self.parent.config.set_list(self.ConfigSection, self.ListData.getFileList())
|
self.parent.config.set_list(self.ConfigSection, self.ListData.getFileList())
|
||||||
|
|
||||||
def generateSlideData(self):
|
def generateSlideData(self):
|
||||||
assert (0, 'This fn needs to be defined by the plugin');
|
assert 0, 'This fn needs to be defined by the plugin'
|
||||||
|
|
||||||
def onPreviewClick(self):
|
def onPreviewClick(self):
|
||||||
log.debug(self.PluginTextShort+u'Preview Requested')
|
log.debug(self.PluginTextShort+u'Preview Requested')
|
||||||
service_item = ServiceItem(self.parent)
|
service_item = ServiceItem(self.parent)
|
||||||
service_item.addIcon(u':/media/media_image.png')
|
service_item.addIcon(self.ServiceItemIconName)
|
||||||
self.generateSlideData(service_item)
|
self.generateSlideData(service_item)
|
||||||
self.parent.preview_controller.addServiceItem(service_item)
|
self.parent.preview_controller.addServiceItem(service_item)
|
||||||
|
|
||||||
def onLiveClick(self):
|
def onLiveClick(self):
|
||||||
log.debug(self.PluginTextShort+u' Live Requested')
|
log.debug(self.PluginTextShort+u' Live Requested')
|
||||||
service_item = ServiceItem(self.parent)
|
service_item = ServiceItem(self.parent)
|
||||||
service_item.addIcon(u':/media/media_image.png')
|
service_item.addIcon(self.ServiceItemIconName)
|
||||||
self.generateSlideData(service_item)
|
self.generateSlideData(service_item)
|
||||||
self.parent.live_controller.addServiceItem(service_item)
|
self.parent.live_controller.addServiceItem(service_item)
|
||||||
|
|
||||||
def onAddClick(self):
|
def onAddClick(self):
|
||||||
log.debug(self.PluginTextShort+u' Add Requested')
|
log.debug(self.PluginTextShort+u' Add Requested')
|
||||||
service_item = ServiceItem(self.parent)
|
service_item = ServiceItem(self.parent)
|
||||||
service_item.addIcon(u':/media/media_image.png')
|
service_item.addIcon(self.ServiceItemIconName)
|
||||||
self.generateSlideData(service_item)
|
self.generateSlideData(service_item)
|
||||||
self.parent.service_manager.addServiceItem(service_item)
|
self.parent.service_manager.addServiceItem(service_item)
|
||||||
|
|
|
@ -49,7 +49,8 @@ class ImageMediaItem(MediaManagerItem):
|
||||||
self.OnNewFileMasks = u'Images (*.jpg *jpeg *.gif *.png *.bmp)'
|
self.OnNewFileMasks = u'Images (*.jpg *jpeg *.gif *.png *.bmp)'
|
||||||
# this next is a class, not an instance of a class - it will
|
# this next is a class, not an instance of a class - it will
|
||||||
# be instanced by the base MediaManagerItem
|
# be instanced by the base MediaManagerItem
|
||||||
self.ListViewWithDnD_class = ImageListView
|
self.ListViewWithDnD_class = ImageListView
|
||||||
|
self.ServiceItemIconName = u':/media/media_image.png'
|
||||||
MediaManagerItem.__init__(self, parent, icon, title)
|
MediaManagerItem.__init__(self, parent, icon, title)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,12 @@ from openlp.core.lib import MediaManagerItem, translate
|
||||||
|
|
||||||
from openlp.plugins.media.lib import MediaTab
|
from openlp.plugins.media.lib import MediaTab
|
||||||
from openlp.plugins.media.lib import FileListData
|
from openlp.plugins.media.lib import FileListData
|
||||||
|
# from listwithpreviews import ListWithPreviews
|
||||||
|
from openlp.core.lib import MediaManagerItem, ServiceItem, translate, BaseListWithDnD
|
||||||
|
class MediaListView(BaseListWithDnD):
|
||||||
|
def __init__(self, parent=None):
|
||||||
|
self.PluginName = u'Media'
|
||||||
|
BaseListWithDnD.__init__(self, parent)
|
||||||
|
|
||||||
class MediaMediaItem(MediaManagerItem):
|
class MediaMediaItem(MediaManagerItem):
|
||||||
"""
|
"""
|
||||||
|
@ -36,92 +42,29 @@ class MediaMediaItem(MediaManagerItem):
|
||||||
log.info(u'Media Media Item loaded')
|
log.info(u'Media Media Item loaded')
|
||||||
|
|
||||||
def __init__(self, parent, icon, title):
|
def __init__(self, parent, icon, title):
|
||||||
|
self.TranslationContext = u'MediaPlugin'
|
||||||
|
self.PluginTextShort = u'Media'
|
||||||
|
self.ConfigSection = u'images'
|
||||||
|
self.OnNewPrompt = u'Select Media(s)'
|
||||||
|
self.OnNewFileMasks = u'Videos (*.avi *.mpeg *.mpg *.mp4);;Audio (*.ogg *.mp3 *.wma);;All files (*)'
|
||||||
|
# this next is a class, not an instance of a class - it will
|
||||||
|
# be instanced by the base MediaManagerItem
|
||||||
|
self.ListViewWithDnD_class = MediaListView
|
||||||
|
self.ServiceItemIconName = u':/media/media_image.png'
|
||||||
MediaManagerItem.__init__(self, parent, icon, title)
|
MediaManagerItem.__init__(self, parent, icon, title)
|
||||||
|
|
||||||
def setupUi(self):
|
|
||||||
# Add a toolbar
|
|
||||||
self.addToolbar()
|
|
||||||
# Create buttons for the toolbar
|
|
||||||
## New Media Button ##
|
|
||||||
self.addToolbarButton(
|
|
||||||
translate(u'MediaMediaItem',u'New Media'),
|
|
||||||
translate(u'MediaMediaItem',u'Load Media into openlp.org'),
|
|
||||||
':/videos/video_load.png', self.onMediaNewClick, 'MediaNewItem')
|
|
||||||
## Delete Media Button ##
|
|
||||||
self.addToolbarButton(
|
|
||||||
translate(u'MediaMediaItem',u'Delete Media'),
|
|
||||||
translate(u'MediaMediaItem',u'Delete the selected Media item'),
|
|
||||||
':/videos/video_delete.png', self.onMediaDeleteClick, 'MediaDeleteItem')
|
|
||||||
## Separator Line ##
|
|
||||||
self.addToolbarSeparator()
|
|
||||||
## Preview Media Button ##
|
|
||||||
self.addToolbarButton(
|
|
||||||
translate(u'MediaMediaItem',u'Preview Media'),
|
|
||||||
translate(u'MediaMediaItem',u'Preview the selected Media item'),
|
|
||||||
':/system/system_preview.png', self.onMediaPreviewClick, 'MediaPreviewItem')
|
|
||||||
## Live Media Button ##
|
|
||||||
self.addToolbarButton(
|
|
||||||
translate(u'MediaMediaItem',u'Go Live'),
|
|
||||||
translate(u'MediaMediaItem',u'Send the selected Media item live'),
|
|
||||||
':/system/system_live.png', self.onMediaLiveClick, 'MediaLiveItem')
|
|
||||||
## Add Media Button ##
|
|
||||||
self.addToolbarButton(
|
|
||||||
translate(u'MediaMediaItem',u'Add Media To Service'),
|
|
||||||
translate(u'MediaMediaItem',u'Add the selected Media items(s) to the service'),
|
|
||||||
':/system/system_add.png',self.onMediaAddClick, 'MediaAddItem')
|
|
||||||
## Add the Medialist widget ##
|
|
||||||
|
|
||||||
self.MediaListView = QtGui.QListView()
|
def generateSlideData(self, service_item):
|
||||||
self.MediaListView.setAlternatingRowColors(True)
|
indexes = self.ListView.selectedIndexes()
|
||||||
self.MediaListData = FileListData()
|
service_item.title = u'Media'
|
||||||
self.MediaListView.setModel(self.MediaListData)
|
|
||||||
|
|
||||||
self.PageLayout.addWidget(self.MediaListView)
|
|
||||||
|
|
||||||
#define and add the context menu
|
|
||||||
self.MediaListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
|
|
||||||
|
|
||||||
self.MediaListView.addAction(self.contextMenuAction(
|
|
||||||
self.MediaListView, ':/system/system_preview.png',
|
|
||||||
translate(u'MediaMediaItem',u'&Preview Media'), self.onMediaPreviewClick))
|
|
||||||
self.MediaListView.addAction(self.contextMenuAction(
|
|
||||||
self.MediaListView, ':/system/system_live.png',
|
|
||||||
translate(u'MediaMediaItem',u'&Show Live'), self.onMediaLiveClick))
|
|
||||||
self.MediaListView.addAction(self.contextMenuAction(
|
|
||||||
self.MediaListView, ':/system/system_add.png',
|
|
||||||
translate(u'MediaMediaItem',u'&Add to Service'), self.onMediaAddClick))
|
|
||||||
|
|
||||||
def initialise(self):
|
|
||||||
list = self.parent.config.load_list(u'Media')
|
|
||||||
self.loadMediaList(list)
|
|
||||||
|
|
||||||
def onMediaNewClick(self):
|
|
||||||
files = QtGui.QFileDialog.getOpenFileNames(None,
|
|
||||||
translate(u'MediaMediaItem', u'Select Media(s) items'),
|
|
||||||
self.parent.config.get_last_dir(),
|
|
||||||
u'Videos (*.avi *.mpeg);;Audio (*.mp3 *.ogg *.wma);;All files (*)')
|
|
||||||
if len(files) > 0:
|
|
||||||
self.loadMediaList(files)
|
|
||||||
dir, filename = os.path.split(unicode(files[0]))
|
|
||||||
self.parent.config.set_last_dir(dir)
|
|
||||||
self.parent.config.set_list(u'media', self.MediaListData.getFileList())
|
|
||||||
|
|
||||||
def getFileList(self):
|
|
||||||
filelist = [item[0] for item in self.MediaListView];
|
|
||||||
return filelist
|
|
||||||
|
|
||||||
def loadMediaList(self, list):
|
|
||||||
for files in list:
|
|
||||||
self.MediaListData.addRow(files)
|
|
||||||
|
|
||||||
def onMediaDeleteClick(self):
|
|
||||||
indexes = self.MediaListView.selectedIndexes()
|
|
||||||
for index in indexes:
|
for index in indexes:
|
||||||
current_row = int(index.row())
|
filename = self.ListData.getFilename(index)
|
||||||
self.MediaListData.removeRow(current_row)
|
frame = QtGui.QImage(unicode(filename))
|
||||||
self.parent.config.set_list(u'media', self.MediaListData.getFileList())
|
(path, name) = os.path.split(filename)
|
||||||
|
service_item.add_from_image(path, name, frame)
|
||||||
|
|
||||||
def onMediaPreviewClick(self):
|
|
||||||
|
def onPreviewClick(self):
|
||||||
log.debug(u'Media Preview Button pressed')
|
log.debug(u'Media Preview Button pressed')
|
||||||
items = self.MediaListView.selectedIndexes()
|
items = self.MediaListView.selectedIndexes()
|
||||||
for item in items:
|
for item in items:
|
||||||
|
@ -129,7 +72,9 @@ class MediaMediaItem(MediaManagerItem):
|
||||||
print text
|
print text
|
||||||
|
|
||||||
def onMediaLiveClick(self):
|
def onMediaLiveClick(self):
|
||||||
|
log.debug(u'Media Live Button pressed')
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def onMediaAddClick(self):
|
# def onMediaAddClick(self):
|
||||||
pass
|
# log.debug(u'Media Add Button pressed')
|
||||||
|
# pass
|
||||||
|
|
|
@ -20,78 +20,6 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
import os
|
import os
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
# xxx this needs a try..except once we've decided what to do if it fails
|
|
||||||
from PyQt4.phonon import Phonon
|
|
||||||
|
|
||||||
# from openlp.core.lib import Plugin, MediaManagerItem, SettingsTab
|
|
||||||
# from openlp.plugins.media.lib import MediaTab,MediaMediaItem
|
|
||||||
|
|
||||||
"""Renders a video to some surface or other """
|
|
||||||
|
|
||||||
class w(QtGui.QMainWindow):
|
|
||||||
def __init__(self, parent=None):
|
|
||||||
super(QtGui.QMainWindow, self).__init__(parent)
|
|
||||||
self.resize(640,480)
|
|
||||||
self.setWindowTitle(u'simple media player')
|
|
||||||
self.show()
|
|
||||||
|
|
||||||
|
|
||||||
if __name__==u'__main__':
|
|
||||||
app = QtGui.QApplication([])
|
|
||||||
# widget = QtGui.QWidget()
|
|
||||||
# widget.resize(320, 240)
|
|
||||||
# widget.setWindowTitle(u'simple')
|
|
||||||
# widget.show()
|
|
||||||
# QCore.QCoreApplication.setApplicationName(u'OpenLP')
|
|
||||||
mainwindow=w()
|
|
||||||
widget=QtGui.QWidget(mainwindow)
|
|
||||||
mainwindow.setCentralWidget(widget)
|
|
||||||
widget.setLayout(QtGui.QVBoxLayout(widget))
|
|
||||||
videofile=u'synctest.24.muxed.avi'
|
|
||||||
# videofile=u'/extra_space/Download/coa360download56Kbps240x160.mpg'
|
|
||||||
source=Phonon.MediaSource(videofile)
|
|
||||||
|
|
||||||
media=Phonon.MediaObject(widget)
|
|
||||||
media.setCurrentSource(source)
|
|
||||||
|
|
||||||
video=Phonon.VideoWidget(widget)
|
|
||||||
audio=Phonon.AudioOutput(Phonon.MusicCategory)
|
|
||||||
# controller=Phonon.MediaController(media)
|
|
||||||
Phonon.createPath(media, video);
|
|
||||||
Phonon.createPath(media, audio);
|
|
||||||
# player=Phonon.VideoPlayer(Phonon.VideoCategory, widget)
|
|
||||||
slider=Phonon.SeekSlider(media, mainwindow)
|
|
||||||
widget.layout().addWidget(slider)
|
|
||||||
widget.layout().addWidget(video)
|
|
||||||
slider.show()
|
|
||||||
|
|
||||||
video.show()
|
|
||||||
media.play()
|
|
||||||
app.exec_()
|
|
||||||
|
|
||||||
=======
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
|
||||||
"""
|
|
||||||
OpenLP - Open Source Lyrics Projection
|
|
||||||
Copyright (c) 2008 Raoul Snyman
|
|
||||||
Portions copyright (c) 2008 Martin Thompson, Tim Bentley,
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it under
|
|
||||||
the terms of the GNU General Public License as published by the Free Software
|
|
||||||
Foundation; version 2 of the License.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
||||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
|
||||||
PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License along with
|
|
||||||
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
|
||||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
"""
|
|
||||||
import os
|
|
||||||
from PyQt4 import QtCore, QtGui
|
|
||||||
|
|
||||||
# xxx this needs a try, except once we've decided what to do if it fails
|
# xxx this needs a try, except once we've decided what to do if it fails
|
||||||
from PyQt4.phonon import Phonon
|
from PyQt4.phonon import Phonon
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue