openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #24178
[Merge] lp:~tomasgroth/openlp/dvd into lp:openlp
Tomas Groth has proposed merging lp:~tomasgroth/openlp/dvd into lp:openlp.
Requested reviews:
Samuel Mehrbrodt (sam92)
Tim Bentley (trb143)
For more details, see:
https://code.launchpad.net/~tomasgroth/openlp/dvd/+merge/233117
Support for optical devices using VLC. It is possible to select a specific clip to play.
--
https://code.launchpad.net/~tomasgroth/openlp/dvd/+merge/233117
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/lib/serviceitem.py'
--- openlp/core/lib/serviceitem.py 2014-04-14 18:28:04 +0000
+++ openlp/core/lib/serviceitem.py 2014-09-02 20:29:54 +0000
@@ -111,6 +111,9 @@
``CanEditTitle``
The capability to edit the title of the item
+ ``IsOptical``
+ .Determines is the service_item is based on an optical device
+
"""
CanPreview = 1
CanEdit = 2
@@ -129,6 +132,7 @@
HasBackgroundAudio = 15
CanAutoStartForLive = 16
CanEditTitle = 17
+ IsOptical = 18
class ServiceItem(RegistryProperties):
@@ -416,7 +420,10 @@
for text_image in service_item['serviceitem']['data']:
if not self.title:
self.title = text_image['title']
- if path:
+ if self.is_capable(ItemCapabilities.IsOptical):
+ self.has_original_files = False
+ self.add_from_command(text_image['path'], text_image['title'], text_image['image'])
+ elif path:
self.has_original_files = False
self.add_from_command(path, text_image['title'], text_image['image'])
else:
@@ -427,7 +434,8 @@
"""
Returns the title of the service item.
"""
- if self.is_text() or ItemCapabilities.CanEditTitle in self.capabilities:
+ if self.is_text() or self.is_capable(ItemCapabilities.IsOptical) \
+ or self.is_capable(ItemCapabilities.CanEditTitle):
return self.title
else:
if len(self._raw_frames) > 1:
@@ -495,7 +503,8 @@
"""
Confirms if the ServiceItem uses a file
"""
- return self.service_item_type == ServiceItemType.Image or self.service_item_type == ServiceItemType.Command
+ return self.service_item_type == ServiceItemType.Image or \
+ (self.service_item_type == ServiceItemType.Command and not self.is_capable(ItemCapabilities.IsOptical))
def is_text(self):
"""
@@ -553,7 +562,7 @@
frame = self._raw_frames[row]
except IndexError:
return ''
- if self.is_image():
+ if self.is_image() or self.is_capable(ItemCapabilities.IsOptical):
path_from = frame['path']
else:
path_from = os.path.join(frame['path'], frame['title'])
@@ -623,12 +632,17 @@
self.is_valid = False
break
elif self.is_command():
- file_name = os.path.join(frame['path'], frame['title'])
- if not os.path.exists(file_name):
- self.is_valid = False
- break
- if suffix_list and not self.is_text():
- file_suffix = frame['title'].split('.')[-1]
- if file_suffix.lower() not in suffix_list:
- self.is_valid = False
- break
+ if self.is_capable(ItemCapabilities.IsOptical):
+ if not os.path.exists(frame['title']):
+ self.is_valid = False
+ break
+ else:
+ file_name = os.path.join(frame['path'], frame['title'])
+ if not os.path.exists(file_name):
+ self.is_valid = False
+ break
+ if suffix_list and not self.is_text():
+ file_suffix = frame['title'].split('.')[-1]
+ if file_suffix.lower() not in suffix_list:
+ self.is_valid = False
+ break
=== modified file 'openlp/core/resources.py'
--- openlp/core/resources.py 2014-04-14 18:09:47 +0000
+++ openlp/core/resources.py 2014-09-02 20:29:54 +0000
@@ -73607,6 +73607,137 @@
\x46\xcb\x9f\xb1\x4a\xaf\x5a\x86\xbd\x7e\x59\x83\xc3\x25\x6a\xcb\
\xbf\x68\x8f\x97\x4b\x7c\x2c\x00\xfc\x06\xe5\x56\x32\x1a\xa3\x07\
\xf0\xd8\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\
+\x00\x00\x08\x08\
+\x89\
+\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
+\x00\x00\x20\x00\x00\x00\x20\x08\x06\x00\x00\x00\x73\x7a\x7a\xf4\
+\x00\x00\x00\x01\x73\x52\x47\x42\x00\xae\xce\x1c\xe9\x00\x00\x00\
+\x09\x70\x48\x59\x73\x00\x00\x06\xec\x00\x00\x06\xec\x01\x1e\x75\
+\x38\x35\x00\x00\x00\x07\x74\x49\x4d\x45\x07\xd9\x05\x07\x11\x2e\
+\x10\xa7\x86\x80\x81\x00\x00\x00\x06\x62\x4b\x47\x44\x00\xff\x00\
+\xff\x00\xff\xa0\xbd\xa7\x93\x00\x00\x07\x88\x49\x44\x41\x54\x78\
+\xda\xd5\x96\x59\x6f\x1b\xe7\x15\x86\xf9\x13\x7a\x97\x7f\xd0\xde\
+\x15\x2d\xda\x04\xbd\x29\x72\xd3\xab\x22\x40\xda\x5e\x14\x68\x2f\
+\x8b\xc2\x41\x51\xa4\x80\x51\x74\x85\x9d\x08\xb1\x55\x3b\x76\x6c\
+\x59\x4a\xac\x46\xb2\x2c\x6f\xb2\xac\xcd\xd6\x2e\x8a\xab\xc8\x21\
+\x87\xe2\x3a\xdc\x86\xc3\xe1\x70\x27\x45\x8a\x14\x29\x89\xa2\x44\
+\x59\x9b\xe7\xed\xf9\x14\x57\xb4\x22\x59\x96\x9a\xf6\xa2\x1f\x70\
+\x30\xc4\x70\x66\x9e\xf7\x3b\xe7\xbc\x67\x46\xf3\x7f\xb1\x7e\x7d\
+\xfe\x9d\xfd\xe3\x8d\xce\xbb\x6f\x3d\xe8\x1b\x39\x3f\xad\xe5\x46\
+\x0d\x46\x87\x8f\xb3\x79\x4b\xbc\x43\x28\xd9\xec\x5e\x1f\x67\xf7\
+\x8c\x8e\x4e\xe8\xce\xdf\xe9\x7b\xfc\x16\xbb\xf6\x37\x2d\x6d\xdf\
+\x1c\xfc\xcf\xee\xc1\xaf\x8e\x3d\xfd\xbf\x9c\x9a\xe1\x72\x9c\xcd\
+\x07\x51\x4c\x41\x12\x33\x6a\x34\x9a\x45\x2c\x96\x43\x32\xb9\x80\
+\x4c\xa6\x88\x85\x85\x8a\x5a\x2a\xad\x20\x9e\xc8\xd2\x35\xf2\xc2\
+\x8c\xde\xfc\x2b\x76\xaf\xce\x68\xfd\xcf\x05\x7c\xda\x71\xff\x7b\
+\x23\xa3\xe6\x94\xd3\x15\x85\x5f\x88\xa9\xc1\x60\x1c\xe1\x30\x09\
+\x90\x32\xfb\xf0\x44\x62\x01\xe9\x74\x11\xb9\x5c\x19\x85\x42\x05\
+\x8b\x8b\x55\x54\x2a\xab\x58\x5d\x5d\x57\xeb\xf5\x06\xa4\x68\x3c\
+\x33\x31\xad\xfb\xfe\x99\xa0\x00\xf6\x8f\xb7\x7b\x87\xcf\x8d\x68\
+\xfd\xe0\x9d\x31\xd5\xed\x55\xe0\x0f\xbc\x09\xbe\x8c\xa5\xa5\x15\
+\xac\xac\xd4\xb1\xb6\xd6\xc0\xc6\xc6\x26\xb6\xb7\x77\xd4\xd5\xd5\
+\x1a\x6c\xbc\xf3\x03\xf6\xcc\x96\x96\x96\xd3\x89\x78\x32\x72\xef\
+\xb6\xd3\x65\x83\xc1\x2e\xa9\x06\x7b\x1c\x1e\x21\x81\x40\x90\xc1\
+\xd3\x27\xc0\x57\x09\xbe\xf6\x12\xfe\x1c\xcf\x9f\x6f\x33\x01\x78\
+\xf1\xe2\x85\xba\xbb\xbb\x0b\xb7\x4f\xf8\xe2\x54\xf0\xbe\x81\xee\
+\x0f\x3d\x5e\x03\xed\xd8\x0a\x21\xe0\x81\x69\x5e\x81\xcd\x9b\x46\
+\x48\xcc\x22\x2a\xbf\x1e\xbe\xbc\xcc\xe0\x1b\x87\xe0\x7b\x7b\x7b\
+\x4c\x00\x98\x80\xcd\xcd\x2d\x58\x6c\xfc\xef\x5f\x0b\xbe\xf7\x60\
+\x50\xf3\xb8\xf7\xd6\x8f\x5c\xce\xa7\x08\x06\x8d\x6a\x48\xb4\x40\
+\x8c\xf0\x08\x8a\x01\x58\x48\x80\x20\xe6\x10\x55\x5e\x0f\xaf\xd5\
+\xd6\x0f\xe0\x3b\x3b\xbb\x87\xe0\x5b\x5b\x3b\x74\x7e\x4b\xad\x54\
+\x96\x31\xab\x37\xbf\xc3\xcd\xbb\x8e\x17\x31\xd7\x3f\x56\x91\x78\
+\xbd\x2a\x05\x67\x10\x8d\x98\x20\xcb\x76\xc4\x14\x37\x44\x59\x82\
+\x3d\x90\x87\x9c\x28\x22\x9d\x3d\x0e\xbe\x81\xf5\xf5\x4d\x06\x61\
+\x70\x82\x1e\x82\xd3\xee\x9f\xd3\xff\x0d\xd4\xd7\x36\xd4\x98\x92\
+\xa8\x1c\x0b\x7f\xd4\xfd\xf0\xb7\x21\xce\x83\xa8\xd9\x05\x85\xe3\
+\x10\x0f\x1a\x90\x50\xcc\x64\x33\x07\x52\x69\x1f\xa4\xb8\x02\x5f\
+\x74\x11\xe9\xdc\x12\xeb\xf6\x97\x35\x3f\x09\xbe\x47\xf0\xed\x57\
+\xe0\xeb\xe4\x8e\xfa\xbe\x60\x0b\xc7\x7f\x70\x44\x80\x71\x5c\x5f\
+\x13\x1d\x82\x1a\x99\x17\xa0\x38\x04\xa4\xec\x6e\x64\x03\x1c\xb2\
+\x49\x0b\xa5\xdc\x45\x3e\x0f\x22\x9a\xca\x42\x4e\x57\x90\x5f\x28\
+\xab\xf9\x5c\x81\xca\x91\x43\x3e\x5f\x20\x31\x55\x34\x1a\x9b\x2a\
+\xa5\xfd\x58\xf8\x5a\x8d\xc1\xd7\x50\xad\x32\xd1\x35\x75\xa9\xb2\
+\xbc\x7b\x08\xfe\xf9\xed\x87\xdf\x71\xd3\xee\x23\xae\x10\x64\x77\
+\x18\x71\xaf\x88\x94\x3f\x8c\x9c\x27\x88\xa2\xcf\x8d\x62\x92\x47\
+\xa9\xe8\x41\xa9\x14\x81\x10\x51\x10\x8a\x26\x6a\xd5\xea\xca\xb3\
+\xcd\xcd\xcd\x76\xda\x79\x7b\xad\xb6\xf6\xac\x58\x2c\xd6\xd6\xd6\
+\xd6\x0e\xe0\x8d\x46\x13\xce\x32\xc5\x6c\x49\xd7\x52\x06\x56\x21\
+\x86\x63\xe8\xbe\xdf\xf7\xed\x03\x01\xfd\x03\xe3\x17\x22\xa1\x24\
+\x22\x01\x05\xb1\xa0\x82\x44\x28\x86\x34\x45\x4e\x8c\xa1\x10\x89\
+\x62\x29\x14\x46\x35\xee\x45\x2e\x69\xa5\x4c\x88\x41\x00\x7f\xa7\
+\xb8\x44\x71\x9d\xe2\x1a\xc5\x27\xec\x5c\xa5\xb2\xe4\xaf\x54\xaa\
+\xac\xe3\x09\x4e\xa5\xa9\x6f\xb0\x2c\x30\x77\x50\xdf\x94\xa9\x9c\
+\x39\x28\x4a\x9a\x22\x83\xc1\xe1\xf1\x0b\x07\x02\x66\xf5\x76\xab\
+\x28\xa6\x55\xe6\x73\x45\xce\x20\x11\xcb\x22\x13\xcf\x62\x81\x62\
+\x31\x9e\xc1\x52\x22\x85\x72\x54\x52\x73\x81\xf9\x1a\x80\xbf\x51\
+\xb4\x65\x33\xd9\xae\x99\x29\xed\xcf\xfa\xfb\x86\x7e\x6e\xb5\xd8\
+\x1e\x31\x31\x4c\x44\x26\x93\x5b\x21\xb8\xba\x41\xbb\xa7\x9d\x93\
+\xe0\x12\xb2\x99\x02\x52\xa9\x1c\xe2\x04\x8f\x46\x13\x94\x81\xb8\
+\xaa\xd5\x59\x9a\x33\xda\x64\x71\x25\x25\x89\xcd\xf6\x6c\xd3\xe7\
+\xd9\x12\x0a\xf9\x32\x4a\x85\x25\x54\x49\x7d\x2e\x16\x43\xad\x52\
+\x19\x00\x70\x39\x1c\x12\xdb\xd9\x7d\x3c\xcf\x6b\xda\xae\x77\x68\
+\xd8\x32\xe8\x4c\xf7\x59\x56\x68\xf2\x0d\x66\x33\x0b\x54\xae\x2a\
+\x0a\x0b\x74\x5f\xb6\x78\x18\x4e\x99\x0d\xf8\x25\x90\x80\xe4\x81\
+\x00\x9b\xdd\xd7\x38\x32\xe1\x16\x96\x9a\xe3\x95\x3a\x37\xa1\xa4\
+\xb0\xbb\xb3\xfb\x29\x80\xf6\x7b\x3d\x8f\x7f\x32\xf4\x60\xe8\xe0\
+\xfe\x4b\x2d\x57\x34\x77\xba\x7a\xdf\x67\x59\xa0\xbe\xb8\x26\xcb\
+\x71\x4a\xf9\xf1\x70\x3f\xc1\xbd\xde\x30\x66\xb4\x96\xc6\xc1\x03\
+\x1c\x4e\xff\x56\x32\x79\xd2\x84\x6b\xd0\x83\xb2\xac\xc3\x2f\x03\
+\xb8\xdd\xfa\xf1\x8d\x1f\xb7\x68\x9a\x73\x7d\x66\x66\x46\x33\x34\
+\xfc\xf4\x3d\x00\x37\x77\xb6\x77\x5a\xc3\x21\x69\x1f\x9e\xdc\x87\
+\x67\x8e\xc0\x9d\xce\x00\xa6\xa6\x4c\x5b\xaf\x0a\xc8\x64\x32\xc7\
+\xc1\x9b\x3e\xa7\xe6\x62\x5d\xfc\x04\xc0\x95\xe9\x31\xfd\x47\xff\
+\xbe\xb7\xa5\xe5\xab\x4c\x24\xe2\x09\xd6\x8c\xad\xe5\xc5\xc5\xbe\
+\x88\x2f\x8a\xa4\x92\x85\x12\x4b\x21\x12\x8d\x23\x4c\x70\xe1\x15\
+\x38\xcf\xfb\x30\x3a\xaa\xcf\x34\x05\xcc\x0b\x7c\x3e\xff\x75\x78\
+\x8d\xc1\x0f\xe6\x7a\xbd\x5e\x27\x11\x95\x3c\x80\xbf\x52\x67\xdf\
+\x79\x36\x38\x75\xf1\x8f\xbf\xbb\xf0\xdd\x5b\xd7\xbf\x7c\x5b\xf0\
+\x05\x5a\x55\x55\xed\x04\xf0\x97\x48\xd8\x56\x94\x22\x6e\x55\x21\
+\xa8\xe4\x25\xcb\x0a\x32\x7c\xfe\x08\xdc\x04\x9f\x27\xb8\x9d\xe0\
+\x1c\x59\x7e\x60\x68\x92\x7f\xc5\x05\xd6\xab\xf4\x31\xf1\x72\xc2\
+\xad\x30\xff\x32\x30\x0b\xe6\x67\xe6\x6b\x36\xdb\x99\x00\x26\xc4\
+\xc2\x44\x50\x5c\xdd\xdb\xdb\xbd\xab\x42\xed\x06\xf0\x0f\x76\x2e\
+\x9b\x92\xb9\x88\xa8\x43\x2a\x61\x87\x14\xb5\x21\x14\xf0\x42\xb0\
+\x87\xe1\xe1\x42\x70\x58\x03\x04\xf6\x61\xce\xea\x86\xd9\xe2\x46\
+\x77\x4f\xff\xd5\x03\x01\xbd\x0f\x07\x7e\x58\x2e\xaf\xb0\x14\x33\
+\x28\x41\x1a\x2c\x98\x9f\xd9\xee\xd9\x4c\x67\xf5\xa7\xdf\xdb\x6a\
+\xa1\xb0\x48\xd6\x5a\xcc\x37\x1a\x8d\xbb\x00\x3e\xa2\xf8\x98\xa6\
+\x5c\xaf\x14\x92\xf3\x7e\x77\x10\x09\x39\xa8\xc6\x63\x1c\xe4\xa8\
+\x01\xa1\x90\x1e\x5e\xc1\x04\x27\xe7\x82\xdd\xe8\x83\x45\xe7\x81\
+\x61\xc6\x85\xa9\x09\x1b\x3e\xb9\xf2\xf9\xdb\x87\xa6\x61\x2e\x57\
+\xd8\xa5\xb4\xab\xf4\x56\x63\x35\x3f\x0c\x6f\xbe\x52\x69\xa2\x35\
+\x50\x5c\x2c\xab\x89\x38\xd5\x37\x22\x23\x14\x8c\x20\x1c\x90\x10\
+\x15\xe3\x6a\x5c\xa2\x6e\x0f\x29\x90\x42\x02\xc2\xa2\x89\x04\x68\
+\x21\x08\xd3\x70\xba\x27\xc1\x59\x0d\x30\x69\x79\xe8\x26\x1c\x6a\
+\xdf\xbd\xc9\x6d\xcd\xd7\x17\x7d\xc3\xfd\x69\x7d\xfd\xf9\x89\x70\
+\x56\x1a\xf6\x42\x61\x33\xbd\x5c\x26\x9f\x17\x96\x5e\x5a\x2d\x8f\
+\xb8\x4c\xf0\x30\x75\xbb\x4f\x86\xdf\x23\x52\xb8\xe0\xf3\x52\x06\
+\xbc\x13\x70\xba\xc6\x60\xe3\x9f\xc2\x3c\x37\x06\xfd\xb4\x19\x37\
+\x3f\xeb\xf9\xb3\xe6\xb8\x25\x2b\x89\x75\x2a\x81\x7a\x22\xbc\x42\
+\xf0\x52\xf5\xa8\xcf\x25\x82\x07\x68\xc8\x78\x22\xf0\x39\x42\x70\
+\xd9\xfc\x70\xda\x79\xcc\xf3\x33\xe0\x1d\xcf\xa8\xfe\x4c\xc0\xb0\
+\x3a\x34\xdc\xd5\xd0\x1c\xbb\xbe\x75\x83\xb2\x60\xfa\x69\x7d\x7d\
+\xe3\x4c\xf0\xe6\x78\x25\x9f\x0b\x12\x7c\xae\x30\x5c\x5c\x00\x8e\
+\x39\x2f\x38\xa3\x0b\x16\xa3\x15\x16\xf3\x24\xcc\xe6\x11\x68\x67\
+\xfb\xf1\xc5\x97\x57\xde\xd3\xfc\xe1\xd9\x51\x7e\x73\x26\xb8\xaf\
+\xa9\x50\xcf\x02\x6f\x0e\x19\x0f\xf9\xdc\x41\x70\x8b\x17\x36\x83\
+\x0b\x73\xb3\x0e\x18\xa7\xed\xd0\x4d\x9b\xa0\x9f\x9d\xa0\xce\xbf\
+\x75\x53\x73\x9a\xe5\x15\x02\x5a\xfa\x92\x39\x0b\xbc\x39\x64\xec\
+\xe4\xf3\x39\x37\xe6\x74\xf3\x30\x4e\xd9\x31\x3b\x6e\xc5\xf4\xd8\
+\x1c\x3a\x3b\x7b\x67\x4f\x05\x37\x1a\x9d\xfb\x47\x0b\x67\xbf\x49\
+\x1f\x0e\xac\xe1\xd4\x53\xc3\x79\x82\x33\x9f\x1b\xe7\x61\xd0\x12\
+\x7c\xc2\xaa\x8e\x0f\x1b\xd0\xde\x76\x77\xff\xe5\xd5\x7a\xeb\x8e\
+\xe6\x4c\x6b\x7c\x4a\xfb\x7e\x30\x24\x6d\x95\x4b\xcb\x04\x2f\xa8\
+\x6f\x84\x5b\x08\x6e\x22\xb8\x8e\x57\x75\x64\xb9\x47\xf7\x47\xb7\
+\x3f\xbb\xde\xf9\x0b\xcd\x37\x5d\xe3\x93\xba\x8b\x4e\x97\x80\x98\
+\x9c\x82\x12\x4b\x53\xc3\x29\x47\xe0\x36\xce\x0d\x0b\x09\xd0\xcd\
+\xda\xf1\xf8\xc9\x04\xda\x3a\x7a\x2e\x6a\xfe\xdb\xab\xb3\xeb\xde\
+\xbb\xa3\x63\xda\x0e\x9d\x81\x13\x67\x75\x5c\x55\x3b\x6b\xc5\x14\
+\x35\xd8\xe8\xb8\xbe\x3a\x34\x3c\x25\xde\xe9\x79\xd2\x71\xe9\xf2\
+\x8d\x77\x35\xff\xab\x75\xae\xab\xeb\x8d\xd7\xfc\xe0\x5c\xd7\x99\
+\x9e\xf9\x2f\x1f\xff\xdd\x5f\xc8\x58\xee\x62\x00\x00\x00\x00\x49\
+\x45\x4e\x44\xae\x42\x60\x82\
\x00\x00\x02\xd2\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
@@ -82742,6 +82873,11 @@
\x00\x61\
\x00\x75\x00\x74\x00\x6f\x00\x2d\x00\x73\x00\x74\x00\x61\x00\x72\x00\x74\x00\x5f\x00\x61\x00\x63\x00\x74\x00\x69\x00\x76\x00\x65\
\x00\x2e\x00\x70\x00\x6e\x00\x67\
+\x00\x11\
+\x06\xfd\x49\x67\
+\x00\x6d\
+\x00\x65\x00\x64\x00\x69\x00\x61\x00\x5f\x00\x6f\x00\x70\x00\x74\x00\x69\x00\x63\x00\x61\x00\x6c\x00\x2e\x00\x70\x00\x6e\x00\x67\
+\
\x00\x0e\
\x0c\x3d\xa6\xe7\
\x00\x6d\
@@ -83056,9 +83192,9 @@
qt_resource_struct = b"\
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x14\x00\x00\x00\x01\
-\x00\x00\x00\xf8\x00\x02\x00\x00\x00\x06\x00\x00\x00\x92\
-\x00\x00\x00\x00\x00\x02\x00\x00\x00\x04\x00\x00\x00\x8e\
-\x00\x00\x00\xb4\x00\x02\x00\x00\x00\x08\x00\x00\x00\x86\
+\x00\x00\x00\xf8\x00\x02\x00\x00\x00\x06\x00\x00\x00\x93\
+\x00\x00\x00\x00\x00\x02\x00\x00\x00\x04\x00\x00\x00\x8f\
+\x00\x00\x00\xb4\x00\x02\x00\x00\x00\x09\x00\x00\x00\x86\
\x00\x00\x00\xd6\x00\x02\x00\x00\x00\x14\x00\x00\x00\x72\
\x00\x00\x00\x3e\x00\x02\x00\x00\x00\x02\x00\x00\x00\x70\
\x00\x00\x00\x14\x00\x02\x00\x00\x00\x02\x00\x00\x00\x6e\
@@ -83082,70 +83218,70 @@
\x00\x00\x04\x3e\x00\x00\x00\x00\x00\x01\x00\x08\x06\x4f\
\x00\x00\x03\xe0\x00\x00\x00\x00\x00\x01\x00\x02\xc4\x8b\
\x00\x00\x04\xa0\x00\x00\x00\x00\x00\x01\x00\x0d\x48\x13\
-\x00\x00\x11\xb2\x00\x00\x00\x00\x00\x01\x00\x13\x92\x0d\
-\x00\x00\x12\x2e\x00\x00\x00\x00\x00\x01\x00\x13\x9b\xd4\
-\x00\x00\x11\x8c\x00\x00\x00\x00\x00\x01\x00\x13\x8f\x33\
-\x00\x00\x11\x12\x00\x00\x00\x00\x00\x01\x00\x13\x87\x1b\
-\x00\x00\x13\x6e\x00\x00\x00\x00\x00\x01\x00\x13\xb4\xa2\
-\x00\x00\x11\x62\x00\x00\x00\x00\x00\x01\x00\x13\x8c\x95\
-\x00\x00\x12\x04\x00\x00\x00\x00\x00\x01\x00\x13\x98\xef\
-\x00\x00\x10\xb0\x00\x00\x00\x00\x00\x01\x00\x13\x80\x01\
-\x00\x00\x12\xaa\x00\x00\x00\x00\x00\x01\x00\x13\xa5\xf8\
-\x00\x00\x13\x22\x00\x00\x00\x00\x00\x01\x00\x13\xae\x1c\
-\x00\x00\x12\x56\x00\x00\x00\x00\x00\x01\x00\x13\x9f\x48\
-\x00\x00\x13\x48\x00\x00\x00\x00\x00\x01\x00\x13\xb1\xce\
-\x00\x00\x10\xe8\x00\x00\x00\x00\x00\x01\x00\x13\x84\xa3\
-\x00\x00\x12\xf8\x00\x00\x00\x00\x00\x01\x00\x13\xab\x9a\
-\x00\x00\x11\x3e\x00\x00\x00\x00\x00\x01\x00\x13\x8a\x4e\
-\x00\x00\x11\xd8\x00\x00\x00\x00\x00\x01\x00\x13\x94\x44\
-\x00\x00\x10\x8c\x00\x00\x00\x00\x00\x01\x00\x13\x7d\x04\
-\x00\x00\x12\xd2\x00\x00\x00\x00\x00\x01\x00\x13\xa8\x0b\
-\x00\x00\x12\x84\x00\x00\x00\x00\x00\x01\x00\x13\xa3\xe1\
+\x00\x00\x11\xda\x00\x00\x00\x00\x00\x01\x00\x13\x9a\x19\
+\x00\x00\x12\x56\x00\x00\x00\x00\x00\x01\x00\x13\xa3\xe0\
+\x00\x00\x11\xb4\x00\x00\x00\x00\x00\x01\x00\x13\x97\x3f\
+\x00\x00\x11\x3a\x00\x00\x00\x00\x00\x01\x00\x13\x8f\x27\
+\x00\x00\x13\x96\x00\x00\x00\x00\x00\x01\x00\x13\xbc\xae\
+\x00\x00\x11\x8a\x00\x00\x00\x00\x00\x01\x00\x13\x94\xa1\
+\x00\x00\x12\x2c\x00\x00\x00\x00\x00\x01\x00\x13\xa0\xfb\
+\x00\x00\x10\xd8\x00\x00\x00\x00\x00\x01\x00\x13\x88\x0d\
+\x00\x00\x12\xd2\x00\x00\x00\x00\x00\x01\x00\x13\xae\x04\
+\x00\x00\x13\x4a\x00\x00\x00\x00\x00\x01\x00\x13\xb6\x28\
+\x00\x00\x12\x7e\x00\x00\x00\x00\x00\x01\x00\x13\xa7\x54\
+\x00\x00\x13\x70\x00\x00\x00\x00\x00\x01\x00\x13\xb9\xda\
+\x00\x00\x11\x10\x00\x00\x00\x00\x00\x01\x00\x13\x8c\xaf\
+\x00\x00\x13\x20\x00\x00\x00\x00\x00\x01\x00\x13\xb3\xa6\
+\x00\x00\x11\x66\x00\x00\x00\x00\x00\x01\x00\x13\x92\x5a\
+\x00\x00\x12\x00\x00\x00\x00\x00\x00\x01\x00\x13\x9c\x50\
+\x00\x00\x10\xb4\x00\x00\x00\x00\x00\x01\x00\x13\x85\x10\
+\x00\x00\x12\xfa\x00\x00\x00\x00\x00\x01\x00\x13\xb0\x17\
+\x00\x00\x12\xac\x00\x00\x00\x00\x00\x01\x00\x13\xab\xed\
\x00\x00\x03\x8a\x00\x00\x00\x00\x00\x01\x00\x00\x21\x92\
-\x00\x00\x0d\x4c\x00\x00\x00\x00\x00\x01\x00\x11\xfe\x7c\
-\x00\x00\x0d\xcc\x00\x00\x00\x00\x00\x01\x00\x12\x05\x42\
-\x00\x00\x0c\xd0\x00\x00\x00\x00\x00\x01\x00\x11\xf7\x78\
-\x00\x00\x0d\x74\x00\x00\x00\x00\x00\x01\x00\x12\x01\x1c\
-\x00\x00\x0d\xf6\x00\x00\x00\x00\x00\x01\x00\x12\x08\x0d\
-\x00\x00\x0d\x1a\x00\x00\x00\x00\x00\x01\x00\x11\xfc\x92\
-\x00\x00\x0c\xf4\x00\x00\x00\x00\x00\x01\x00\x11\xfa\x1f\
-\x00\x00\x0d\xaa\x00\x00\x00\x00\x00\x01\x00\x12\x02\x9e\
+\x00\x00\x0d\x74\x00\x00\x00\x00\x00\x01\x00\x12\x06\x88\
+\x00\x00\x0d\xf4\x00\x00\x00\x00\x00\x01\x00\x12\x0d\x4e\
+\x00\x00\x0c\xf8\x00\x00\x00\x00\x00\x01\x00\x11\xff\x84\
+\x00\x00\x0d\x9c\x00\x00\x00\x00\x00\x01\x00\x12\x09\x28\
+\x00\x00\x0e\x1e\x00\x00\x00\x00\x00\x01\x00\x12\x10\x19\
+\x00\x00\x0d\x42\x00\x00\x00\x00\x00\x01\x00\x12\x04\x9e\
+\x00\x00\x0d\x1c\x00\x00\x00\x00\x00\x01\x00\x12\x02\x2b\
+\x00\x00\x0d\xd2\x00\x00\x00\x00\x00\x01\x00\x12\x0a\xaa\
\x00\x00\x01\x80\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\
\x00\x00\x01\xe6\x00\x00\x00\x00\x00\x01\x00\x00\x05\xe6\
\x00\x00\x01\xb2\x00\x00\x00\x00\x00\x01\x00\x00\x02\xfe\
-\x00\x00\x0f\xdc\x00\x00\x00\x00\x00\x01\x00\x12\x23\x5b\
-\x00\x00\x10\x06\x00\x00\x00\x00\x00\x01\x00\x12\x28\xc5\
-\x00\x00\x10\x36\x00\x00\x00\x00\x00\x01\x00\x12\x97\x4e\
-\x00\x00\x10\x56\x00\x00\x00\x00\x00\x01\x00\x12\x9d\xff\
-\x00\x00\x14\x34\x00\x00\x00\x00\x00\x01\x00\x13\xc2\x69\
-\x00\x00\x13\xda\x00\x00\x00\x00\x00\x01\x00\x13\xbd\x68\
-\x00\x00\x16\x50\x00\x00\x00\x00\x00\x01\x00\x13\xec\x6e\
-\x00\x00\x14\xda\x00\x00\x00\x00\x00\x01\x00\x13\xca\x73\
-\x00\x00\x14\x76\x00\x00\x00\x00\x00\x01\x00\x13\xc5\xbc\
-\x00\x00\x14\x00\x00\x00\x00\x00\x00\x01\x00\x13\xc0\x99\
-\x00\x00\x15\xa2\x00\x00\x00\x00\x00\x01\x00\x13\xdd\x49\
-\x00\x00\x15\x40\x00\x00\x00\x00\x00\x01\x00\x13\xd5\x19\
-\x00\x00\x16\x76\x00\x00\x00\x00\x00\x01\x00\x13\xef\x50\
-\x00\x00\x16\x1c\x00\x00\x00\x00\x00\x01\x00\x13\xe8\x91\
-\x00\x00\x15\x6c\x00\x00\x00\x00\x00\x01\x00\x13\xda\x25\
-\x00\x00\x16\xa8\x00\x00\x00\x00\x00\x01\x00\x13\xf3\x0d\
-\x00\x00\x15\xc4\x00\x00\x00\x00\x00\x01\x00\x13\xe1\xb8\
-\x00\x00\x15\x08\x00\x00\x00\x00\x00\x01\x00\x13\xd2\xa3\
-\x00\x00\x15\xf2\x00\x00\x00\x00\x00\x01\x00\x13\xe6\x09\
-\x00\x00\x14\xa4\x00\x00\x00\x00\x00\x01\x00\x13\xc7\xc3\
+\x00\x00\x10\x04\x00\x00\x00\x00\x00\x01\x00\x12\x2b\x67\
+\x00\x00\x10\x2e\x00\x00\x00\x00\x00\x01\x00\x12\x30\xd1\
+\x00\x00\x10\x5e\x00\x00\x00\x00\x00\x01\x00\x12\x9f\x5a\
+\x00\x00\x10\x7e\x00\x00\x00\x00\x00\x01\x00\x12\xa6\x0b\
+\x00\x00\x14\x5c\x00\x00\x00\x00\x00\x01\x00\x13\xca\x75\
+\x00\x00\x14\x02\x00\x00\x00\x00\x00\x01\x00\x13\xc5\x74\
+\x00\x00\x16\x78\x00\x00\x00\x00\x00\x01\x00\x13\xf4\x7a\
+\x00\x00\x15\x02\x00\x00\x00\x00\x00\x01\x00\x13\xd2\x7f\
+\x00\x00\x14\x9e\x00\x00\x00\x00\x00\x01\x00\x13\xcd\xc8\
+\x00\x00\x14\x28\x00\x00\x00\x00\x00\x01\x00\x13\xc8\xa5\
+\x00\x00\x15\xca\x00\x00\x00\x00\x00\x01\x00\x13\xe5\x55\
+\x00\x00\x15\x68\x00\x00\x00\x00\x00\x01\x00\x13\xdd\x25\
+\x00\x00\x16\x9e\x00\x00\x00\x00\x00\x01\x00\x13\xf7\x5c\
+\x00\x00\x16\x44\x00\x00\x00\x00\x00\x01\x00\x13\xf0\x9d\
+\x00\x00\x15\x94\x00\x00\x00\x00\x00\x01\x00\x13\xe2\x31\
+\x00\x00\x16\xd0\x00\x00\x00\x00\x00\x01\x00\x13\xfb\x19\
+\x00\x00\x15\xec\x00\x00\x00\x00\x00\x01\x00\x13\xe9\xc4\
+\x00\x00\x15\x30\x00\x00\x00\x00\x00\x01\x00\x13\xda\xaf\
+\x00\x00\x16\x1a\x00\x00\x00\x00\x00\x01\x00\x13\xee\x15\
+\x00\x00\x14\xcc\x00\x00\x00\x00\x00\x01\x00\x13\xcf\xcf\
\x00\x00\x0b\x2c\x00\x00\x00\x00\x00\x01\x00\x11\x9f\x6b\
\x00\x00\x0b\x4c\x00\x00\x00\x00\x00\x01\x00\x11\xa3\x48\
\x00\x00\x0b\x06\x00\x00\x00\x00\x00\x01\x00\x11\x9c\xcd\
-\x00\x00\x0e\xba\x00\x00\x00\x00\x00\x01\x00\x12\x12\x29\
-\x00\x00\x0f\x58\x00\x00\x00\x00\x00\x01\x00\x12\x1c\x9e\
-\x00\x00\x0f\xb2\x00\x00\x00\x00\x00\x01\x00\x12\x21\x57\
-\x00\x00\x0e\x50\x00\x00\x00\x00\x00\x01\x00\x12\x0e\x39\
-\x00\x00\x0f\x34\x00\x00\x00\x00\x00\x01\x00\x12\x19\x6b\
-\x00\x00\x0e\x84\x00\x00\x00\x00\x00\x01\x00\x12\x10\x30\
-\x00\x00\x0e\xee\x00\x00\x00\x00\x00\x01\x00\x12\x14\x27\
-\x00\x00\x0f\x10\x00\x00\x00\x00\x00\x01\x00\x12\x16\x3a\
-\x00\x00\x0f\x8e\x00\x00\x00\x00\x00\x01\x00\x12\x1e\x86\
-\x00\x00\x0e\x28\x00\x00\x00\x00\x00\x01\x00\x12\x0b\x7d\
+\x00\x00\x0e\xe2\x00\x00\x00\x00\x00\x01\x00\x12\x1a\x35\
+\x00\x00\x0f\x80\x00\x00\x00\x00\x00\x01\x00\x12\x24\xaa\
+\x00\x00\x0f\xda\x00\x00\x00\x00\x00\x01\x00\x12\x29\x63\
+\x00\x00\x0e\x78\x00\x00\x00\x00\x00\x01\x00\x12\x16\x45\
+\x00\x00\x0f\x5c\x00\x00\x00\x00\x00\x01\x00\x12\x21\x77\
+\x00\x00\x0e\xac\x00\x00\x00\x00\x00\x01\x00\x12\x18\x3c\
+\x00\x00\x0f\x16\x00\x00\x00\x00\x00\x01\x00\x12\x1c\x33\
+\x00\x00\x0f\x38\x00\x00\x00\x00\x00\x01\x00\x12\x1e\x46\
+\x00\x00\x0f\xb6\x00\x00\x00\x00\x00\x01\x00\x12\x26\x92\
+\x00\x00\x0e\x50\x00\x00\x00\x00\x00\x01\x00\x12\x13\x89\
\x00\x00\x07\x84\x00\x00\x00\x00\x00\x01\x00\x11\x50\x13\
\x00\x00\x07\xaa\x00\x00\x00\x00\x00\x01\x00\x11\x52\x77\
\x00\x00\x07\x60\x00\x00\x00\x00\x00\x01\x00\x11\x4d\xce\
@@ -83165,10 +83301,10 @@
\x00\x00\x05\x18\x00\x00\x00\x00\x00\x01\x00\x0f\xf0\xe8\
\x00\x00\x05\xb2\x00\x00\x00\x00\x00\x01\x00\x0f\xf7\x01\
\x00\x00\x05\x80\x00\x00\x00\x00\x00\x01\x00\x0f\xf5\x39\
-\x00\x00\x16\xcc\x00\x00\x00\x00\x00\x01\x00\x13\xf6\xc0\
-\x00\x00\x17\x00\x00\x00\x00\x00\x00\x01\x00\x13\xf9\x90\
-\x00\x00\x13\x96\x00\x00\x00\x00\x00\x01\x00\x13\xb7\xe7\
-\x00\x00\x13\xba\x00\x00\x00\x00\x00\x01\x00\x13\xba\xe5\
+\x00\x00\x16\xf4\x00\x00\x00\x00\x00\x01\x00\x13\xfe\xcc\
+\x00\x00\x17\x28\x00\x00\x00\x00\x00\x01\x00\x14\x01\x9c\
+\x00\x00\x13\xbe\x00\x00\x00\x00\x00\x01\x00\x13\xbf\xf3\
+\x00\x00\x13\xe2\x00\x00\x00\x00\x00\x01\x00\x13\xc2\xf1\
\x00\x00\x08\x02\x00\x00\x00\x00\x00\x01\x00\x11\x5d\xa6\
\x00\x00\x08\xe0\x00\x00\x00\x00\x00\x01\x00\x11\x6d\xf6\
\x00\x00\x0a\xe6\x00\x00\x00\x00\x00\x01\x00\x11\x98\xda\
@@ -83189,18 +83325,19 @@
\x00\x00\x08\x26\x00\x00\x00\x00\x00\x01\x00\x11\x60\x92\
\x00\x00\x08\x9e\x00\x00\x00\x00\x00\x01\x00\x11\x67\xa2\
\x00\x00\x0a\x0a\x00\x00\x00\x00\x00\x01\x00\x11\x7f\xdb\
+\x00\x00\x0c\x8a\x00\x00\x00\x00\x00\x01\x00\x11\xed\xbb\
\x00\x00\x0b\xe0\x00\x00\x00\x00\x00\x01\x00\x11\xdc\x80\
\x00\x00\x0c\x14\x00\x00\x00\x00\x00\x01\x00\x11\xdf\x83\
-\x00\x00\x0c\x8a\x00\x00\x00\x00\x00\x01\x00\x11\xed\xbb\
+\x00\x00\x0c\xb2\x00\x00\x00\x00\x00\x01\x00\x11\xf5\xc7\
\x00\x00\x0b\xb0\x00\x00\x00\x00\x00\x01\x00\x11\xda\x27\
\x00\x00\x0c\x5a\x00\x00\x00\x00\x00\x01\x00\x11\xea\x88\
-\x00\x00\x0c\xac\x00\x00\x00\x00\x00\x01\x00\x11\xf0\x91\
+\x00\x00\x0c\xd4\x00\x00\x00\x00\x00\x01\x00\x11\xf8\x9d\
\x00\x00\x0b\x6e\x00\x00\x00\x00\x00\x01\x00\x11\xa6\x82\
\x00\x00\x0c\x36\x00\x00\x00\x00\x00\x01\x00\x11\xe3\x56\
-\x00\x00\x17\x30\x00\x00\x00\x00\x00\x01\x00\x13\xfc\x89\
-\x00\x00\x17\x92\x00\x00\x00\x00\x00\x01\x00\x14\x02\xff\
-\x00\x00\x17\x64\x00\x00\x00\x00\x00\x01\x00\x13\xff\xeb\
-\x00\x00\x17\xba\x00\x00\x00\x00\x00\x01\x00\x14\x05\x9d\
+\x00\x00\x17\x58\x00\x00\x00\x00\x00\x01\x00\x14\x04\x95\
+\x00\x00\x17\xba\x00\x00\x00\x00\x00\x01\x00\x14\x0b\x0b\
+\x00\x00\x17\x8c\x00\x00\x00\x00\x00\x01\x00\x14\x07\xf7\
+\x00\x00\x17\xe2\x00\x00\x00\x00\x00\x01\x00\x14\x0d\xa9\
\x00\x00\x06\xc8\x00\x00\x00\x00\x00\x01\x00\x10\x3b\xad\
\x00\x00\x06\x68\x00\x00\x00\x00\x00\x01\x00\x10\x0c\x6d\
\x00\x00\x06\x38\x00\x00\x00\x00\x00\x01\x00\x10\x01\xd9\
=== modified file 'openlp/core/ui/media/__init__.py'
--- openlp/core/ui/media/__init__.py 2014-04-20 22:23:26 +0000
+++ openlp/core/ui/media/__init__.py 2014-09-02 20:29:54 +0000
@@ -72,6 +72,9 @@
length = 0
start_time = 0
end_time = 0
+ title_track = 0
+ audio_track = 0
+ subtitle_track = 0
media_type = MediaType()
@@ -107,6 +110,40 @@
players = players.replace(overridden_player, '[%s]' % overridden_player)
Settings().setValue('media/players', players)
+
+def parse_optical_path(input):
+ """
+ Split the optical path info.
+
+ :param input: The string to parse
+ :return: The elements extracted from the string: filename, title, audio_track, subtitle_track, start, end
+ """
+ log.debug('parse_optical_path, about to parse: "%s"' % input)
+ clip_info = input.split(sep=':')
+ title = int(clip_info[1])
+ audio_track = int(clip_info[2])
+ subtitle_track = int(clip_info[3])
+ start = float(clip_info[4])
+ end = float(clip_info[5])
+ clip_name = clip_info[6]
+ filename = clip_info[7]
+ # Windows path usually contains a colon after the drive letter
+ if len(clip_info) > 8:
+ filename += ':' + clip_info[8]
+ return filename, title, audio_track, subtitle_track, start, end, clip_name
+
+
+def format_milliseconds(milliseconds):
+ """
+ Format milliseconds into a human readable time string.
+ :param milliseconds: Milliseconds to format
+ :return: Time string in format: hh.mm.ss,ttt
+ """
+ seconds, millis = divmod(milliseconds, 1000)
+ minutes, seconds = divmod(seconds, 60)
+ hours, minutes = divmod(minutes, 60)
+ return "%02d:%02d:%02d,%03d" % (hours, minutes, seconds, millis)
+
from .mediacontroller import MediaController
from .playertab import PlayerTab
=== modified file 'openlp/core/ui/media/mediacontroller.py'
--- openlp/core/ui/media/mediacontroller.py 2014-06-30 20:59:22 +0000
+++ openlp/core/ui/media/mediacontroller.py 2014-09-02 20:29:54 +0000
@@ -36,9 +36,10 @@
from PyQt4 import QtCore, QtGui
from openlp.core.common import OpenLPMixin, Registry, RegistryMixin, RegistryProperties, Settings, UiStrings, translate
-from openlp.core.lib import OpenLPToolbar
+from openlp.core.lib import OpenLPToolbar, ItemCapabilities
from openlp.core.lib.ui import critical_error_message_box
-from openlp.core.ui.media import MediaState, MediaInfo, MediaType, get_media_players, set_media_players
+from openlp.core.ui.media import MediaState, MediaInfo, MediaType, get_media_players, set_media_players,\
+ parse_optical_path
from openlp.core.ui.media.mediaplayer import MediaPlayer
from openlp.core.common import AppLocation
from openlp.core.ui import DisplayControllerType
@@ -368,7 +369,16 @@
controller.media_info.file_info = QtCore.QFileInfo(service_item.get_frame_path())
display = self._define_display(controller)
if controller.is_live:
- is_valid = self._check_file_type(controller, display, service_item)
+ # if this is an optical device use special handling
+ if service_item.is_capable(ItemCapabilities.IsOptical):
+ log.debug('video is optical and live')
+ path = service_item.get_frame_path()
+ (name, title, audio_track, subtitle_track, start, end, clip_name) = parse_optical_path(path)
+ is_valid = self.media_setup_optical(name, title, audio_track, subtitle_track, start, end, display,
+ controller)
+ else:
+ log.debug('video is not optical and live')
+ is_valid = self._check_file_type(controller, display, service_item)
display.override['theme'] = ''
display.override['video'] = True
if controller.media_info.is_background:
@@ -379,12 +389,21 @@
controller.media_info.start_time = service_item.start_time
controller.media_info.end_time = service_item.end_time
elif controller.preview_display:
- is_valid = self._check_file_type(controller, display, service_item)
+ if service_item.is_capable(ItemCapabilities.IsOptical):
+ log.debug('video is optical and preview')
+ path = service_item.get_frame_path()
+ (name, title, audio_track, subtitle_track, start, end, clip_name) = parse_optical_path(path)
+ is_valid = self.media_setup_optical(name, title, audio_track, subtitle_track, start, end, display,
+ controller)
+ else:
+ log.debug('video is not optical and preview')
+ is_valid = self._check_file_type(controller, display, service_item)
if not is_valid:
# Media could not be loaded correctly
critical_error_message_box(translate('MediaPlugin.MediaItem', 'Unsupported File'),
translate('MediaPlugin.MediaItem', 'Unsupported File'))
return False
+ log.debug('video mediatype: ' + str(controller.media_info.media_type))
# dont care about actual theme, set a black background
if controller.is_live and not controller.media_info.is_background:
display.frame.evaluateJavaScript('show_video( "setBackBoard", null, null, null,"visible");')
@@ -436,6 +455,62 @@
log.debug('use %s controller' % self.current_media_players[controller.controller_type])
return True
+ def media_setup_optical(self, filename, title, audio_track, subtitle_track, start, end, display, controller):
+ """
+ Setup playback of optical media
+
+ :param filename: Path of the optical device/drive.
+ :param title: The main/title track to play.
+ :param audio_track: The audio track to play.
+ :param subtitle_track: The subtitle track to play.
+ :param start: Start position in miliseconds.
+ :param end: End position in miliseconds.
+ :param display: The display to play the media.
+ :param controller: The media contraoller.
+ :return: True if setup succeded else False.
+ """
+ log.debug('media_setup_optical')
+ if controller is None:
+ controller = self.display_controllers[DisplayControllerType.Plugin]
+ # stop running videos
+ self.media_reset(controller)
+ # Setup media info
+ controller.media_info = MediaInfo()
+ controller.media_info.file_info = QtCore.QFileInfo(filename)
+ if audio_track == -1 and subtitle_track == -1:
+ controller.media_info.media_type = MediaType.CD
+ else:
+ controller.media_info.media_type = MediaType.DVD
+ controller.media_info.start_time = start/1000
+ controller.media_info.end_time = end/1000
+ controller.media_info.length = (end - start)/1000
+ controller.media_info.title_track = title
+ controller.media_info.audio_track = audio_track
+ controller.media_info.subtitle_track = subtitle_track
+ # When called from mediaitem display is None
+ if display is None:
+ display = controller.preview_display
+ # Find vlc player
+ used_players = get_media_players()[0]
+ vlc_player = None
+ for title in used_players:
+ player = self.media_players[title]
+ if player.name == 'vlc':
+ vlc_player = player
+ if vlc_player is None:
+ critical_error_message_box(translate('MediaPlugin.MediaItem', 'VLC player required'),
+ translate('MediaPlugin.MediaItem',
+ 'VLC player required for playback of optical devices'))
+ return False
+ vlc_player.load(display)
+ self.resize(display, vlc_player)
+ self.current_media_players[controller.controller_type] = vlc_player
+ if audio_track == -1 and subtitle_track == -1:
+ controller.media_info.media_type = MediaType.CD
+ else:
+ controller.media_info.media_type = MediaType.DVD
+ return True
+
def _check_file_type(self, controller, display, service_item):
"""
Select the correct media Player type from the prioritized Player list
=== modified file 'openlp/core/ui/media/vlcplayer.py'
--- openlp/core/ui/media/vlcplayer.py 2014-08-27 23:18:06 +0000
+++ openlp/core/ui/media/vlcplayer.py 2014-09-02 20:29:54 +0000
@@ -40,7 +40,7 @@
from openlp.core.common import Settings, is_win, is_macosx
from openlp.core.lib import translate
-from openlp.core.ui.media import MediaState
+from openlp.core.ui.media import MediaState, MediaType
from openlp.core.ui.media.mediaplayer import MediaPlayer
log = logging.getLogger(__name__)
@@ -166,7 +166,19 @@
file_path = str(controller.media_info.file_info.absoluteFilePath())
path = os.path.normcase(file_path)
# create the media
- display.vlc_media = display.vlc_instance.media_new_path(path)
+ if controller.media_info.media_type == MediaType.CD:
+ display.vlc_media = display.vlc_instance.media_new_location('cdda://' + path)
+ display.vlc_media_player.set_media(display.vlc_media)
+ display.vlc_media_player.play()
+ # Wait for media to start playing. In this case VLC actually returns an error.
+ self.media_state_wait(display, vlc.State.Playing)
+ # If subitems exists, this is a CD
+ audio_cd_tracks = display.vlc_media.subitems()
+ if not audio_cd_tracks or audio_cd_tracks.count() < 1:
+ return False
+ display.vlc_media = audio_cd_tracks.item_at_index(controller.media_info.title_track)
+ else:
+ display.vlc_media = display.vlc_instance.media_new_path(path)
# put the media in the media player
display.vlc_media_player.set_media(display.vlc_media)
# parse the metadata of the file
@@ -206,15 +218,40 @@
"""
controller = display.controller
start_time = 0
+ log.debug('vlc play')
if self.state != MediaState.Paused and controller.media_info.start_time > 0:
start_time = controller.media_info.start_time
threading.Thread(target=display.vlc_media_player.play).start()
if not self.media_state_wait(display, vlc.State.Playing):
return False
+ if self.state != MediaState.Paused and controller.media_info.start_time > 0:
+ log.debug('vlc play, starttime set')
+ start_time = controller.media_info.start_time
+ log.debug('mediatype: ' + str(controller.media_info.media_type))
+ # Set tracks for the optical device
+ if controller.media_info.media_type == MediaType.DVD:
+ log.debug('vlc play, playing started')
+ if controller.media_info.title_track > 0:
+ log.debug('vlc play, title_track set: ' + str(controller.media_info.title_track))
+ display.vlc_media_player.set_title(controller.media_info.title_track)
+ display.vlc_media_player.play()
+ if not self.media_state_wait(display, vlc.State.Playing):
+ return False
+ if controller.media_info.audio_track > 0:
+ display.vlc_media_player.audio_set_track(controller.media_info.audio_track)
+ log.debug('vlc play, audio_track set: ' + str(controller.media_info.audio_track))
+ if controller.media_info.subtitle_track > 0:
+ display.vlc_media_player.video_set_spu(controller.media_info.subtitle_track)
+ log.debug('vlc play, subtitle_track set: ' + str(controller.media_info.subtitle_track))
+ if controller.media_info.start_time > 0:
+ log.debug('vlc play, starttime set: ' + str(controller.media_info.start_time))
+ start_time = controller.media_info.start_time
+ controller.media_info.length = controller.media_info.end_time - controller.media_info.start_time
+ else:
+ controller.media_info.length = int(display.vlc_media_player.get_media().get_duration() / 1000)
self.volume(display, controller.media_info.volume)
- if start_time > 0:
- self.seek(display, controller.media_info.start_time * 1000)
- controller.media_info.length = int(display.vlc_media_player.get_media().get_duration() / 1000)
+ if start_time > 0 and display.vlc_media_player.is_seekable():
+ display.vlc_media_player.set_time(int(start_time * 1000))
controller.seek_slider.setMaximum(controller.media_info.length * 1000)
self.state = MediaState.Playing
display.vlc_widget.raise_()
@@ -248,6 +285,9 @@
"""
Go to a particular position
"""
+ if display.controller.media_info.media_type == MediaType.CD \
+ or display.controller.media_info.media_type == MediaType.DVD:
+ seek_value += int(display.controller.media_info.start_time * 1000)
if display.vlc_media_player.is_seekable():
display.vlc_media_player.set_time(seek_value)
@@ -280,7 +320,12 @@
self.set_visible(display, False)
if not controller.seek_slider.isSliderDown():
controller.seek_slider.blockSignals(True)
- controller.seek_slider.setSliderPosition(display.vlc_media_player.get_time())
+ if display.controller.media_info.media_type == MediaType.CD \
+ or display.controller.media_info.media_type == MediaType.DVD:
+ controller.seek_slider.setSliderPosition(display.vlc_media_player.get_time() -
+ int(display.controller.media_info.start_time * 1000))
+ else:
+ controller.seek_slider.setSliderPosition(display.vlc_media_player.get_time())
controller.seek_slider.blockSignals(False)
def get_info(self):
=== added directory 'openlp/plugins/media/forms'
=== added file 'openlp/plugins/media/forms/__init__.py'
--- openlp/plugins/media/forms/__init__.py 1970-01-01 00:00:00 +0000
+++ openlp/plugins/media/forms/__init__.py 2014-09-02 20:29:54 +0000
@@ -0,0 +1,28 @@
+# -*- coding: utf-8 -*-
+# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
+
+###############################################################################
+# OpenLP - Open Source Lyrics Projection #
+# --------------------------------------------------------------------------- #
+# Copyright (c) 2008-2014 Raoul Snyman #
+# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan #
+# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
+# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. #
+# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, #
+# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
+# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, #
+# Frode Woldsund, Martin Zibricky, Patrick Zimmermann #
+# --------------------------------------------------------------------------- #
+# 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 #
+###############################################################################
=== added file 'openlp/plugins/media/forms/mediaclipselectordialog.py'
--- openlp/plugins/media/forms/mediaclipselectordialog.py 1970-01-01 00:00:00 +0000
+++ openlp/plugins/media/forms/mediaclipselectordialog.py 2014-09-02 20:29:54 +0000
@@ -0,0 +1,209 @@
+# -*- coding: utf-8 -*-
+# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
+
+###############################################################################
+# OpenLP - Open Source Lyrics Projection #
+# --------------------------------------------------------------------------- #
+# Copyright (c) 2008-2014 Raoul Snyman #
+# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan #
+# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
+# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. #
+# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, #
+# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
+# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, #
+# Frode Woldsund, Martin Zibricky, Patrick Zimmermann #
+# --------------------------------------------------------------------------- #
+# 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 #
+###############################################################################
+
+
+from PyQt4 import QtCore, QtGui
+from openlp.core.common import translate
+from openlp.core.lib import build_icon
+
+
+class Ui_MediaClipSelector(object):
+ def setupUi(self, media_clip_selector):
+ media_clip_selector.setObjectName('media_clip_selector')
+ media_clip_selector.resize(554, 654)
+ self.combobox_size_policy = QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Fixed)
+ media_clip_selector.setSizePolicy(
+ QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.MinimumExpanding))
+ self.main_layout = QtGui.QVBoxLayout(media_clip_selector)
+ self.main_layout.setContentsMargins(8, 8, 8, 8)
+ self.main_layout.setObjectName('main_layout')
+ # Source groupbox
+ self.source_groupbox = QtGui.QGroupBox(media_clip_selector)
+ self.source_groupbox.setObjectName('source_groupbox')
+ self.source_layout = QtGui.QHBoxLayout()
+ self.source_layout.setContentsMargins(8, 8, 8, 8)
+ self.source_layout.setObjectName('source_layout')
+ self.source_groupbox.setLayout(self.source_layout)
+ # Media path label
+ self.media_path_label = QtGui.QLabel(self.source_groupbox)
+ self.media_path_label.setObjectName('media_path_label')
+ self.source_layout.addWidget(self.media_path_label)
+ # Media path combobox
+ self.media_path_combobox = QtGui.QComboBox(self.source_groupbox)
+ # Make the combobox expand
+ self.media_path_combobox.setSizePolicy(self.combobox_size_policy)
+ self.media_path_combobox.setEditable(True)
+ self.media_path_combobox.setObjectName('media_path_combobox')
+ self.source_layout.addWidget(self.media_path_combobox)
+ # Load disc button
+ self.load_disc_button = QtGui.QPushButton(media_clip_selector)
+ self.load_disc_button.setEnabled(True)
+ self.load_disc_button.setObjectName('load_disc_button')
+ self.source_layout.addWidget(self.load_disc_button)
+ self.main_layout.addWidget(self.source_groupbox)
+ # Track details group box
+ self.track_groupbox = QtGui.QGroupBox(media_clip_selector)
+ self.track_groupbox.setObjectName('track_groupbox')
+ self.track_layout = QtGui.QFormLayout()
+ self.track_layout.setContentsMargins(8, 8, 8, 8)
+ self.track_layout.setObjectName('track_layout')
+ self.label_alignment = self.track_layout.labelAlignment()
+ self.track_groupbox.setLayout(self.track_layout)
+ # Title track
+ self.title_label = QtGui.QLabel(self.track_groupbox)
+ self.title_label.setObjectName('title_label')
+ self.titles_combo_box = QtGui.QComboBox(self.track_groupbox)
+ self.titles_combo_box.setSizePolicy(self.combobox_size_policy)
+ self.titles_combo_box.setEditText('')
+ self.titles_combo_box.setObjectName('titles_combo_box')
+ self.track_layout.addRow(self.title_label, self.titles_combo_box)
+ # Audio track
+ self.audio_track_label = QtGui.QLabel(self.track_groupbox)
+ self.audio_track_label.setObjectName('audio_track_label')
+ self.audio_tracks_combobox = QtGui.QComboBox(self.track_groupbox)
+ self.audio_tracks_combobox.setSizePolicy(self.combobox_size_policy)
+ self.audio_tracks_combobox.setObjectName('audio_tracks_combobox')
+ self.track_layout.addRow(self.audio_track_label, self.audio_tracks_combobox)
+ self.main_layout.addWidget(self.track_groupbox)
+ # Subtitle track
+ self.subtitle_track_label = QtGui.QLabel(self.track_groupbox)
+ self.subtitle_track_label.setObjectName('subtitle_track_label')
+ self.subtitle_tracks_combobox = QtGui.QComboBox(self.track_groupbox)
+ self.subtitle_tracks_combobox.setSizePolicy(self.combobox_size_policy)
+ self.subtitle_tracks_combobox.setObjectName('subtitle_tracks_combobox')
+ self.track_layout.addRow(self.subtitle_track_label, self.subtitle_tracks_combobox)
+ # Preview frame
+ self.preview_frame = QtGui.QFrame(media_clip_selector)
+ self.preview_frame.setMinimumSize(QtCore.QSize(320, 240))
+ self.preview_frame.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding,
+ QtGui.QSizePolicy.MinimumExpanding))
+ self.preview_frame.setStyleSheet('background-color:black;')
+ self.preview_frame.setFrameShape(QtGui.QFrame.NoFrame)
+ self.preview_frame.setObjectName('preview_frame')
+ self.main_layout.addWidget(self.preview_frame)
+ # player controls
+ self.controls_layout = QtGui.QHBoxLayout()
+ self.controls_layout.setObjectName('controls_layout')
+ self.play_button = QtGui.QToolButton(media_clip_selector)
+ self.play_button.setIcon(build_icon(':/slides/media_playback_start.png'))
+ self.play_button.setObjectName('play_button')
+ self.controls_layout.addWidget(self.play_button)
+ self.position_slider = QtGui.QSlider(media_clip_selector)
+ self.position_slider.setTracking(False)
+ self.position_slider.setOrientation(QtCore.Qt.Horizontal)
+ self.position_slider.setObjectName('position_slider')
+ self.controls_layout.addWidget(self.position_slider)
+ self.position_timeedit = QtGui.QTimeEdit(media_clip_selector)
+ self.position_timeedit.setReadOnly(True)
+ self.position_timeedit.setObjectName('position_timeedit')
+ self.controls_layout.addWidget(self.position_timeedit)
+ self.main_layout.addLayout(self.controls_layout)
+ # Range
+ self.range_groupbox = QtGui.QGroupBox(media_clip_selector)
+ self.range_groupbox.setObjectName('range_groupbox')
+ self.range_layout = QtGui.QGridLayout()
+ self.range_layout.setContentsMargins(8, 8, 8, 8)
+ self.range_layout.setObjectName('range_layout')
+ self.range_groupbox.setLayout(self.range_layout)
+ # Start position
+ self.start_position_label = QtGui.QLabel(self.range_groupbox)
+ self.start_position_label.setObjectName('start_position_label')
+ self.range_layout.addWidget(self.start_position_label, 0, 0, self.label_alignment)
+ self.start_position_edit = QtGui.QTimeEdit(self.range_groupbox)
+ self.start_position_edit.setObjectName('start_position_edit')
+ self.range_layout.addWidget(self.start_position_edit, 0, 1)
+ self.set_start_button = QtGui.QPushButton(self.range_groupbox)
+ self.set_start_button.setObjectName('set_start_button')
+ self.range_layout.addWidget(self.set_start_button, 0, 2)
+ self.jump_start_button = QtGui.QPushButton(self.range_groupbox)
+ self.jump_start_button.setObjectName('jump_start_button')
+ self.range_layout.addWidget(self.jump_start_button, 0, 3)
+ # End position
+ self.end_position_label = QtGui.QLabel(self.range_groupbox)
+ self.end_position_label.setObjectName('end_position_label')
+ self.range_layout.addWidget(self.end_position_label, 1, 0, self.label_alignment)
+ self.end_timeedit = QtGui.QTimeEdit(self.range_groupbox)
+ self.end_timeedit.setObjectName('end_timeedit')
+ self.range_layout.addWidget(self.end_timeedit, 1, 1)
+ self.set_end_button = QtGui.QPushButton(self.range_groupbox)
+ self.set_end_button.setObjectName('set_end_button')
+ self.range_layout.addWidget(self.set_end_button, 1, 2)
+ self.jump_end_button = QtGui.QPushButton(self.range_groupbox)
+ self.jump_end_button.setObjectName('jump_end_button')
+ self.range_layout.addWidget(self.jump_end_button, 1, 3)
+ self.main_layout.addWidget(self.range_groupbox)
+ # Save and close buttons
+ self.button_box = QtGui.QDialogButtonBox(media_clip_selector)
+ self.button_box.addButton(QtGui.QDialogButtonBox.Save)
+ self.button_box.addButton(QtGui.QDialogButtonBox.Close)
+ self.close_button = self.button_box.button(QtGui.QDialogButtonBox.Close)
+ self.save_button = self.button_box.button(QtGui.QDialogButtonBox.Save)
+ self.main_layout.addWidget(self.button_box)
+
+ self.retranslateUi(media_clip_selector)
+ self.button_box.accepted.connect(media_clip_selector.accept)
+ self.button_box.rejected.connect(media_clip_selector.reject)
+ QtCore.QMetaObject.connectSlotsByName(media_clip_selector)
+ media_clip_selector.setTabOrder(self.media_path_combobox, self.load_disc_button)
+ media_clip_selector.setTabOrder(self.load_disc_button, self.titles_combo_box)
+ media_clip_selector.setTabOrder(self.titles_combo_box, self.audio_tracks_combobox)
+ media_clip_selector.setTabOrder(self.audio_tracks_combobox, self.subtitle_tracks_combobox)
+ media_clip_selector.setTabOrder(self.subtitle_tracks_combobox, self.play_button)
+ media_clip_selector.setTabOrder(self.play_button, self.position_slider)
+ media_clip_selector.setTabOrder(self.position_slider, self.position_timeedit)
+ media_clip_selector.setTabOrder(self.position_timeedit, self.start_position_edit)
+ media_clip_selector.setTabOrder(self.start_position_edit, self.set_start_button)
+ media_clip_selector.setTabOrder(self.set_start_button, self.jump_start_button)
+ media_clip_selector.setTabOrder(self.jump_start_button, self.end_timeedit)
+ media_clip_selector.setTabOrder(self.end_timeedit, self.set_end_button)
+ media_clip_selector.setTabOrder(self.set_end_button, self.jump_end_button)
+ media_clip_selector.setTabOrder(self.jump_end_button, self.save_button)
+ media_clip_selector.setTabOrder(self.save_button, self.close_button)
+
+ def retranslateUi(self, media_clip_selector):
+ media_clip_selector.setWindowTitle(translate('MediaPlugin.MediaClipSelector', 'Select Media Clip'))
+ self.source_groupbox.setTitle(translate('MediaPlugin.MediaClipSelector', 'Source'))
+ self.media_path_label.setText(translate('MediaPlugin.MediaClipSelector', 'Media path:'))
+ self.media_path_combobox.lineEdit().setPlaceholderText(translate('MediaPlugin.MediaClipSelector',
+ 'Select drive from list'))
+ self.load_disc_button.setText(translate('MediaPlugin.MediaClipSelector', 'Load disc'))
+ self.track_groupbox.setTitle(translate('MediaPlugin.MediaClipSelector', 'Track Details'))
+ self.title_label.setText(translate('MediaPlugin.MediaClipSelector', 'Title:'))
+ self.audio_track_label.setText(translate('MediaPlugin.MediaClipSelector', 'Audio track:'))
+ self.subtitle_track_label.setText(translate('MediaPlugin.MediaClipSelector', 'Subtitle track:'))
+ self.position_timeedit.setDisplayFormat(translate('MediaPlugin.MediaClipSelector', 'HH:mm:ss.z'))
+ self.range_groupbox.setTitle(translate('MediaPlugin.MediaClipSelector', 'Clip Range'))
+ self.start_position_label.setText(translate('MediaPlugin.MediaClipSelector', 'Start point:'))
+ self.start_position_edit.setDisplayFormat(translate('MediaPlugin.MediaClipSelector', 'HH:mm:ss.z'))
+ self.set_start_button.setText(translate('MediaPlugin.MediaClipSelector', 'Set start point'))
+ self.jump_start_button.setText(translate('MediaPlugin.MediaClipSelector', 'Jump to start point'))
+ self.end_position_label.setText(translate('MediaPlugin.MediaClipSelector', 'End point:'))
+ self.end_timeedit.setDisplayFormat(translate('MediaPlugin.MediaClipSelector', 'HH:mm:ss.z'))
+ self.set_end_button.setText(translate('MediaPlugin.MediaClipSelector', 'Set end point'))
+ self.jump_end_button.setText(translate('MediaPlugin.MediaClipSelector', 'Jump to end point'))
=== added file 'openlp/plugins/media/forms/mediaclipselectorform.py'
--- openlp/plugins/media/forms/mediaclipselectorform.py 1970-01-01 00:00:00 +0000
+++ openlp/plugins/media/forms/mediaclipselectorform.py 2014-09-02 20:29:54 +0000
@@ -0,0 +1,665 @@
+# -*- coding: utf-8 -*-
+# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
+
+###############################################################################
+# OpenLP - Open Source Lyrics Projection #
+# --------------------------------------------------------------------------- #
+# Copyright (c) 2008-2014 Raoul Snyman #
+# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan #
+# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
+# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. #
+# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, #
+# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
+# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, #
+# Frode Woldsund, Martin Zibricky, Patrick Zimmermann #
+# --------------------------------------------------------------------------- #
+# 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
+if os.name == 'nt':
+ from win32com.client import Dispatch
+ import string
+import sys
+
+if sys.platform.startswith('linux'):
+ import dbus
+import logging
+import re
+from time import sleep
+from datetime import datetime
+
+
+from PyQt4 import QtCore, QtGui
+
+from openlp.core.common import translate
+from openlp.plugins.media.forms.mediaclipselectordialog import Ui_MediaClipSelector
+from openlp.core.lib.ui import critical_error_message_box
+from openlp.core.ui.media import format_milliseconds
+try:
+ from openlp.core.ui.media.vendor import vlc
+except (ImportError, NameError, NotImplementedError):
+ pass
+except OSError as e:
+ if sys.platform.startswith('win'):
+ if not isinstance(e, WindowsError) and e.winerror != 126:
+ raise
+ else:
+ raise
+
+log = logging.getLogger(__name__)
+
+
+class MediaClipSelectorForm(QtGui.QDialog, Ui_MediaClipSelector):
+ """
+ Class to manage the clip selection
+ """
+ log.info('%s MediaClipSelectorForm loaded', __name__)
+
+ def __init__(self, media_item, parent, manager):
+ """
+ Constructor
+ """
+ super(MediaClipSelectorForm, self).__init__(parent)
+ self.vlc_instance = None
+ self.vlc_media_player = None
+ self.vlc_media = None
+ self.timer = None
+ self.audio_cd_tracks = None
+ self.audio_cd = False
+ self.playback_length = 0
+ self.media_item = media_item
+ self.setupUi(self)
+ # setup play/pause icon
+ self.play_icon = QtGui.QIcon()
+ self.play_icon.addPixmap(QtGui.QPixmap(":/slides/media_playback_start.png"), QtGui.QIcon.Normal,
+ QtGui.QIcon.Off)
+ self.pause_icon = QtGui.QIcon()
+ self.pause_icon.addPixmap(QtGui.QPixmap(":/slides/media_playback_pause.png"), QtGui.QIcon.Normal,
+ QtGui.QIcon.Off)
+
+ def reject(self):
+ """
+ Exit Dialog and do not save
+ """
+ log.debug('MediaClipSelectorForm.reject')
+ # Tear down vlc
+ if self.vlc_media_player:
+ self.vlc_media_player.stop()
+ self.vlc_media_player.release()
+ self.vlc_media_player = None
+ if self.vlc_instance:
+ self.vlc_instance.release()
+ self.vlc_instance = None
+ if self.vlc_media:
+ self.vlc_media.release()
+ self.vlc_media = None
+ return QtGui.QDialog.reject(self)
+
+ def exec_(self):
+ """
+ Start dialog
+ """
+ self.reset_ui()
+ self.setup_vlc()
+ return QtGui.QDialog.exec_(self)
+
+ def reset_ui(self):
+ """
+ Reset the UI to default values
+ """
+ self.playback_length = 0
+ self.position_slider.setMinimum(0)
+ self.disable_all()
+ self.toggle_disable_load_media(False)
+ self.subtitle_tracks_combobox.clear()
+ self.audio_tracks_combobox.clear()
+ self.titles_combo_box.clear()
+ time = QtCore.QTime()
+ self.start_position_edit.setTime(time)
+ self.end_timeedit.setTime(time)
+ self.position_timeedit.setTime(time)
+
+ def setup_vlc(self):
+ """
+ Setup VLC instance and mediaplayer
+ """
+ self.vlc_instance = vlc.Instance()
+ # creating an empty vlc media player
+ self.vlc_media_player = self.vlc_instance.media_player_new()
+ # The media player has to be 'connected' to the QFrame.
+ # (otherwise a video would be displayed in it's own window)
+ # This is platform specific!
+ # You have to give the id of the QFrame (or similar object)
+ # to vlc, different platforms have different functions for this.
+ win_id = int(self.preview_frame.winId())
+ if sys.platform == "win32":
+ self.vlc_media_player.set_hwnd(win_id)
+ elif sys.platform == "darwin":
+ # We have to use 'set_nsobject' since Qt4 on OSX uses Cocoa
+ # framework and not the old Carbon.
+ self.vlc_media_player.set_nsobject(win_id)
+ else:
+ # for Linux using the X Server
+ self.vlc_media_player.set_xwindow(win_id)
+ self.vlc_media = None
+ # Setup timer every 100 ms to update position
+ self.timer = QtCore.QTimer(self)
+ self.timer.timeout.connect(self.update_position)
+ self.timer.start(100)
+ self.find_optical_devices()
+ self.audio_cd = False
+ self.audio_cd_tracks = None
+
+ def detect_audio_cd(self, path):
+ """
+ Detects is the given path is an audio CD
+
+ :param path: Path to the device to be tested.
+ :return: True if it was an audio CD else False.
+ """
+ # Detect by trying to play it as a CD
+ self.vlc_media = self.vlc_instance.media_new_location('cdda://' + path)
+ self.vlc_media_player.set_media(self.vlc_media)
+ self.vlc_media_player.play()
+ # Wait for media to start playing. In this case VLC actually returns an error.
+ self.media_state_wait(vlc.State.Playing)
+ self.vlc_media_player.set_pause(1)
+ # If subitems exists, this is a CD
+ self.audio_cd_tracks = self.vlc_media.subitems()
+ if not self.audio_cd_tracks or self.audio_cd_tracks.count() < 1:
+ return False
+ # Insert into titles_combo_box
+ self.titles_combo_box.clear()
+ for i in range(self.audio_cd_tracks.count()):
+ item = self.audio_cd_tracks.item_at_index(i)
+ item_title = item.get_meta(vlc.Meta.Title)
+ self.titles_combo_box.addItem(item_title, i)
+ self.vlc_media_player.set_media(self.audio_cd_tracks.item_at_index(0))
+ self.audio_cd = True
+ self.titles_combo_box.setDisabled(False)
+ self.titles_combo_box.setCurrentIndex(0)
+ self.on_title_combo_box_currentIndexChanged(0)
+
+ return True
+
+ @QtCore.pyqtSlot(bool)
+ def on_load_disc_button_clicked(self, clicked):
+ """
+ Load the media when the load-button has been clicked
+
+ :param clicked: Given from signal, not used.
+ """
+ log.debug('on_load_disc_button_clicked')
+ self.disable_all()
+ path = self.media_path_combobox.currentText()
+ # Check if given path is non-empty and exists before starting VLC
+ if not path:
+ log.debug('no given path')
+ critical_error_message_box(message=translate('MediaPlugin.MediaClipSelectorForm', 'No path was given'))
+ self.toggle_disable_load_media(False)
+ return
+ if not os.path.exists(path):
+ log.debug('Given path does not exists')
+ critical_error_message_box(message=translate('MediaPlugin.MediaClipSelectorForm',
+ 'Given path does not exists'))
+ self.toggle_disable_load_media(False)
+ return
+ # VLC behaves a bit differently on windows and linux when loading, which creates problems when trying to
+ # detect if we're dealing with a DVD or CD, so we use different loading approaches depending on the OS.
+ if os.name == 'nt':
+ # If the given path is in the format "D:\" or "D:", prefix it with "/" to make VLC happy
+ pattern = re.compile('^\w:\\\\*$')
+ if pattern.match(path):
+ path = '/' + path
+ self.vlc_media = self.vlc_instance.media_new_location('dvd://' + path)
+ else:
+ self.vlc_media = self.vlc_instance.media_new_path(path)
+ if not self.vlc_media:
+ log.debug('vlc media player is none')
+ critical_error_message_box(message=translate('MediaPlugin.MediaClipSelectorForm',
+ 'An error happened during initialization of VLC player'))
+ self.toggle_disable_load_media(False)
+ return
+ # put the media in the media player
+ self.vlc_media_player.set_media(self.vlc_media)
+ self.vlc_media_player.audio_set_mute(True)
+ # start playback to get vlc to parse the media
+ if self.vlc_media_player.play() < 0:
+ log.debug('vlc play returned error')
+ critical_error_message_box(message=translate('MediaPlugin.MediaClipSelectorForm',
+ 'VLC player failed playing the media'))
+ self.toggle_disable_load_media(False)
+ return
+ self.vlc_media_player.audio_set_mute(True)
+ if not self.media_state_wait(vlc.State.Playing):
+ # Tests if this is an audio CD
+ if not self.detect_audio_cd(path):
+ critical_error_message_box(message=translate('MediaPlugin.MediaClipSelectorForm',
+ 'VLC player failed playing the media'))
+ self.toggle_disable_load_media(False)
+ return
+ self.vlc_media_player.audio_set_mute(True)
+ if not self.audio_cd:
+ # Get titles, insert in combobox
+ titles = self.vlc_media_player.video_get_title_description()
+ self.titles_combo_box.clear()
+ for title in titles:
+ self.titles_combo_box.addItem(title[1].decode(), title[0])
+ # Main title is usually title #1
+ if len(titles) > 1:
+ self.titles_combo_box.setCurrentIndex(1)
+ else:
+ self.titles_combo_box.setCurrentIndex(0)
+ # Enable audio track combobox if anything is in it
+ if len(titles) > 0:
+ self.titles_combo_box.setDisabled(False)
+ self.toggle_disable_load_media(False)
+ log.debug('load_disc_button end - vlc_media_player state: %s' % self.vlc_media_player.get_state())
+
+ @QtCore.pyqtSlot(bool)
+ def on_play_button_clicked(self, clicked):
+ """
+ Toggle the playback
+
+ :param clicked: Given from signal, not used.
+ """
+ if self.vlc_media_player.get_state() == vlc.State.Playing:
+ self.vlc_media_player.pause()
+ self.play_button.setIcon(self.play_icon)
+ else:
+ self.vlc_media_player.play()
+ self.media_state_wait(vlc.State.Playing)
+ self.play_button.setIcon(self.pause_icon)
+
+ @QtCore.pyqtSlot(bool)
+ def on_set_start_button_clicked(self, clicked):
+ """
+ Copy the current player position to start_position_edit
+
+ :param clicked: Given from signal, not used.
+ """
+ vlc_ms_pos = self.vlc_media_player.get_time()
+ time = QtCore.QTime()
+ new_pos_time = time.addMSecs(vlc_ms_pos)
+ self.start_position_edit.setTime(new_pos_time)
+ # If start time is after end time, update end time.
+ end_time = self.end_timeedit.time()
+ if end_time < new_pos_time:
+ self.end_timeedit.setTime(new_pos_time)
+
+ @QtCore.pyqtSlot(bool)
+ def on_set_end_button_clicked(self, clicked):
+ """
+ Copy the current player position to end_timeedit
+
+ :param clicked: Given from signal, not used.
+ """
+ vlc_ms_pos = self.vlc_media_player.get_time()
+ time = QtCore.QTime()
+ new_pos_time = time.addMSecs(vlc_ms_pos)
+ self.end_timeedit.setTime(new_pos_time)
+ # If start time is after end time, update start time.
+ start_time = self.start_position_edit.time()
+ if start_time > new_pos_time:
+ self.start_position_edit.setTime(new_pos_time)
+
+ @QtCore.pyqtSlot(QtCore.QTime)
+ def on_start_timeedit_timeChanged(self, new_time):
+ """
+ Called when start_position_edit is changed manually
+
+ :param new_time: The new time
+ """
+ # If start time is after end time, update end time.
+ end_time = self.end_timeedit.time()
+ if end_time < new_time:
+ self.end_timeedit.setTime(new_time)
+
+ @QtCore.pyqtSlot(QtCore.QTime)
+ def on_end_timeedit_timeChanged(self, new_time):
+ """
+ Called when end_timeedit is changed manually
+
+ :param new_time: The new time
+ """
+ # If start time is after end time, update start time.
+ start_time = self.start_position_edit.time()
+ if start_time > new_time:
+ self.start_position_edit.setTime(new_time)
+
+ @QtCore.pyqtSlot(bool)
+ def on_jump_end_button_clicked(self, clicked):
+ """
+ Set the player position to the position stored in end_timeedit
+
+ :param clicked: Given from signal, not used.
+ """
+ end_time = self.end_timeedit.time()
+ end_time_ms = end_time.hour() * 60 * 60 * 1000 + \
+ end_time.minute() * 60 * 1000 + \
+ end_time.second() * 1000 + \
+ end_time.msec()
+ self.vlc_media_player.set_time(end_time_ms)
+
+ @QtCore.pyqtSlot(bool)
+ def on_jump_start_button_clicked(self, clicked):
+ """
+ Set the player position to the position stored in start_position_edit
+
+ :param clicked: Given from signal, not used.
+ """
+ start_time = self.start_position_edit.time()
+ start_time_ms = start_time.hour() * 60 * 60 * 1000 + \
+ start_time.minute() * 60 * 1000 + \
+ start_time.second() * 1000 + \
+ start_time.msec()
+ self.vlc_media_player.set_time(start_time_ms)
+
+ @QtCore.pyqtSlot(int)
+ def on_titles_combo_box_currentIndexChanged(self, index):
+ """
+ When a new title is chosen, it is loaded by VLC and info about audio and subtitle tracks is reloaded
+
+ :param index: The index of the newly chosen title track.
+ """
+ log.debug('in on_titles_combo_box_changed, index: %d', index)
+ if not self.vlc_media_player:
+ log.error('vlc_media_player was None')
+ return
+ if self.audio_cd:
+ self.vlc_media = self.audio_cd_tracks.item_at_index(index)
+ self.vlc_media_player.set_media(self.vlc_media)
+ self.vlc_media_player.set_time(0)
+ self.vlc_media_player.play()
+ if not self.media_state_wait(vlc.State.Playing):
+ log.error('Could not start playing audio cd, needed to get track info')
+ return
+ self.vlc_media_player.audio_set_mute(True)
+ # Sleep 1 second to make sure VLC has the needed metadata
+ sleep(1)
+ # pause
+ self.vlc_media_player.set_time(0)
+ self.vlc_media_player.set_pause(1)
+ self.vlc_media_player.audio_set_mute(False)
+ self.toggle_disable_player(False)
+ else:
+ self.vlc_media_player.set_title(index)
+ self.vlc_media_player.set_time(0)
+ self.vlc_media_player.play()
+ if not self.media_state_wait(vlc.State.Playing):
+ log.error('Could not start playing dvd, needed to get track info')
+ return
+ self.vlc_media_player.audio_set_mute(True)
+ # Sleep 1 second to make sure VLC has the needed metadata
+ sleep(1)
+ self.vlc_media_player.set_time(0)
+ # Get audio tracks, insert in combobox
+ audio_tracks = self.vlc_media_player.audio_get_track_description()
+ self.audio_tracks_combobox.clear()
+ for audio_track in audio_tracks:
+ self.audio_tracks_combobox.addItem(audio_track[1].decode(), audio_track[0])
+ # Enable audio track combobox if anything is in it
+ if len(audio_tracks) > 0:
+ self.audio_tracks_combobox.setDisabled(False)
+ # First track is "deactivated", so set to next if it exists
+ if len(audio_tracks) > 1:
+ self.audio_tracks_combobox.setCurrentIndex(1)
+ # Get subtitle tracks, insert in combobox
+ subtitles_tracks = self.vlc_media_player.video_get_spu_description()
+ self.subtitle_tracks_combobox.clear()
+ for subtitle_track in subtitles_tracks:
+ self.subtitle_tracks_combobox.addItem(subtitle_track[1].decode(), subtitle_track[0])
+ # Enable subtitle track combobox is anything in it
+ if len(subtitles_tracks) > 0:
+ self.subtitle_tracks_combobox.setDisabled(False)
+ self.vlc_media_player.audio_set_mute(False)
+ self.vlc_media_player.set_pause(1)
+ # If a title or audio track is available the player is enabled
+ if self.titles_combo_box.count() > 0 or len(audio_tracks) > 0:
+ self.toggle_disable_player(False)
+ # Set media length info
+ self.playback_length = self.vlc_media_player.get_length()
+ log.debug('playback_length: %d ms' % self.playback_length)
+ self.position_slider.setMaximum(self.playback_length)
+ # setup start and end time
+ rounded_vlc_ms_length = int(round(self.playback_length / 100.0) * 100.0)
+ time = QtCore.QTime()
+ playback_length_time = time.addMSecs(rounded_vlc_ms_length)
+ self.start_position_edit.setMaximumTime(playback_length_time)
+ self.end_timeedit.setMaximumTime(playback_length_time)
+ self.end_timeedit.setTime(playback_length_time)
+ # Pause once again, just to make sure
+ loop_count = 0
+ while self.vlc_media_player.get_state() == vlc.State.Playing and loop_count < 20:
+ sleep(0.1)
+ self.vlc_media_player.set_pause(1)
+ loop_count += 1
+ log.debug('titles_combo_box end - vlc_media_player state: %s' % self.vlc_media_player.get_state())
+
+ @QtCore.pyqtSlot(int)
+ def on_audio_tracks_combobox_currentIndexChanged(self, index):
+ """
+ When a new audio track is chosen update audio track bing played by VLC
+
+ :param index: The index of the newly chosen audio track.
+ """
+ if not self.vlc_media_player:
+ return
+ audio_track = self.audio_tracks_combobox.itemData(index)
+ log.debug('in on_audio_tracks_combobox_currentIndexChanged, index: %d audio_track: %s' % (index, audio_track))
+ if audio_track and int(audio_track) > 0:
+ self.vlc_media_player.audio_set_track(int(audio_track))
+
+ @QtCore.pyqtSlot(int)
+ def on_subtitle_tracks_combobox_currentIndexChanged(self, index):
+ """
+ When a new subtitle track is chosen update subtitle track bing played by VLC
+
+ :param index: The index of the newly chosen subtitle.
+ """
+ if not self.vlc_media_player:
+ return
+ subtitle_track = self.subtitle_tracks_combobox.itemData(index)
+ if subtitle_track:
+ self.vlc_media_player.video_set_spu(int(subtitle_track))
+
+ def on_position_slider_sliderMoved(self, position):
+ """
+ Set player position according to new slider position.
+
+ :param position: Position to seek to.
+ """
+ self.vlc_media_player.set_time(position)
+
+ def update_position(self):
+ """
+ Update slider position and displayed time according to VLC player position.
+ """
+ if self.vlc_media_player:
+ vlc_ms_pos = self.vlc_media_player.get_time()
+ rounded_vlc_ms_pos = int(round(vlc_ms_pos / 100.0) * 100.0)
+ time = QtCore.QTime()
+ new_pos_time = time.addMSecs(rounded_vlc_ms_pos)
+ self.position_timeedit.setTime(new_pos_time)
+ self.position_slider.setSliderPosition(vlc_ms_pos)
+
+ def disable_all(self):
+ """
+ Disable all elements in the dialog
+ """
+ self.toggle_disable_load_media(True)
+ self.titles_combo_box.setDisabled(True)
+ self.audio_tracks_combobox.setDisabled(True)
+ self.subtitle_tracks_combobox.setDisabled(True)
+ self.toggle_disable_player(True)
+
+ def toggle_disable_load_media(self, action):
+ """
+ Enable/disable load media combobox and button.
+
+ :param action: If True elements are disabled, if False they are enabled.
+ """
+ self.media_path_combobox.setDisabled(action)
+ self.load_disc_button.setDisabled(action)
+
+ def toggle_disable_player(self, action):
+ """
+ Enable/disable player elements.
+
+ :param action: If True elements are disabled, if False they are enabled.
+ """
+ self.play_button.setDisabled(action)
+ self.position_slider.setDisabled(action)
+ self.position_timeedit.setDisabled(action)
+ self.start_position_edit.setDisabled(action)
+ self.set_start_button.setDisabled(action)
+ self.jump_start_button.setDisabled(action)
+ self.end_timeedit.setDisabled(action)
+ self.set_end_button.setDisabled(action)
+ self.jump_end_button.setDisabled(action)
+ self.save_button.setDisabled(action)
+
+ def accept(self):
+ """
+ Saves the current media and trackinfo as a clip to the mediamanager
+ """
+ log.debug('in on_save_button_clicked')
+ start_time = self.start_position_edit.time()
+ start_time_ms = start_time.hour() * 60 * 60 * 1000 + \
+ start_time.minute() * 60 * 1000 + \
+ start_time.second() * 1000 + \
+ start_time.msec()
+ end_time = self.end_timeedit.time()
+ end_time_ms = end_time.hour() * 60 * 60 * 1000 + \
+ end_time.minute() * 60 * 1000 + \
+ end_time.second() * 1000 + \
+ end_time.msec()
+ title = self.titles_combo_box.itemData(self.titles_combo_box.currentIndex())
+ path = self.media_path_combobox.currentText()
+ optical = ''
+ if self.audio_cd:
+ optical = 'optical:%d:-1:-1:%d:%d:' % (title, start_time_ms, end_time_ms)
+ else:
+ audio_track = self.audio_tracks_combobox.itemData(self.audio_tracks_combobox.currentIndex())
+ subtitle_track = self.subtitle_tracks_combobox.itemData(self.subtitle_tracks_combobox.currentIndex())
+ optical = 'optical:%d:%d:%d:%d:%d:' % (title, audio_track, subtitle_track, start_time_ms, end_time_ms)
+ # Ask for an alternative name for the mediaclip
+ while True:
+ new_optical_name, ok = QtGui.QInputDialog.getText(self, translate('MediaPlugin.MediaClipSelectorForm',
+ 'Set name of mediaclip'),
+ translate('MediaPlugin.MediaClipSelectorForm',
+ 'Name of mediaclip:'),
+ QtGui.QLineEdit.Normal)
+ # User pressed cancel, don't save the clip
+ if not ok:
+ return
+ # User pressed ok, but the input text is blank
+ if not new_optical_name:
+ critical_error_message_box(translate('MediaPlugin.MediaClipSelectorForm',
+ 'Enter a valid name or cancel'),
+ translate('MediaPlugin.MediaClipSelectorForm',
+ 'Enter a valid name or cancel'))
+ # The entered new name contains a colon, which we don't allow because colons is used to seperate clip info
+ elif new_optical_name.find(':') >= 0:
+ critical_error_message_box(translate('MediaPlugin.MediaClipSelectorForm', 'Invalid character'),
+ translate('MediaPlugin.MediaClipSelectorForm',
+ 'The name of the mediaclip must not contain the character ":"'))
+ # New name entered and we use it
+ else:
+ break
+ # Append the new name to the optical string and the path
+ optical += new_optical_name + ':' + path
+ self.media_item.add_optical_clip(optical)
+
+ def media_state_wait(self, media_state):
+ """
+ Wait for the video to change its state
+ Wait no longer than 15 seconds. (loading an optical disc takes some time)
+
+ :param media_state: VLC media state to wait for.
+ :return: True if state was reached within 15 seconds, False if not or error occurred.
+ """
+ start = datetime.now()
+ while media_state != self.vlc_media_player.get_state():
+ if self.vlc_media_player.get_state() == vlc.State.Error:
+ return False
+ if (datetime.now() - start).seconds > 30:
+ return False
+ return True
+
+ def find_optical_devices(self):
+ """
+ Attempt to autodetect optical devices on the computer, and add them to the media-dropdown
+ :return:
+ """
+ # Clear list first
+ self.media_path_combobox.clear()
+ if os.name == 'nt':
+ # use win api to find optical drives
+ fso = Dispatch('scripting.filesystemobject')
+ for drive in fso.Drives:
+ log.debug('Drive %s has type %d' % (drive.DriveLetter, drive.DriveType))
+ # if type is 4, it is a cd-rom drive
+ if drive.DriveType == 4:
+ self.media_path_combobox.addItem('%s:\\' % drive.DriveLetter)
+ elif sys.platform.startswith('linux'):
+ # Get disc devices from dbus and find the ones that are optical
+ bus = dbus.SystemBus()
+ try:
+ udev_manager_obj = bus.get_object('org.freedesktop.UDisks', '/org/freedesktop/UDisks')
+ udev_manager = dbus.Interface(udev_manager_obj, 'org.freedesktop.UDisks')
+ for dev in udev_manager.EnumerateDevices():
+ device_obj = bus.get_object("org.freedesktop.UDisks", dev)
+ device_props = dbus.Interface(device_obj, dbus.PROPERTIES_IFACE)
+ if device_props.Get('org.freedesktop.UDisks.Device', 'DeviceIsDrive'):
+ drive_props = device_props.Get('org.freedesktop.UDisks.Device', 'DriveMediaCompatibility')
+ if any('optical' in prop for prop in drive_props):
+ self.media_path_combobox.addItem(device_props.Get('org.freedesktop.UDisks.Device',
+ 'DeviceFile'))
+ return
+ except dbus.exceptions.DBusException:
+ log.debug('could not use udisks, will try udisks2')
+ udev_manager_obj = bus.get_object('org.freedesktop.UDisks2', '/org/freedesktop/UDisks2')
+ udev_manager = dbus.Interface(udev_manager_obj, 'org.freedesktop.DBus.ObjectManager')
+ for k, v in udev_manager.GetManagedObjects().items():
+ drive_info = v.get('org.freedesktop.UDisks2.Drive', {})
+ drive_props = drive_info.get('MediaCompatibility')
+ if drive_props and any('optical' in prop for prop in drive_props):
+ for device in udev_manager.GetManagedObjects().values():
+ if dbus.String('org.freedesktop.UDisks2.Block') in device:
+ if device[dbus.String('org.freedesktop.UDisks2.Block')][dbus.String('Drive')] == k:
+ block_file = ''
+ for c in device[dbus.String('org.freedesktop.UDisks2.Block')][
+ dbus.String('PreferredDevice')]:
+ if chr(c) != '\x00':
+ block_file += chr(c)
+ self.media_path_combobox.addItem(block_file)
+ elif sys.platform.startswith('darwin'):
+ # Look for DVD folders in devices to find optical devices
+ volumes = os.listdir('/Volumes')
+ candidates = list()
+ for volume in volumes:
+ if volume.startswith('.'):
+ continue
+ dirs = os.listdir('/Volumes/' + volume)
+ # Detect DVD
+ if 'VIDEO_TS' in dirs:
+ self.media_path_combobox.addItem('/Volumes/' + volume)
+ # Detect audio cd
+ files = [f for f in dirs if os.path.isfile(f)]
+ for file in files:
+ if file.endswith('aiff'):
+ self.media_path_combobox.addItem('/Volumes/' + volume)
+ break
=== modified file 'openlp/plugins/media/lib/mediaitem.py'
--- openlp/plugins/media/lib/mediaitem.py 2014-05-03 20:00:17 +0000
+++ openlp/plugins/media/lib/mediaitem.py 2014-09-02 20:29:54 +0000
@@ -29,6 +29,7 @@
import logging
import os
+from datetime import time
from PyQt4 import QtCore, QtGui
@@ -38,17 +39,21 @@
build_icon, check_item_selected
from openlp.core.lib.ui import critical_error_message_box, create_horizontal_adjusting_combo_box
from openlp.core.ui import DisplayController, Display, DisplayControllerType
-from openlp.core.ui.media import get_media_players, set_media_players
+from openlp.core.ui.media import get_media_players, set_media_players, parse_optical_path, format_milliseconds
from openlp.core.utils import get_locale_key
+from openlp.core.ui.media.vlcplayer import VLC_AVAILABLE
+if VLC_AVAILABLE:
+ from openlp.plugins.media.forms.mediaclipselectorform import MediaClipSelectorForm
log = logging.getLogger(__name__)
CLAPPERBOARD = ':/media/slidecontroller_multimedia.png'
+OPTICAL = ':/media/media_optical.png'
VIDEO_ICON = build_icon(':/media/media_video.png')
AUDIO_ICON = build_icon(':/media/media_audio.png')
-DVD_ICON = build_icon(':/media/media_video.png')
+OPTICAL_ICON = build_icon(OPTICAL)
ERROR_ICON = build_icon(':/general/general_delete.png')
@@ -88,6 +93,10 @@
self.list_view.activateDnD()
def retranslateUi(self):
+ """
+ This method is called automatically to provide OpenLP with the opportunity to translate the ``MediaManagerItem``
+ to another language.
+ """
self.on_new_prompt = translate('MediaPlugin.MediaItem', 'Select Media')
self.replace_action.setText(UiStrings().ReplaceBG)
self.replace_action.setToolTip(UiStrings().ReplaceLiveBG)
@@ -106,10 +115,35 @@
self.has_edit_icon = False
def add_list_view_to_toolbar(self):
+ """
+ Creates the main widget for listing items.
+ """
MediaManagerItem.add_list_view_to_toolbar(self)
self.list_view.addAction(self.replace_action)
+ def add_start_header_bar(self):
+ """
+ Adds buttons to the start of the header bar.
+ """
+ if 'vlc' in get_media_players()[0]:
+ diable_optical_button_text = False
+ optical_button_text = translate('MediaPlugin.MediaItem', 'Load CD/DVD')
+ optical_button_tooltip = translate('MediaPlugin.MediaItem', 'Load CD/DVD')
+ else:
+ diable_optical_button_text = True
+ optical_button_text = translate('MediaPlugin.MediaItem', 'Load CD/DVD')
+ optical_button_tooltip = translate('MediaPlugin.MediaItem',
+ 'Load CD/DVD - only supported when VLC is installed and enabled')
+ self.load_optical = self.toolbar.add_toolbar_action('load_optical', icon=OPTICAL_ICON, text=optical_button_text,
+ tooltip=optical_button_tooltip,
+ triggers=self.on_load_optical)
+ if diable_optical_button_text:
+ self.load_optical.setDisabled(True)
+
def add_end_header_bar(self):
+ """
+ Adds buttons to the end of the header bar.
+ """
# Replace backgrounds do not work at present so remove functionality.
self.replace_action = self.toolbar.add_toolbar_action('replace_action', icon=':/slides/slide_blank.png',
triggers=self.on_replace_click)
@@ -198,22 +232,42 @@
if item is None:
return False
filename = item.data(QtCore.Qt.UserRole)
- if not os.path.exists(filename):
- if not remote:
- # File is no longer present
- critical_error_message_box(
- translate('MediaPlugin.MediaItem', 'Missing Media File'),
- translate('MediaPlugin.MediaItem', 'The file %s no longer exists.') % filename)
- return False
- (path, name) = os.path.split(filename)
- service_item.title = name
- service_item.processor = self.display_type_combo_box.currentText()
- service_item.add_from_command(path, name, CLAPPERBOARD)
- # Only get start and end times if going to a service
- if context == ServiceItemContext.Service:
- # Start media and obtain the length
- if not self.media_controller.media_length(service_item):
- return False
+ # Special handling if the filename is a optical clip
+ if filename.startswith('optical:'):
+ (name, title, audio_track, subtitle_track, start, end, clip_name) = parse_optical_path(filename)
+ if not os.path.exists(name):
+ if not remote:
+ # Optical disc is no longer present
+ critical_error_message_box(
+ translate('MediaPlugin.MediaItem', 'Missing Media File'),
+ translate('MediaPlugin.MediaItem', 'The optical disc %s is no longer available.') % name)
+ return False
+ service_item.processor = self.display_type_combo_box.currentText()
+ service_item.add_from_command(filename, name, CLAPPERBOARD)
+ service_item.title = clip_name
+ # Set the length
+ self.media_controller.media_setup_optical(name, title, audio_track, subtitle_track, start, end, None, None)
+ service_item.set_media_length((end - start) / 1000)
+ service_item.start_time = start / 1000
+ service_item.end_time = end / 1000
+ service_item.add_capability(ItemCapabilities.IsOptical)
+ else:
+ if not os.path.exists(filename):
+ if not remote:
+ # File is no longer present
+ critical_error_message_box(
+ translate('MediaPlugin.MediaItem', 'Missing Media File'),
+ translate('MediaPlugin.MediaItem', 'The file %s no longer exists.') % filename)
+ return False
+ (path, name) = os.path.split(filename)
+ service_item.title = name
+ service_item.processor = self.display_type_combo_box.currentText()
+ service_item.add_from_command(path, name, CLAPPERBOARD)
+ # Only get start and end times if going to a service
+ if context == ServiceItemContext.Service:
+ # Start media and obtain the length
+ if not self.media_controller.media_length(service_item):
+ return False
service_item.add_capability(ItemCapabilities.CanAutoStartForLive)
service_item.add_capability(ItemCapabilities.CanEditTitle)
service_item.add_capability(ItemCapabilities.RequiresMedia)
@@ -224,6 +278,9 @@
return True
def initialise(self):
+ """
+ Initialize media item.
+ """
self.list_view.clear()
self.list_view.setIconSize(QtCore.QSize(88, 50))
self.service_path = os.path.join(AppLocation.get_section_data_path(self.settings_section), 'thumbnails')
@@ -241,6 +298,9 @@
' '.join(self.media_controller.audio_extensions_list), UiStrings().AllFiles)
def display_setup(self):
+ """
+ Setup media controller display.
+ """
self.media_controller.setup_display(self.display_controller.preview_display, False)
def populate_display_types(self):
@@ -280,7 +340,6 @@
Settings().setValue(self.settings_section + '/media files', self.get_file_list())
def load_list(self, media, target_group=None):
- # Sort the media by its filename considering language specific characters.
"""
Load the media list
@@ -290,12 +349,22 @@
media.sort(key=lambda file_name: get_locale_key(os.path.split(str(file_name))[1]))
for track in media:
track_info = QtCore.QFileInfo(track)
- if not os.path.exists(track):
+ if track.startswith('optical:'):
+ # Handle optical based item
+ (file_name, title, audio_track, subtitle_track, start, end, clip_name) = parse_optical_path(track)
+ item_name = QtGui.QListWidgetItem(clip_name)
+ item_name.setIcon(OPTICAL_ICON)
+ item_name.setData(QtCore.Qt.UserRole, track)
+ item_name.setToolTip('%s@%s-%s' % (file_name, format_milliseconds(start), format_milliseconds(end)))
+ elif not os.path.exists(track):
+ # File doesn't exist, mark as error.
file_name = os.path.split(str(track))[1]
item_name = QtGui.QListWidgetItem(file_name)
item_name.setIcon(ERROR_ICON)
item_name.setData(QtCore.Qt.UserRole, track)
+ item_name.setToolTip(track)
elif track_info.isFile():
+ # Normal media file handling.
file_name = os.path.split(str(track))[1]
item_name = QtGui.QListWidgetItem(file_name)
if '*.%s' % (file_name.split('.')[-1].lower()) in self.media_controller.audio_extensions_list:
@@ -303,15 +372,16 @@
else:
item_name.setIcon(VIDEO_ICON)
item_name.setData(QtCore.Qt.UserRole, track)
- else:
- file_name = os.path.split(str(track))[1]
- item_name = QtGui.QListWidgetItem(file_name)
- item_name.setIcon(build_icon(DVD_ICON))
- item_name.setData(QtCore.Qt.UserRole, track)
- item_name.setToolTip(track)
+ item_name.setToolTip(track)
self.list_view.addItem(item_name)
def get_list(self, type=MediaType.Audio):
+ """
+ Get the list of media, optional select media type.
+
+ :param type: Type to get, defaults to audio.
+ :return: The media list
+ """
media = Settings().value(self.settings_section + '/media files')
media.sort(key=lambda filename: get_locale_key(os.path.split(str(filename))[1]))
if type == MediaType.Audio:
@@ -323,6 +393,13 @@
return media
def search(self, string, show_error):
+ """
+ Performs a search for items containing ``string``
+
+ :param string: String to be displayed
+ :param show_error: Should the error be shown (True)
+ :return: The search result.
+ """
files = Settings().value(self.settings_section + '/media files')
results = []
string = string.lower()
@@ -331,3 +408,32 @@
if filename.lower().find(string) > -1:
results.append([file, filename])
return results
+
+ def on_load_optical(self):
+ """
+ When the load optical button is clicked, open the clip selector window.
+ """
+ # self.media_clip_selector_form.exec_()
+ if VLC_AVAILABLE:
+ media_clip_selector_form = MediaClipSelectorForm(self, self.main_window, None)
+ media_clip_selector_form.exec_()
+ del media_clip_selector_form
+ else:
+ QtGui.QMessageBox.critical(self, 'VLC is not available', 'VLC is not available')
+
+ def add_optical_clip(self, optical):
+ """
+ Add a optical based clip to the mediamanager, called from media_clip_selector_form.
+
+ :param optical: The clip to add.
+ """
+ full_list = self.get_file_list()
+ # If the clip already is in the media list it isn't added and an error message is displayed.
+ if optical in full_list:
+ critical_error_message_box(translate('MediaPlugin.MediaItem', 'Mediaclip already saved'),
+ translate('MediaPlugin.MediaItem', 'This mediaclip has already been saved'))
+ return
+ # Append the optical string to the media list
+ full_list.append(optical)
+ self.load_list([optical])
+ Settings().setValue(self.settings_section + '/media files', self.get_file_list())
=== modified file 'openlp/plugins/songs/forms/songexportform.py'
--- openlp/plugins/songs/forms/songexportform.py 2014-04-12 20:19:22 +0000
+++ openlp/plugins/songs/forms/songexportform.py 2014-09-02 20:29:54 +0000
@@ -124,7 +124,7 @@
self.export_song_layout = QtGui.QHBoxLayout(self.export_song_page)
self.export_song_layout.setObjectName('export_song_layout')
self.grid_layout = QtGui.QGridLayout()
- self.grid_layout.setObjectName('grid_layout')
+ self.grid_layout.setObjectName('range_layout')
self.selected_list_widget = QtGui.QListWidget(self.export_song_page)
self.selected_list_widget.setObjectName('selected_list_widget')
self.grid_layout.addWidget(self.selected_list_widget, 1, 0, 1, 1)
=== added file 'resources/forms/mediaclipselector.ui'
--- resources/forms/mediaclipselector.ui 1970-01-01 00:00:00 +0000
+++ resources/forms/mediaclipselector.ui 2014-09-02 20:29:54 +0000
@@ -0,0 +1,336 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MediaClipSelector</class>
+ <widget class="QMainWindow" name="MediaClipSelector">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>683</width>
+ <height>739</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>683</width>
+ <height>686</height>
+ </size>
+ </property>
+ <property name="focusPolicy">
+ <enum>Qt::NoFocus</enum>
+ </property>
+ <property name="windowTitle">
+ <string>Select media clip</string>
+ </property>
+ <property name="autoFillBackground">
+ <bool>false</bool>
+ </property>
+ <property name="inputMethodHints">
+ <set>Qt::ImhNone</set>
+ </property>
+ <widget class="QWidget" name="centralwidget">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="2" colspan="2">
+ <widget class="QComboBox" name="media_path_combobox">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="7" column="2">
+ <widget class="QTimeEdit" name="start_timeedit">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="displayFormat">
+ <string>HH:mm:ss.z</string>
+ </property>
+ </widget>
+ </item>
+ <item row="8" column="2">
+ <widget class="QTimeEdit" name="end_timeedit">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="displayFormat">
+ <string>HH:mm:ss.z</string>
+ </property>
+ </widget>
+ </item>
+ <item row="7" column="3">
+ <widget class="QPushButton" name="set_start_pushbutton">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Set current position as start point</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="4">
+ <widget class="QPushButton" name="load_disc_pushbutton">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Load disc</string>
+ </property>
+ </widget>
+ </item>
+ <item row="9" column="3">
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Minimum</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="6" column="0">
+ <widget class="QPushButton" name="play_pushbutton">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="icon">
+ <iconset>
+ <normaloff>../images/media_playback_start.png</normaloff>../images/media_playback_start.png</iconset>
+ </property>
+ </widget>
+ </item>
+ <item row="8" column="0">
+ <widget class="QLabel" name="end_point_label">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>End point</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="2" colspan="2">
+ <widget class="QComboBox" name="subtitle_tracks_combobox">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="title_label">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Title</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="2" colspan="2">
+ <widget class="QComboBox" name="audio_tracks_combobox">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="8" column="3">
+ <widget class="QPushButton" name="set_end_pushbutton">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Set current position as end point</string>
+ </property>
+ </widget>
+ </item>
+ <item row="10" column="3">
+ <widget class="QPushButton" name="save_pushbutton">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Save current clip</string>
+ </property>
+ </widget>
+ </item>
+ <item row="10" column="4">
+ <widget class="QPushButton" name="close_pushbutton">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Close</string>
+ </property>
+ </widget>
+ </item>
+ <item row="7" column="0" colspan="2">
+ <widget class="QLabel" name="start_point_label">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Start point</string>
+ </property>
+ </widget>
+ </item>
+ <item row="7" column="4">
+ <widget class="QPushButton" name="jump_start_pushbutton">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Jump to start point</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0" colspan="2">
+ <widget class="QLabel" name="audio_track_label">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Audio track</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="4">
+ <widget class="QTimeEdit" name="media_position_timeedit">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ <property name="displayFormat">
+ <string>HH:mm:ss.z</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0" colspan="5">
+ <widget class="QFrame" name="media_view_frame">
+ <property name="minimumSize">
+ <size>
+ <width>665</width>
+ <height>375</height>
+ </size>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">background-color:black;</string>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Raised</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0" colspan="2">
+ <widget class="QLabel" name="subtitle_track_label">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Subtitle track</string>
+ </property>
+ </widget>
+ </item>
+ <item row="8" column="4">
+ <widget class="QPushButton" name="jump_end_pushbutton">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Jump to end point</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0" colspan="2">
+ <widget class="QLabel" name="media_path_label">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Media path</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="2" colspan="2">
+ <widget class="QComboBox" name="title_combo_box">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="currentText" stdset="0">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="1" colspan="3">
+ <widget class="QSlider" name="position_horizontalslider">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="tracking">
+ <bool>false</bool>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="invertedAppearance">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ <tabstops>
+ <tabstop>media_path_combobox</tabstop>
+ <tabstop>load_disc_pushbutton</tabstop>
+ <tabstop>title_combo_box</tabstop>
+ <tabstop>audio_tracks_combobox</tabstop>
+ <tabstop>subtitle_tracks_combobox</tabstop>
+ <tabstop>play_pushbutton</tabstop>
+ <tabstop>position_horizontalslider</tabstop>
+ <tabstop>media_position_timeedit</tabstop>
+ <tabstop>start_timeedit</tabstop>
+ <tabstop>set_start_pushbutton</tabstop>
+ <tabstop>jump_start_pushbutton</tabstop>
+ <tabstop>end_timeedit</tabstop>
+ <tabstop>set_end_pushbutton</tabstop>
+ <tabstop>jump_end_pushbutton</tabstop>
+ <tabstop>save_pushbutton</tabstop>
+ <tabstop>close_pushbutton</tabstop>
+ </tabstops>
+ <resources/>
+ <connections/>
+</ui>
=== added file 'resources/images/media_optical.png'
Binary files resources/images/media_optical.png 1970-01-01 00:00:00 +0000 and resources/images/media_optical.png 2014-09-02 20:29:54 +0000 differ
=== modified file 'resources/images/openlp-2.qrc'
--- resources/images/openlp-2.qrc 2014-04-14 18:09:47 +0000
+++ resources/images/openlp-2.qrc 2014-09-02 20:29:54 +0000
@@ -139,6 +139,7 @@
<file>media_stop.png</file>
<file>media_audio.png</file>
<file>media_video.png</file>
+ <file>media_optical.png</file>
<file>slidecontroller_multimedia.png</file>
<file>auto-start_active.png</file>
<file>auto-start_inactive.png</file>
=== modified file 'tests/functional/openlp_core_lib/test_serviceitem.py'
--- tests/functional/openlp_core_lib/test_serviceitem.py 2014-03-13 20:59:10 +0000
+++ tests/functional/openlp_core_lib/test_serviceitem.py 2014-09-02 20:29:54 +0000
@@ -206,3 +206,24 @@
'This service item should be able to be run in a can be made to Loop')
self.assertTrue(service_item.is_capable(ItemCapabilities.CanAppend),
'This service item should be able to have new items added to it')
+
+ def service_item_load_optical_media_from_service_test(self):
+ """
+ Test the Service Item - load an optical media item
+ """
+ # GIVEN: A new service item and a mocked add icon function
+ service_item = ServiceItem(None)
+ service_item.add_icon = MagicMock()
+
+ # WHEN: We load a serviceitem with optical media
+ line = convert_file_service_item(TEST_PATH, 'serviceitem-dvd.osj')
+ with patch('openlp.core.ui.servicemanager.os.path.exists') as mocked_exists:
+ mocked_exists.return_value = True
+ service_item.set_from_service(line)
+
+ # THEN: We should get back a valid service item with optical media info
+ self.assertTrue(service_item.is_valid, 'The service item should be valid')
+ self.assertTrue(service_item.is_capable(ItemCapabilities.IsOptical), 'The item should be Optical')
+ self.assertEqual(service_item.start_time, 654.375, 'Start time should be 654.375')
+ self.assertEqual(service_item.end_time, 672.069, 'End time should be 672.069')
+ self.assertEqual(service_item.media_length, 17.694, 'Media length should be 17.694')
=== modified file 'tests/functional/openlp_core_ui/test_media.py'
--- tests/functional/openlp_core_ui/test_media.py 2014-06-04 04:54:44 +0000
+++ tests/functional/openlp_core_ui/test_media.py 2014-09-02 20:29:54 +0000
@@ -32,7 +32,7 @@
from PyQt4 import QtCore
from unittest import TestCase
-from openlp.core.ui.media import get_media_players
+from openlp.core.ui.media import get_media_players, parse_optical_path
from tests.functional import MagicMock, patch
from tests.helpers.testmixin import TestMixin
@@ -126,3 +126,59 @@
# THEN: the used_players should be an empty list, and the overridden player should be an empty string
self.assertEqual(['vlc', 'webkit', 'phonon'], used_players, 'Used players should be correct')
self.assertEqual('vlc,webkit,phonon', overridden_player, 'Overridden player should be a string of players')
+
+ def test_parse_optical_path_linux(self):
+ """
+ Test that test_parse_optical_path() parses a optical path with linux device path correctly
+ """
+
+ # GIVEN: An optical formatted path
+ org_title_track = 1
+ org_audio_track = 2
+ org_subtitle_track = -1
+ org_start = 1234
+ org_end = 4321
+ org_name = 'test name'
+ org_device_path = '/dev/dvd'
+ path = 'optical:%d:%d:%d:%d:%d:%s:%s' % (org_title_track, org_audio_track, org_subtitle_track,
+ org_start, org_end, org_name, org_device_path)
+
+ # WHEN: parsing the path
+ (device_path, title_track, audio_track, subtitle_track, start, end, name) = parse_optical_path(path)
+
+ # THEN: The return values should match the original values
+ self.assertEqual(org_title_track, title_track, 'Returned title_track should match the original')
+ self.assertEqual(org_audio_track, audio_track, 'Returned audio_track should match the original')
+ self.assertEqual(org_subtitle_track, subtitle_track, 'Returned subtitle_track should match the original')
+ self.assertEqual(org_start, start, 'Returned start should match the original')
+ self.assertEqual(org_end, end, 'Returned end should match the original')
+ self.assertEqual(org_name, name, 'Returned end should match the original')
+ self.assertEqual(org_device_path, device_path, 'Returned device_path should match the original')
+
+ def test_parse_optical_path_win(self):
+ """
+ Test that test_parse_optical_path() parses a optical path with windows device path correctly
+ """
+
+ # GIVEN: An optical formatted path
+ org_title_track = 1
+ org_audio_track = 2
+ org_subtitle_track = -1
+ org_start = 1234
+ org_end = 4321
+ org_name = 'test name'
+ org_device_path = 'D:'
+ path = 'optical:%d:%d:%d:%d:%d:%s:%s' % (org_title_track, org_audio_track, org_subtitle_track,
+ org_start, org_end, org_name, org_device_path)
+
+ # WHEN: parsing the path
+ (device_path, title_track, audio_track, subtitle_track, start, end, name) = parse_optical_path(path)
+
+ # THEN: The return values should match the original values
+ self.assertEqual(org_title_track, title_track, 'Returned title_track should match the original')
+ self.assertEqual(org_audio_track, audio_track, 'Returned audio_track should match the original')
+ self.assertEqual(org_subtitle_track, subtitle_track, 'Returned subtitle_track should match the original')
+ self.assertEqual(org_start, start, 'Returned start should match the original')
+ self.assertEqual(org_end, end, 'Returned end should match the original')
+ self.assertEqual(org_name, name, 'Returned end should match the original')
+ self.assertEqual(org_device_path, device_path, 'Returned device_path should match the original')
=== added directory 'tests/interfaces/openlp_plugins/media'
=== added file 'tests/interfaces/openlp_plugins/media/__init__.py'
=== added directory 'tests/interfaces/openlp_plugins/media/forms'
=== added file 'tests/interfaces/openlp_plugins/media/forms/test_mediaclipselectorform.py'
--- tests/interfaces/openlp_plugins/media/forms/test_mediaclipselectorform.py 1970-01-01 00:00:00 +0000
+++ tests/interfaces/openlp_plugins/media/forms/test_mediaclipselectorform.py 2014-09-02 20:29:54 +0000
@@ -0,0 +1,157 @@
+# -*- coding: utf-8 -*-
+# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
+
+###############################################################################
+# OpenLP - Open Source Lyrics Projection #
+# --------------------------------------------------------------------------- #
+# Copyright (c) 2008-2014 Raoul Snyman #
+# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan #
+# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
+# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. #
+# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, #
+# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
+# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, #
+# Frode Woldsund, Martin Zibricky, Patrick Zimmermann #
+# --------------------------------------------------------------------------- #
+# 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 #
+###############################################################################
+"""
+Module to test the MediaClipSelectorForm.
+"""
+
+import os
+from unittest import TestCase, SkipTest
+from openlp.core.ui.media.vlcplayer import VLC_AVAILABLE
+
+if os.name == 'nt' and not VLC_AVAILABLE:
+ raise SkipTest('Windows without VLC, skipping this test since it cannot run without vlc')
+
+from PyQt4 import QtGui, QtTest, QtCore
+
+from openlp.core.common import Registry
+from openlp.plugins.media.forms.mediaclipselectorform import MediaClipSelectorForm
+from tests.interfaces import MagicMock, patch
+from tests.helpers.testmixin import TestMixin
+
+
+class TestMediaClipSelectorForm(TestCase, TestMixin):
+ """
+ Test the EditCustomSlideForm.
+ """
+ def setUp(self):
+ """
+ Create the UI
+ """
+ Registry.create()
+ self.get_application()
+ self.main_window = QtGui.QMainWindow()
+ Registry().register('main_window', self.main_window)
+ # Mock VLC so we don't actually use it
+ self.vlc_patcher = patch('openlp.plugins.media.forms.mediaclipselectorform.vlc')
+ self.vlc_patcher.start()
+ # Mock the media item
+ self.mock_media_item = MagicMock()
+ # create form to test
+ self.form = MediaClipSelectorForm(self.mock_media_item, self.main_window, None)
+ mock_media_state_wait = MagicMock()
+ mock_media_state_wait.return_value = True
+ self.form.media_state_wait = mock_media_state_wait
+
+ def tearDown(self):
+ """
+ Delete all the C++ objects at the end so that we don't have a segfault
+ """
+ self.vlc_patcher.stop()
+ del self.form
+ del self.main_window
+
+ def basic_test(self):
+ """
+ Test if the dialog is correctly set up.
+ """
+ # GIVEN: A mocked QDialog.exec_() method
+ with patch('PyQt4.QtGui.QDialog.exec_') as mocked_exec:
+ # WHEN: Show the dialog.
+ self.form.exec_()
+
+ # THEN: The media path should be empty.
+ assert self.form.media_path_combobox.currentText() == '', 'There should not be any text in the media path.'
+
+ def click_load_button_test(self):
+ """
+ Test that the correct function is called when load is clicked, and that it behaves as expected.
+ """
+ # GIVEN: Mocked methods.
+ with patch('openlp.plugins.media.forms.mediaclipselectorform.critical_error_message_box') as \
+ mocked_critical_error_message_box,\
+ patch('openlp.plugins.media.forms.mediaclipselectorform.os.path.exists') as mocked_os_path_exists,\
+ patch('PyQt4.QtGui.QDialog.exec_') as mocked_exec:
+ self.form.exec_()
+
+ # WHEN: The load button is clicked with no path set
+ QtTest.QTest.mouseClick(self.form.load_disc_button, QtCore.Qt.LeftButton)
+
+ # THEN: we should get an error
+ mocked_critical_error_message_box.assert_called_with(message='No path was given')
+
+ # WHEN: The load button is clicked with a non-existing path
+ mocked_os_path_exists.return_value = False
+ self.form.media_path_combobox.insertItem(0, '/non-existing/test-path.test')
+ self.form.media_path_combobox.setCurrentIndex(0)
+ QtTest.QTest.mouseClick(self.form.load_disc_button, QtCore.Qt.LeftButton)
+
+ # THEN: we should get an error
+ assert self.form.media_path_combobox.currentText() == '/non-existing/test-path.test',\
+ 'The media path should be the given one.'
+ mocked_critical_error_message_box.assert_called_with(message='Given path does not exists')
+
+ # WHEN: The load button is clicked with a mocked existing path
+ mocked_os_path_exists.return_value = True
+ self.form.vlc_media_player = MagicMock()
+ self.form.vlc_media_player.play.return_value = -1
+ self.form.media_path_combobox.insertItem(0, '/existing/test-path.test')
+ self.form.media_path_combobox.setCurrentIndex(0)
+ QtTest.QTest.mouseClick(self.form.load_disc_button, QtCore.Qt.LeftButton)
+
+ # THEN: we should get an error
+ assert self.form.media_path_combobox.currentText() == '/existing/test-path.test',\
+ 'The media path should be the given one.'
+ mocked_critical_error_message_box.assert_called_with(message='VLC player failed playing the media')
+
+ def title_combobox_test(self):
+ """
+ Test the behavior when the title combobox is updated
+ """
+ # GIVEN: Mocked methods and some entries in the title combobox.
+ with patch('PyQt4.QtGui.QDialog.exec_') as mocked_exec:
+ self.form.exec_()
+ self.form.vlc_media_player.get_length.return_value = 1000
+ self.form.audio_tracks_combobox.itemData = MagicMock()
+ self.form.subtitle_tracks_combobox.itemData = MagicMock()
+ self.form.audio_tracks_combobox.itemData.return_value = None
+ self.form.subtitle_tracks_combobox.itemData.return_value = None
+ self.form.titles_combo_box.insertItem(0, 'Test Title 0')
+ self.form.titles_combo_box.insertItem(1, 'Test Title 1')
+
+ # WHEN: There exists audio and subtitle tracks and the index is updated.
+ self.form.vlc_media_player.audio_get_track_description.return_value = [(-1, b'Disabled'),
+ (0, b'Audio Track 1')]
+ self.form.vlc_media_player.video_get_spu_description.return_value = [(-1, b'Disabled'),
+ (0, b'Subtitle Track 1')]
+ self.form.titles_combo_box.setCurrentIndex(1)
+
+ # THEN: The subtitle and audio track comboboxes should be updated and get signals and call itemData.
+ self.form.audio_tracks_combobox.itemData.assert_any_call(0)
+ self.form.audio_tracks_combobox.itemData.assert_any_call(1)
+ self.form.subtitle_tracks_combobox.itemData.assert_any_call(0)
=== added file 'tests/resources/serviceitem-dvd.osj'
--- tests/resources/serviceitem-dvd.osj 1970-01-01 00:00:00 +0000
+++ tests/resources/serviceitem-dvd.osj 2014-09-02 20:29:54 +0000
@@ -0,0 +1,1 @@
+[{"serviceitem": {"header": {"auto_play_slides_once": false, "data": "", "processor": "Automatic", "theme": -1, "theme_overwritten": false, "end_time": 672.069, "start_time": 654.375, "capabilities": [12, 18, 16, 4], "media_length": 17.694, "audit": "", "xml_version": null, "title": "First DVD Clip", "auto_play_slides_loop": false, "notes": "", "icon": ":/plugins/plugin_media.png", "type": 3, "background_audio": [], "plugin": "media", "from_plugin": false, "search": "", "will_auto_start": false, "name": "media", "footer": [], "timed_slide_interval": 0}, "data": [{"image": ":/media/slidecontroller_multimedia.png", "path": "optical:1:5:3:654375:672069:First DVD Clip:/dev/sr0", "title": "/dev/sr0"}]}}]
Follow ups