Merge lp:~trb143/openlp/media_state into lp:openlp

Proposed by Tim Bentley
Status: Superseded
Proposed branch: lp:~trb143/openlp/media_state
Merge into: lp:openlp
Diff against target: 9468 lines (+3897/-2446)
60 files modified
openlp/.version (+1/-1)
openlp/core/app.py (+5/-1)
openlp/core/common/actions.py (+1/-1)
openlp/core/common/mixins.py (+2/-1)
openlp/core/common/registry.py (+7/-0)
openlp/core/lib/mediamanageritem.py (+37/-26)
openlp/core/lib/plugin.py (+5/-4)
openlp/core/lib/pluginmanager.py (+77/-55)
openlp/core/lib/serviceitem.py (+7/-2)
openlp/core/loader.py (+48/-0)
openlp/core/state.py (+175/-0)
openlp/core/ui/icons.py (+1/-1)
openlp/core/ui/maindisplay.py (+1/-108)
openlp/core/ui/mainwindow.py (+4/-26)
openlp/core/ui/media/__init__.py (+1/-38)
openlp/core/ui/media/mediacontroller.py (+70/-163)
openlp/core/ui/media/mediaplayer.py (+2/-1)
openlp/core/ui/media/playertab.py (+8/-9)
openlp/core/ui/media/vendor/mediainfoWrapper.py (+0/-128)
openlp/core/ui/media/vendor/vlc.py (+2900/-1193)
openlp/core/ui/media/vlcplayer.py (+4/-4)
openlp/core/ui/pluginform.py (+29/-27)
openlp/core/ui/settingsform.py (+0/-6)
openlp/core/ui/slidecontroller.py (+54/-108)
openlp/core/widgets/views.py (+1/-1)
openlp/plugins/alerts/alertsplugin.py (+3/-0)
openlp/plugins/alerts/lib/alertsmanager.py (+1/-1)
openlp/plugins/bibles/bibleplugin.py (+3/-0)
openlp/plugins/custom/customplugin.py (+3/-0)
openlp/plugins/images/imageplugin.py (+3/-0)
openlp/plugins/media/lib/mediaitem.py (+52/-149)
openlp/plugins/media/mediaplugin.py (+3/-52)
openlp/plugins/presentations/presentationplugin.py (+3/-0)
openlp/plugins/songs/lib/mediaitem.py (+11/-5)
openlp/plugins/songs/songsplugin.py (+3/-0)
openlp/plugins/songusage/songusageplugin.py (+3/-0)
scripts/check_dependencies.py (+2/-1)
scripts/jenkins_script.py (+7/-6)
tests/functional/openlp_core/api/endpoint/test_controller.py (+4/-0)
tests/functional/openlp_core/common/test_registry.py (+1/-1)
tests/functional/openlp_core/lib/test_mediamanageritem.py (+12/-0)
tests/functional/openlp_core/lib/test_pluginmanager.py (+70/-25)
tests/functional/openlp_core/lib/test_serviceitem.py (+9/-4)
tests/functional/openlp_core/test_state.py (+151/-0)
tests/functional/openlp_core/ui/media/test_mediacontroller.py (+33/-104)
tests/functional/openlp_core/ui/media/test_vlcplayer.py (+4/-4)
tests/functional/openlp_core/ui/test_maindisplay.py (+1/-19)
tests/functional/openlp_core/ui/test_mainwindow.py (+12/-7)
tests/functional/openlp_core/ui/test_media.py (+13/-11)
tests/functional/openlp_core/ui/test_slidecontroller.py (+3/-0)
tests/functional/openlp_core/widgets/test_views.py (+16/-13)
tests/functional/openlp_plugins/images/test_upgrade.py (+4/-2)
tests/functional/openlp_plugins/media/test_mediaplugin.py (+1/-27)
tests/functional/openlp_plugins/songs/test_mediaitem.py (+0/-1)
tests/interfaces/openlp_core/lib/test_pluginmanager.py (+16/-12)
tests/interfaces/openlp_core/ui/media/__init__.py (+0/-21)
tests/interfaces/openlp_core/ui/media/vendor/__init__.py (+0/-21)
tests/interfaces/openlp_core/ui/media/vendor/test_mediainfoWrapper.py (+0/-48)
tests/interfaces/openlp_core/ui/test_mainwindow.py (+10/-4)
tests/openlp_core/projectors/test_projector_db.py (+0/-4)
To merge this branch: bzr merge lp:~trb143/openlp/media_state
Reviewer Review Type Date Requested Status
Phill Pending
Review via email: mp+361641@code.launchpad.net

This proposal supersedes a proposal from 2019-01-10.

This proposal has been superseded by a proposal from 2019-01-11.

Commit message

This is to do a code review and see what mess is left

Description of the change

Refactor Media and add State management. (there is more to do!)

* Add Start of State management with dependency understanding. (works for VLC and PyMediaInfo)!
* refactor plugin manager to use this (part 1)
* move loading of static stuff from mainwindow.
* Only use VLC for media, remove other options (more cleanups to be done later)
* clean up pymediainfo usage
* remove audio and convert to vlc for song audio player
* fix many bugs discovered on my travels.
* upgraded vlc.py

lp:~trb143/openlp/media_state (revision 2914)
https://ci.openlp.io/job/Branch-01-Pull/2675/ [SUCCESS]
https://ci.openlp.io/job/Branch-02a-Linux-Tests/2569/ [SUCCESS]
https://ci.openlp.io/job/Branch-02b-macOS-Tests/339/ [SUCCESS]
https://ci.openlp.io/job/Branch-03a-Build-Source/181/ [SUCCESS]
https://ci.openlp.io/job/Branch-03b-Build-macOS/160/ [SUCCESS]
https://ci.openlp.io/job/Branch-04a-Code-Lint/1643/ [SUCCESS]
https://ci.openlp.io/job/Branch-04b-Test-Coverage/1456/ [SUCCESS]
https://ci.openlp.io/job/Branch-05-AppVeyor-Tests/346/ [FAILURE]
Stopping after failure

Failed builds:
 - Branch-05-AppVeyor-Tests #346: https://ci.openlp.io/job/Branch-05-AppVeyor-Tests/346/console

To post a comment you must log in.
Revision history for this message
Raoul Snyman (raoul-snyman) wrote : Posted in a previous version of this proposal

Linux tests failed, please see https://ci.openlp.io/job/MP-02-Linux_Tests/65/ for more details

Revision history for this message
Raoul Snyman (raoul-snyman) wrote : Posted in a previous version of this proposal

Linux tests failed, please see https://ci.openlp.io/job/MP-02-Linux_Tests/66/ for more details

Revision history for this message
Raoul Snyman (raoul-snyman) wrote : Posted in a previous version of this proposal

Linux tests failed, please see https://ci.openlp.io/job/MP-02-Linux_Tests/67/ for more details

Revision history for this message
Raoul Snyman (raoul-snyman) wrote : Posted in a previous version of this proposal

Linux tests passed!

Revision history for this message
Raoul Snyman (raoul-snyman) wrote : Posted in a previous version of this proposal

Linting passed!

Revision history for this message
Raoul Snyman (raoul-snyman) wrote : Posted in a previous version of this proposal

macOS tests passed!

Revision history for this message
Phill (phill-ridout) wrote : Posted in a previous version of this proposal

Only got to line 1023, will take another look later, just a few minor issues with doc strings (see inline comments)

Revision history for this message
Phill (phill-ridout) wrote : Posted in a previous version of this proposal

I assume the commented out code is a work in progress?

L7027: if statement not needed
L7953: I'm not convinced the user will want to see a dialog box every time the preview, go live, or edit a song that has audio....

Also it looks like you've removed the background audio controls from the live slide controller, but not replaced them with anything?

review: Needs Information
Revision history for this message
Phill (phill-ridout) wrote : Posted in a previous version of this proposal

L7953: I'm not convinced the user will want to see a dialog box every time the preview, go live, or edit a song that has audio....

Could you comment this out for no, I'mo concerned that this would too easily be overlooked. (Its only going to happen for people who try to load a song with background audio and have the media tab disable / problems with VLC integration.

If you can do that and resub, I'll be happy to approve it!

Revision history for this message
Raoul Snyman (raoul-snyman) wrote : Posted in a previous version of this proposal

Linux tests passed!

Revision history for this message
Raoul Snyman (raoul-snyman) wrote : Posted in a previous version of this proposal

Linting failed, please see https://ci.openlp.io/job/MP-03-Linting/26/ for more details

Revision history for this message
Raoul Snyman (raoul-snyman) wrote :

Linux tests passed!

Revision history for this message
Raoul Snyman (raoul-snyman) wrote :

Linting passed!

Revision history for this message
Raoul Snyman (raoul-snyman) wrote :

macOS tests passed!

lp:~trb143/openlp/media_state updated
2918. By Tim Bentley

fix

2919. By Tim Bentley

settings updates

2920. By Tim Bentley

Move settings

2921. By Tim Bentley

clean ups and settings

2922. By Tim Bentley

More stream stuff

2923. By Tim Bentley

Add settings tab

2924. By Tim Bentley

Head

2925. By Tim Bentley

Head 2

2926. By Tim Bentley

Media is now playing again - just

2927. By Tim Bentley

head

2928. By Tim Bentley

media now works and plays

2929. By Tim Bentley

vlc tests pass

2930. By Tim Bentley

fix pep8.5

2931. By Tim Bentley

fix pep8.5

2932. By Tim Bentley

Fixes and handle missing display

2933. By Tim Bentley

handle missing live display preserve prview

2934. By Tim Bentley

add experimental flag

2935. By Tim Bentley

pep8

2936. By Tim Bentley

head

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'openlp/.version'
--- openlp/.version 2018-03-29 15:54:55 +0000
+++ openlp/.version 2019-01-10 22:02:32 +0000
@@ -1,1 +1,1 @@
12.9.012.5.dev2916
2\ No newline at end of file2\ No newline at end of file
33
=== modified file 'openlp/core/app.py'
--- openlp/core/app.py 2018-10-07 21:40:36 +0000
+++ openlp/core/app.py 2019-01-10 22:02:32 +0000
@@ -35,8 +35,10 @@
3535
36from PyQt5 import QtCore, QtWidgets36from PyQt5 import QtCore, QtWidgets
3737
38from openlp.core.state import State
38from openlp.core.common import is_macosx, is_win39from openlp.core.common import is_macosx, is_win
39from openlp.core.common.applocation import AppLocation40from openlp.core.common.applocation import AppLocation
41from openlp.core.loader import loader
40from openlp.core.common.i18n import LanguageManager, UiStrings, translate42from openlp.core.common.i18n import LanguageManager, UiStrings, translate
41from openlp.core.common.path import create_paths, copytree43from openlp.core.common.path import create_paths, copytree
42from openlp.core.common.registry import Registry44from openlp.core.common.registry import Registry
@@ -113,8 +115,10 @@
113 # Check if OpenLP has been upgrade and if a backup of data should be created115 # Check if OpenLP has been upgrade and if a backup of data should be created
114 self.backup_on_upgrade(has_run_wizard, can_show_splash)116 self.backup_on_upgrade(has_run_wizard, can_show_splash)
115 # start the main app window117 # start the main app window
118 loader()
116 self.main_window = MainWindow()119 self.main_window = MainWindow()
117 Registry().execute('bootstrap_initialise')120 Registry().execute('bootstrap_initialise')
121 State().flush_preconditions()
118 Registry().execute('bootstrap_post_set_up')122 Registry().execute('bootstrap_post_set_up')
119 Registry().initialise = False123 Registry().initialise = False
120 self.main_window.show()124 self.main_window.show()
@@ -132,7 +136,7 @@
132 if Settings().value('core/update check'):136 if Settings().value('core/update check'):
133 check_for_update(self.main_window)137 check_for_update(self.main_window)
134 self.main_window.is_display_blank()138 self.main_window.is_display_blank()
135 self.main_window.app_startup()139 Registry().execute('bootstrap_completion')
136 return self.exec()140 return self.exec()
137141
138 @staticmethod142 @staticmethod
139143
=== modified file 'openlp/core/common/actions.py'
--- openlp/core/common/actions.py 2018-06-28 15:37:37 +0000
+++ openlp/core/common/actions.py 2019-01-10 22:02:32 +0000
@@ -20,7 +20,7 @@
20# Temple Place, Suite 330, Boston, MA 02111-1307 USA #20# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
21###############################################################################21###############################################################################
22"""22"""
23The :mod:`~openlp.core.utils.actions` module provides action list classes used23The :mod:`~openlp.core.common.actions` module provides action list classes used
24by the shortcuts system.24by the shortcuts system.
25"""25"""
26import logging26import logging
2727
=== modified file 'openlp/core/common/mixins.py'
--- openlp/core/common/mixins.py 2018-02-03 11:24:39 +0000
+++ openlp/core/common/mixins.py 2019-01-10 22:02:32 +0000
@@ -49,7 +49,8 @@
49 setattr(self, name, self.logging_wrapper(m, self))49 setattr(self, name, self.logging_wrapper(m, self))
50 return self._logger50 return self._logger
5151
52 def logging_wrapper(self, func, parent):52 @staticmethod
53 def logging_wrapper(func, parent):
53 """54 """
54 Code to added debug wrapper to work on called functions within a decorated class.55 Code to added debug wrapper to work on called functions within a decorated class.
55 """56 """
5657
=== modified file 'openlp/core/common/registry.py'
--- openlp/core/common/registry.py 2018-10-06 20:49:13 +0000
+++ openlp/core/common/registry.py 2019-01-10 22:02:32 +0000
@@ -203,6 +203,7 @@
203 Registry().register(de_hump(self.__class__.__name__), self)203 Registry().register(de_hump(self.__class__.__name__), self)
204 Registry().register_function('bootstrap_initialise', self.bootstrap_initialise)204 Registry().register_function('bootstrap_initialise', self.bootstrap_initialise)
205 Registry().register_function('bootstrap_post_set_up', self.bootstrap_post_set_up)205 Registry().register_function('bootstrap_post_set_up', self.bootstrap_post_set_up)
206 Registry().register_function('bootstrap_completion', self.bootstrap_completion)
206207
207 def bootstrap_initialise(self):208 def bootstrap_initialise(self):
208 """209 """
@@ -215,3 +216,9 @@
215 Dummy method to be overridden216 Dummy method to be overridden
216 """217 """
217 pass218 pass
219
220 def bootstrap_completion(self):
221 """
222 Dummy method to be overridden
223 """
224 pass
218225
=== modified file 'openlp/core/lib/mediamanageritem.py'
--- openlp/core/lib/mediamanageritem.py 2018-08-25 14:08:19 +0000
+++ openlp/core/lib/mediamanageritem.py 2019-01-10 22:02:32 +0000
@@ -129,6 +129,9 @@
129 self.has_file_icon = False129 self.has_file_icon = False
130 self.has_delete_icon = True130 self.has_delete_icon = True
131 self.add_to_service_item = False131 self.add_to_service_item = False
132 self.can_preview = True
133 self.can_make_live = True
134 self.can_add_to_service = True
132135
133 def retranslateUi(self):136 def retranslateUi(self):
134 """137 """
@@ -182,11 +185,14 @@
182 if self.has_delete_icon:185 if self.has_delete_icon:
183 toolbar_actions.append(['Delete', StringContent.Delete, UiIcons().delete, self.on_delete_click])186 toolbar_actions.append(['Delete', StringContent.Delete, UiIcons().delete, self.on_delete_click])
184 # Preview187 # Preview
185 toolbar_actions.append(['Preview', StringContent.Preview, UiIcons().preview, self.on_preview_click])188 if self.can_preview:
189 toolbar_actions.append(['Preview', StringContent.Preview, UiIcons().preview, self.on_preview_click])
186 # Live Button190 # Live Button
187 toolbar_actions.append(['Live', StringContent.Live, UiIcons().live, self.on_live_click])191 if self.can_make_live:
192 toolbar_actions.append(['Live', StringContent.Live, UiIcons().live, self.on_live_click])
188 # Add to service Button193 # Add to service Button
189 toolbar_actions.append(['Service', StringContent.Service, UiIcons().add, self.on_add_click])194 if self.can_add_to_service:
195 toolbar_actions.append(['Service', StringContent.Service, UiIcons().add, self.on_add_click])
190 for action in toolbar_actions:196 for action in toolbar_actions:
191 if action[0] == StringContent.Preview:197 if action[0] == StringContent.Preview:
192 self.toolbar.addSeparator()198 self.toolbar.addSeparator()
@@ -210,27 +216,30 @@
210 icon=UiIcons().edit,216 icon=UiIcons().edit,
211 triggers=self.on_edit_click)217 triggers=self.on_edit_click)
212 create_widget_action(self.list_view, separator=True)218 create_widget_action(self.list_view, separator=True)
213 create_widget_action(self.list_view,219 if self.can_preview:
214 'listView{plugin}{preview}Item'.format(plugin=self.plugin.name.title(),220 create_widget_action(self.list_view,
215 preview=StringContent.Preview.title()),221 'listView{plugin}{preview}Item'.format(plugin=self.plugin.name.title(),
216 text=self.plugin.get_string(StringContent.Preview)['title'],222 preview=StringContent.Preview.title()),
217 icon=UiIcons().preview,223 text=self.plugin.get_string(StringContent.Preview)['title'],
218 can_shortcuts=True,224 icon=UiIcons().preview,
219 triggers=self.on_preview_click)225 can_shortcuts=True,
220 create_widget_action(self.list_view,226 triggers=self.on_preview_click)
221 'listView{plugin}{live}Item'.format(plugin=self.plugin.name.title(),227 if self.can_make_live:
222 live=StringContent.Live.title()),228 create_widget_action(self.list_view,
223 text=self.plugin.get_string(StringContent.Live)['title'],229 'listView{plugin}{live}Item'.format(plugin=self.plugin.name.title(),
224 icon=UiIcons().live,230 live=StringContent.Live.title()),
225 can_shortcuts=True,231 text=self.plugin.get_string(StringContent.Live)['title'],
226 triggers=self.on_live_click)232 icon=UiIcons().live,
227 create_widget_action(self.list_view,233 can_shortcuts=True,
228 'listView{plugin}{service}Item'.format(plugin=self.plugin.name.title(),234 triggers=self.on_live_click)
229 service=StringContent.Service.title()),235 if self.can_add_to_service:
230 can_shortcuts=True,236 create_widget_action(self.list_view,
231 text=self.plugin.get_string(StringContent.Service)['title'],237 'listView{plugin}{service}Item'.format(plugin=self.plugin.name.title(),
232 icon=UiIcons().add,238 service=StringContent.Service.title()),
233 triggers=self.on_add_click)239 can_shortcuts=True,
240 text=self.plugin.get_string(StringContent.Service)['title'],
241 icon=UiIcons().add,
242 triggers=self.on_add_click)
234 if self.has_delete_icon:243 if self.has_delete_icon:
235 create_widget_action(self.list_view, separator=True)244 create_widget_action(self.list_view, separator=True)
236 create_widget_action(self.list_view,245 create_widget_action(self.list_view,
@@ -461,10 +470,12 @@
461 Allows the list click action to be determined dynamically470 Allows the list click action to be determined dynamically
462 """471 """
463 if Settings().value('advanced/double click live'):472 if Settings().value('advanced/double click live'):
464 self.on_live_click()473 if self.can_make_live:
474 self.on_live_click()
465 elif not Settings().value('advanced/single click preview'):475 elif not Settings().value('advanced/single click preview'):
466 # NOTE: The above check is necessary to prevent bug #1419300476 # NOTE: The above check is necessary to prevent bug #1419300
467 self.on_preview_click()477 if self.can_preview:
478 self.on_preview_click()
468479
469 def on_selection_change(self):480 def on_selection_change(self):
470 """481 """
471482
=== modified file 'openlp/core/lib/plugin.py'
--- openlp/core/lib/plugin.py 2017-12-29 09:15:48 +0000
+++ openlp/core/lib/plugin.py 2019-01-10 22:02:32 +0000
@@ -24,11 +24,9 @@
24"""24"""
25import logging25import logging
2626
27from PyQt5 import QtCore
28
29from openlp.core.common.i18n import UiStrings27from openlp.core.common.i18n import UiStrings
30from openlp.core.common.mixins import RegistryProperties28from openlp.core.common.mixins import RegistryProperties
31from openlp.core.common.registry import Registry29from openlp.core.common.registry import Registry, RegistryBase
32from openlp.core.common.settings import Settings30from openlp.core.common.settings import Settings
33from openlp.core.version import get_version31from openlp.core.version import get_version
3432
@@ -60,7 +58,7 @@
60 VisibleName = 'visible_name'58 VisibleName = 'visible_name'
6159
6260
63class Plugin(QtCore.QObject, RegistryProperties):61class Plugin(RegistryBase, RegistryProperties):
64 """62 """
65 Base class for openlp plugins to inherit from.63 Base class for openlp plugins to inherit from.
6664
@@ -325,6 +323,9 @@
325 """323 """
326 return self.text_strings[name]324 return self.text_strings[name]
327325
326 def set_plugin_text_strings(self):
327 pass
328
328 def set_plugin_ui_text_strings(self, tooltips):329 def set_plugin_ui_text_strings(self, tooltips):
329 """330 """
330 Called to define all translatable texts of the plugin331 Called to define all translatable texts of the plugin
331332
=== modified file 'openlp/core/lib/pluginmanager.py'
--- openlp/core/lib/pluginmanager.py 2018-08-25 14:08:19 +0000
+++ openlp/core/lib/pluginmanager.py 2019-01-10 22:02:32 +0000
@@ -24,8 +24,12 @@
24"""24"""
25import os25import os
2626
27from PyQt5 import QtWidgets
28
29from openlp.core.state import State
27from openlp.core.common import extension_loader30from openlp.core.common import extension_loader
28from openlp.core.common.applocation import AppLocation31from openlp.core.common.applocation import AppLocation
32from openlp.core.common.i18n import translate, UiStrings
29from openlp.core.common.mixins import LogMixin, RegistryProperties33from openlp.core.common.mixins import LogMixin, RegistryProperties
30from openlp.core.common.registry import RegistryBase34from openlp.core.common.registry import RegistryBase
31from openlp.core.lib.plugin import Plugin, PluginStatus35from openlp.core.lib.plugin import Plugin, PluginStatus
@@ -50,11 +54,22 @@
50 def bootstrap_initialise(self):54 def bootstrap_initialise(self):
51 """55 """
52 Bootstrap all the plugin manager functions56 Bootstrap all the plugin manager functions
53 """57 Scan a directory for objects inheriting from the ``Plugin`` class.
54 self.find_plugins()58 """
55 # hook methods have to happen after find_plugins. Find plugins needs59 glob_pattern = os.path.join('plugins', '*', '[!.]*plugin.py')
56 # the controllers hence the hooks have moved from setupUI() to here60 extension_loader(glob_pattern)
57 # Find and insert settings tabs61 plugin_classes = Plugin.__subclasses__()
62 for p in plugin_classes:
63 try:
64 p()
65 self.log_debug('Loaded plugin {plugin}'.format(plugin=str(p)))
66 except TypeError:
67 self.log_exception('Failed to load plugin {plugin}'.format(plugin=str(p)))
68
69 def bootstrap_post_set_up(self):
70 """
71 Bootstrap all the plugin manager functions
72 """
58 self.hook_settings_tabs()73 self.hook_settings_tabs()
59 # Find and insert media manager items74 # Find and insert media manager items
60 self.hook_media_manager()75 self.hook_media_manager()
@@ -67,36 +82,23 @@
67 # Call the initialise method to setup plugins.82 # Call the initialise method to setup plugins.
68 self.initialise_plugins()83 self.initialise_plugins()
6984
70 def find_plugins(self):85 def bootstrap_completion(self):
71 """86 """
72 Scan a directory for objects inheriting from the ``Plugin`` class.87 Give all the plugins a chance to perform some tasks at startup
73 """88 """
74 glob_pattern = os.path.join('plugins', '*', '[!.]*plugin.py')89 self.application.process_events()
75 extension_loader(glob_pattern)90 for plugin in State().list_plugins():
76 plugin_classes = Plugin.__subclasses__()91 if plugin and plugin.is_active():
77 plugin_objects = []92 plugin.app_startup()
78 for p in plugin_classes:93 self.application.process_events()
79 try:
80 plugin = p()
81 self.log_debug('Loaded plugin {plugin}'.format(plugin=str(p)))
82 plugin_objects.append(plugin)
83 except TypeError:
84 self.log_exception('Failed to load plugin {plugin}'.format(plugin=str(p)))
85 plugins_list = sorted(plugin_objects, key=lambda plugin: plugin.weight)
86 for plugin in plugins_list:
87 if plugin.check_pre_conditions():
88 self.log_debug('Plugin {plugin} active'.format(plugin=str(plugin.name)))
89 plugin.set_status()
90 else:
91 plugin.status = PluginStatus.Disabled
92 self.plugins.append(plugin)
9394
94 def hook_media_manager(self):95 @staticmethod
96 def hook_media_manager():
95 """97 """
96 Create the plugins' media manager items.98 Create the plugins' media manager items.
97 """99 """
98 for plugin in self.plugins:100 for plugin in State().list_plugins():
99 if plugin.status is not PluginStatus.Disabled:101 if plugin and plugin.status is not PluginStatus.Disabled:
100 plugin.create_media_manager_item()102 plugin.create_media_manager_item()
101103
102 def hook_settings_tabs(self):104 def hook_settings_tabs(self):
@@ -106,8 +108,8 @@
106 Tabs are set for all plugins not just Active ones108 Tabs are set for all plugins not just Active ones
107109
108 """110 """
109 for plugin in self.plugins:111 for plugin in State().list_plugins():
110 if plugin.status is not PluginStatus.Disabled:112 if plugin and plugin.status is not PluginStatus.Disabled:
111 plugin.create_settings_tab(self.settings_form)113 plugin.create_settings_tab(self.settings_form)
112114
113 def hook_import_menu(self):115 def hook_import_menu(self):
@@ -116,8 +118,8 @@
116 item to the import menu.118 item to the import menu.
117119
118 """120 """
119 for plugin in self.plugins:121 for plugin in State().list_plugins():
120 if plugin.status is not PluginStatus.Disabled:122 if plugin and plugin.status is not PluginStatus.Disabled:
121 plugin.add_import_menu_item(self.main_window.file_import_menu)123 plugin.add_import_menu_item(self.main_window.file_import_menu)
122124
123 def hook_export_menu(self):125 def hook_export_menu(self):
@@ -125,8 +127,8 @@
125 Loop through all the plugins and give them an opportunity to add an127 Loop through all the plugins and give them an opportunity to add an
126 item to the export menu.128 item to the export menu.
127 """129 """
128 for plugin in self.plugins:130 for plugin in State().list_plugins():
129 if plugin.status is not PluginStatus.Disabled:131 if plugin and plugin.status is not PluginStatus.Disabled:
130 plugin.add_export_menu_item(self.main_window.file_export_menu)132 plugin.add_export_menu_item(self.main_window.file_export_menu)
131133
132 def hook_tools_menu(self):134 def hook_tools_menu(self):
@@ -134,53 +136,73 @@
134 Loop through all the plugins and give them an opportunity to add an136 Loop through all the plugins and give them an opportunity to add an
135 item to the tools menu.137 item to the tools menu.
136 """138 """
137 for plugin in self.plugins:139 for plugin in State().list_plugins():
138 if plugin.status is not PluginStatus.Disabled:140 if plugin and plugin.status is not PluginStatus.Disabled:
139 plugin.add_tools_menu_item(self.main_window.tools_menu)141 plugin.add_tools_menu_item(self.main_window.tools_menu)
140142
141 def hook_upgrade_plugin_settings(self, settings):143 @staticmethod
144 def hook_upgrade_plugin_settings(settings):
142 """145 """
143 Loop through all the plugins and give them an opportunity to upgrade their settings.146 Loop through all the plugins and give them an opportunity to upgrade their settings.
144147
145 :param settings: The Settings object containing the old settings.148 :param settings: The Settings object containing the old settings.
146 """149 """
147 for plugin in self.plugins:150 for plugin in State().list_plugins():
148 if plugin.status is not PluginStatus.Disabled:151 if plugin and plugin.status is not PluginStatus.Disabled:
149 plugin.upgrade_settings(settings)152 plugin.upgrade_settings(settings)
150153
151 def initialise_plugins(self):154 def initialise_plugins(self):
152 """155 """
153 Loop through all the plugins and give them an opportunity to initialise themselves.156 Loop through all the plugins and give them an opportunity to initialise themselves.
154 """157 """
155 for plugin in self.plugins:158 uninitialised_plugins = []
156 self.log_info('initialising plugins {plugin} in a {state} state'.format(plugin=plugin.name,159 for plugin in State().list_plugins():
157 state=plugin.is_active()))160 if plugin:
158 if plugin.is_active():161 self.log_info('initialising plugins {plugin} in a {state} state'.format(plugin=plugin.name,
159 plugin.initialise()162 state=plugin.is_active()))
160 self.log_info('Initialisation Complete for {plugin}'.format(plugin=plugin.name))163 if plugin.is_active():
164 try:
165 plugin.initialise()
166 self.log_info('Initialisation Complete for {plugin}'.format(plugin=plugin.name))
167 except Exception:
168 uninitialised_plugins.append(plugin.name.title())
169 self.log_exception('Unable to initialise plugin {plugin}'.format(plugin=plugin.name))
170 display_text = ''
171 if uninitialised_plugins:
172 display_text = translate('OpenLP.PluginManager', 'Unable to initialise the following plugins:') + \
173 '\n\n'.join(uninitialised_plugins) + '\n\n'
174 error_text = State().get_text()
175 if error_text:
176 display_text = display_text + error_text + '\n'
177 if display_text:
178 display_text = display_text + translate('OpenLP.PluginManager', 'See the log file for more details')
179 QtWidgets.QMessageBox.critical(None, UiStrings().Error, display_text,
180 QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Ok))
161181
162 def finalise_plugins(self):182 def finalise_plugins(self):
163 """183 """
164 Loop through all the plugins and give them an opportunity to clean themselves up184 Loop through all the plugins and give them an opportunity to clean themselves up
165 """185 """
166 for plugin in self.plugins:186 for plugin in State().list_plugins():
167 if plugin.is_active():187 if plugin and plugin.is_active():
168 plugin.finalise()188 plugin.finalise()
169 self.log_info('Finalisation Complete for {plugin}'.format(plugin=plugin.name))189 self.log_info('Finalisation Complete for {plugin}'.format(plugin=plugin.name))
170190
171 def get_plugin_by_name(self, name):191 @staticmethod
192 def get_plugin_by_name(name):
172 """193 """
173 Return the plugin which has a name with value ``name``.194 Return the plugin which has a name with value ``name``.
174 """195 """
175 for plugin in self.plugins:196 for plugin in State().list_plugins():
176 if plugin.name == name:197 if plugin and plugin.name == name:
177 return plugin198 return plugin
178 return None199 return None
179200
180 def new_service_created(self):201 @staticmethod
202 def new_service_created():
181 """203 """
182 Loop through all the plugins and give them an opportunity to handle a new service204 Loop through all the plugins and give them an opportunity to handle a new service
183 """205 """
184 for plugin in self.plugins:206 for plugin in State().list_plugins():
185 if plugin.is_active():207 if plugin.is_active():
186 plugin.new_service_created()208 plugin.new_service_created()
187209
=== modified file 'openlp/core/lib/serviceitem.py'
--- openlp/core/lib/serviceitem.py 2018-10-27 01:40:20 +0000
+++ openlp/core/lib/serviceitem.py 2019-01-10 22:02:32 +0000
@@ -32,6 +32,7 @@
3232
33from PyQt5 import QtGui33from PyQt5 import QtGui
3434
35from openlp.core.state import State
35from openlp.core.common import md5_hash36from openlp.core.common import md5_hash
36from openlp.core.common.applocation import AppLocation37from openlp.core.common.applocation import AppLocation
37from openlp.core.common.i18n import translate38from openlp.core.common.i18n import translate
@@ -441,7 +442,7 @@
441 self.processor = header.get('processor', None)442 self.processor = header.get('processor', None)
442 self.has_original_files = True443 self.has_original_files = True
443 self.metadata = header.get('item_meta_data', [])444 self.metadata = header.get('item_meta_data', [])
444 if 'background_audio' in header:445 if 'background_audio' in header and State().check_preconditions('media'):
445 self.background_audio = []446 self.background_audio = []
446 for file_path in header['background_audio']:447 for file_path in header['background_audio']:
447 # In OpenLP 3.0 we switched to storing Path objects in JSON files448 # In OpenLP 3.0 we switched to storing Path objects in JSON files
@@ -616,6 +617,10 @@
616 path_from = frame['path']617 path_from = frame['path']
617 else:618 else:
618 path_from = os.path.join(frame['path'], frame['title'])619 path_from = os.path.join(frame['path'], frame['title'])
620 if isinstance(path_from, str):
621 # Handle service files prior to OpenLP 3.0
622 # Windows can handle both forward and backward slashes, so we use ntpath to get the basename
623 path_from = Path(path_from)
619 return path_from624 return path_from
620625
621 def remove_frame(self, frame):626 def remove_frame(self, frame):
@@ -684,7 +689,7 @@
684 self.is_valid = False689 self.is_valid = False
685 break690 break
686 elif self.is_command():691 elif self.is_command():
687 if self.is_capable(ItemCapabilities.IsOptical):692 if self.is_capable(ItemCapabilities.IsOptical) and State().check_preconditions('media'):
688 if not os.path.exists(frame['title']):693 if not os.path.exists(frame['title']):
689 self.is_valid = False694 self.is_valid = False
690 break695 break
691696
=== added file 'openlp/core/loader.py'
--- openlp/core/loader.py 1970-01-01 00:00:00 +0000
+++ openlp/core/loader.py 2019-01-10 22:02:32 +0000
@@ -0,0 +1,48 @@
1# -*- coding: utf-8 -*-
2# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
3
4###############################################################################
5# OpenLP - Open Source Lyrics Projection #
6# --------------------------------------------------------------------------- #
7# Copyright (c) 2008-2018 OpenLP Developers #
8# --------------------------------------------------------------------------- #
9# This program is free software; you can redistribute it and/or modify it #
10# under the terms of the GNU General Public License as published by the Free #
11# Software Foundation; version 2 of the License. #
12# #
13# This program is distributed in the hope that it will be useful, but WITHOUT #
14# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
15# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
16# more details. #
17# #
18# You should have received a copy of the GNU General Public License along #
19# with this program; if not, write to the Free Software Foundation, Inc., 59 #
20# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
21###############################################################################
22"""
23The :mod:`~openlp.core.loader` module provides a bootstrap for the singleton classes
24"""
25
26from openlp.core.state import State
27from openlp.core.ui.media.mediacontroller import MediaController
28from openlp.core.lib.pluginmanager import PluginManager
29from openlp.core.display.renderer import Renderer
30from openlp.core.lib.imagemanager import ImageManager
31from openlp.core.ui.slidecontroller import LiveController, PreviewController
32
33
34def loader():
35 """
36 God class to load all the components which are registered with the Registry
37
38 :return: None
39 """
40 State().load_settings()
41 MediaController()
42 PluginManager()
43 # Set up the path with plugins
44 ImageManager()
45 Renderer()
46 # Create slide controllers
47 PreviewController()
48 LiveController()
049
=== added file 'openlp/core/state.py'
--- openlp/core/state.py 1970-01-01 00:00:00 +0000
+++ openlp/core/state.py 2019-01-10 22:02:32 +0000
@@ -0,0 +1,175 @@
1# -*- coding: utf-8 -*-
2# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
3
4###############################################################################
5# OpenLP - Open Source Lyrics Projection #
6# --------------------------------------------------------------------------- #
7# Copyright (c) 2008-2018 OpenLP Developers #
8# --------------------------------------------------------------------------- #
9# This program is free software; you can redistribute it and/or modify it #
10# under the terms of the GNU General Public License as published by the Free #
11# Software Foundation; version 2 of the License. #
12# #
13# This program is distributed in the hope that it will be useful, but WITHOUT #
14# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
15# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
16# more details. #
17# #
18# You should have received a copy of the GNU General Public License along #
19# with this program; if not, write to the Free Software Foundation, Inc., 59 #
20# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
21###############################################################################
22
23"""
24The :mod:`core` module provides state management
25
26All the core functions of the OpenLP application including the GUI, settings, logging and a plugin framework are
27contained within the openlp.core module.
28"""
29import logging
30
31from openlp.core.common.registry import Registry
32from openlp.core.common.mixins import LogMixin
33from openlp.core.lib.plugin import PluginStatus
34
35
36log = logging.getLogger()
37
38
39class StateModule(LogMixin):
40 def __init__(self):
41 """
42 Holder of State information per module
43 """
44 super(StateModule, self).__init__()
45 self.name = None
46 self.order = 0
47 self.is_plugin = None
48 self.status = PluginStatus.Inactive
49 self.pass_preconditions = False
50 self.requires = None
51 self.required_by = None
52 self.text = None
53
54
55class State(LogMixin):
56
57 __instance__ = None
58
59 def __new__(cls):
60 """
61 Re-implement the __new__ method to make sure we create a true singleton.
62 """
63 if not cls.__instance__:
64 cls.__instance__ = object.__new__(cls)
65 return cls.__instance__
66
67 def load_settings(self):
68 self.modules = {}
69
70 def save_settings(self):
71 pass
72
73 def add_service(self, name, order, is_plugin=False, status=PluginStatus.Active, requires=None):
74 """
75 Add a module to the array and load dependencies. There will only be one item per module
76 :param name: Module name
77 :param order: Order to display
78 :param is_plugin: Am I a plugin
79 :param status: The active status
80 :param requires: Module name this requires
81 :return:
82 """
83 if name not in self.modules:
84 state = StateModule()
85 state.name = name
86 state.order = order
87 state.is_plugin = is_plugin
88 state.status = status
89 state.requires = requires
90 state.required_by = []
91 self.modules[name] = state
92 if requires and requires in self.modules:
93 if requires not in self.modules[requires].required_by:
94 self.modules[requires].required_by.append(name)
95
96 def missing_text(self, name, text):
97 """
98 Updates the preconditions state of a module
99
100 :param name: Module name
101 :param text: Module missing text
102 :return:
103 """
104 self.modules[name].text = text
105
106 def get_text(self):
107 """
108 return an string of error text
109 :return: a string of text
110 """
111 error_text = ''
112 for mod in self.modules:
113 if self.modules[mod].text:
114 error_text = error_text + self.modules[mod].text + '\n'
115 return error_text
116
117 def update_pre_conditions(self, name, status):
118 """
119 Updates the preconditions state of a module
120
121 :param name: Module name
122 :param status: Module new status
123 :return:
124 """
125 self.modules[name].pass_preconditions = status
126 if self.modules[name].is_plugin:
127 plugin = Registry().get('{mod}_plugin'.format(mod=name))
128 if status:
129 self.log_debug('Plugin {plugin} active'.format(plugin=str(plugin.name)))
130 plugin.set_status()
131 else:
132 plugin.status = PluginStatus.Disabled
133
134 def flush_preconditions(self):
135 """
136 Now all modules are loaded lets update all the preconditions.
137
138 :return:
139 """
140 for mods in self.modules:
141 for req in self.modules[mods].required_by:
142 self.modules[req].pass_preconditions = self.modules[mods].pass_preconditions
143 plugins_list = sorted(self.modules, key=lambda state: self.modules[state].order)
144 mdl = {}
145 for pl in plugins_list:
146 mdl[pl] = self.modules[pl]
147 self.modules = mdl
148
149 def is_module_active(self, name):
150 return self.modules[name].status == PluginStatus.Active
151
152 def check_preconditions(self, name):
153 """
154 Checks if a modules preconditions have been met.
155
156 :param name: Module name
157 :return: Have the preconditions been met.
158 :rtype: bool
159 """
160 if self.modules[name].requires is None:
161 return self.modules[name].pass_preconditions
162 else:
163 mod = self.modules[name].requires
164 return self.modules[mod].pass_preconditions
165
166 def list_plugins(self):
167 """
168 Return a list of plugins
169 :return: an array of plugins
170 """
171 plugins = []
172 for mod in self.modules:
173 if self.modules[mod].is_plugin:
174 plugins.append(Registry().get('{mod}_plugin'.format(mod=mod)))
175 return plugins
0176
=== modified file 'openlp/core/ui/icons.py'
--- openlp/core/ui/icons.py 2018-10-27 01:53:43 +0000
+++ openlp/core/ui/icons.py 2019-01-10 22:02:32 +0000
@@ -78,7 +78,7 @@
78 'book': {'icon': 'fa.book'},78 'book': {'icon': 'fa.book'},
79 'bottom': {'icon': 'fa.angle-double-down'},79 'bottom': {'icon': 'fa.angle-double-down'},
80 'box': {'icon': 'fa.briefcase'},80 'box': {'icon': 'fa.briefcase'},
81 'clapperboard': {'icon': 'fa.chess-board'},81 'clapperboard': {'icon': 'fa.film'},
82 'clock': {'icon': 'fa.clock-o'},82 'clock': {'icon': 'fa.clock-o'},
83 'clone': {'icon': 'fa.clone'},83 'clone': {'icon': 'fa.clone'},
84 'close': {'icon': 'fa.times-circle-o'},84 'close': {'icon': 'fa.times-circle-o'},
8585
=== modified file 'openlp/core/ui/maindisplay.py'
--- openlp/core/ui/maindisplay.py 2018-10-27 01:40:20 +0000
+++ openlp/core/ui/maindisplay.py 2019-01-10 22:02:32 +0000
@@ -30,7 +30,7 @@
30import html30import html
31import logging31import logging
3232
33from PyQt5 import QtCore, QtWidgets, QtWebKit, QtWebKitWidgets, QtGui, QtMultimedia33from PyQt5 import QtCore, QtWidgets, QtWebKit, QtWebKitWidgets, QtGui
3434
35from openlp.core.common import is_macosx, is_win35from openlp.core.common import is_macosx, is_win
36from openlp.core.common.applocation import AppLocation36from openlp.core.common.applocation import AppLocation
@@ -148,10 +148,6 @@
148 self.override = {}148 self.override = {}
149 self.retranslateUi()149 self.retranslateUi()
150 self.media_object = None150 self.media_object = None
151 if self.is_live:
152 self.audio_player = AudioPlayer(self)
153 else:
154 self.audio_player = None
155 self.first_time = True151 self.first_time = True
156 self.web_loaded = True152 self.web_loaded = True
157 self.setStyleSheet(OPAQUE_STYLESHEET)153 self.setStyleSheet(OPAQUE_STYLESHEET)
@@ -604,106 +600,3 @@
604 """600 """
605 self.web_view.setGeometry(0, 0, self.width(), self.height() - 1)601 self.web_view.setGeometry(0, 0, self.width(), self.height() - 1)
606 self.web_view.setGeometry(0, 0, self.width(), self.height())602 self.web_view.setGeometry(0, 0, self.width(), self.height())
607
608
609class AudioPlayer(LogMixin, QtCore.QObject):
610 """
611 This Class will play audio only allowing components to work with a soundtrack independent of the user interface.
612 """
613 position_changed = QtCore.pyqtSignal(int)
614
615 def __init__(self, parent):
616 """
617 The constructor for the display form.
618
619 :param parent: The parent widget.
620 """
621 super(AudioPlayer, self).__init__(parent)
622 self.player = QtMultimedia.QMediaPlayer()
623 self.playlist = QtMultimedia.QMediaPlaylist(self.player)
624 self.volume_slider = None
625 self.player.setPlaylist(self.playlist)
626 self.player.positionChanged.connect(self._on_position_changed)
627
628 def __del__(self):
629 """
630 Shutting down so clean up connections
631 """
632 self.stop()
633
634 def _on_position_changed(self, position):
635 """
636 Emit a signal when the position of the media player updates
637 """
638 self.position_changed.emit(position)
639
640 def set_volume_slider(self, slider):
641 """
642 Connect the volume slider to the media player
643 :param slider:
644 """
645 self.volume_slider = slider
646 self.volume_slider.setMinimum(0)
647 self.volume_slider.setMaximum(100)
648 self.volume_slider.setValue(self.player.volume())
649 self.volume_slider.valueChanged.connect(self.set_volume)
650
651 def set_volume(self, volume):
652 """
653 Set the volume of the media player
654
655 :param volume:
656 """
657 self.player.setVolume(volume)
658
659 def reset(self):
660 """
661 Reset the audio player, clearing the playlist and the queue.
662 """
663 self.stop()
664 self.playlist.clear()
665
666 def play(self):
667 """
668 We want to play the file so start it
669 """
670 self.player.play()
671
672 def pause(self):
673 """
674 Pause the Audio
675 """
676 self.player.pause()
677
678 def stop(self):
679 """
680 Stop the Audio and clean up
681 """
682 self.player.stop()
683
684 def add_to_playlist(self, file_names):
685 """
686 Add another file to the playlist.
687
688 :param file_names: A list with files to be added to the playlist.
689 """
690 if not isinstance(file_names, list):
691 file_names = [file_names]
692 for file_name in file_names:
693 self.playlist.addMedia(QtMultimedia.QMediaContent(QtCore.QUrl.fromLocalFile(str(file_name))))
694
695 def next(self):
696 """
697 Skip forward to the next track in the list
698 """
699 self.playlist.next()
700
701 def go_to(self, index):
702 """
703 Go to a particular track in the list
704
705 :param index: The track to go to
706 """
707 self.playlist.setCurrentIndex(index)
708 if self.player.state() == QtMultimedia.QMediaPlayer.PlayingState:
709 self.player.play()
710603
=== modified file 'openlp/core/ui/mainwindow.py'
--- openlp/core/ui/mainwindow.py 2018-10-27 01:53:43 +0000
+++ openlp/core/ui/mainwindow.py 2019-01-10 22:02:32 +0000
@@ -30,6 +30,7 @@
3030
31from PyQt5 import QtCore, QtGui, QtWidgets31from PyQt5 import QtCore, QtGui, QtWidgets
3232
33from openlp.core.state import State
33from openlp.core.api import websockets34from openlp.core.api import websockets
34from openlp.core.api.http import server35from openlp.core.api.http import server
35from openlp.core.common import is_win, is_macosx, add_actions36from openlp.core.common import is_win, is_macosx, add_actions
@@ -41,11 +42,8 @@
41from openlp.core.common.path import Path, copyfile, create_paths42from openlp.core.common.path import Path, copyfile, create_paths
42from openlp.core.common.registry import Registry43from openlp.core.common.registry import Registry
43from openlp.core.common.settings import Settings44from openlp.core.common.settings import Settings
44from openlp.core.display.renderer import Renderer
45from openlp.core.display.screens import ScreenList45from openlp.core.display.screens import ScreenList
46from openlp.core.lib.imagemanager import ImageManager
47from openlp.core.lib.plugin import PluginStatus46from openlp.core.lib.plugin import PluginStatus
48from openlp.core.lib.pluginmanager import PluginManager
49from openlp.core.lib.ui import create_action47from openlp.core.lib.ui import create_action
50from openlp.core.projectors.manager import ProjectorManager48from openlp.core.projectors.manager import ProjectorManager
51from openlp.core.ui.shortcutlistform import ShortcutListForm49from openlp.core.ui.shortcutlistform import ShortcutListForm
@@ -54,10 +52,8 @@
54from openlp.core.ui.servicemanager import ServiceManager52from openlp.core.ui.servicemanager import ServiceManager
55from openlp.core.ui.aboutform import AboutForm53from openlp.core.ui.aboutform import AboutForm
56from openlp.core.ui.pluginform import PluginForm54from openlp.core.ui.pluginform import PluginForm
57from openlp.core.ui.slidecontroller import LiveController, PreviewController
58from openlp.core.ui.settingsform import SettingsForm55from openlp.core.ui.settingsform import SettingsForm
59from openlp.core.ui.firsttimeform import FirstTimeForm56from openlp.core.ui.firsttimeform import FirstTimeForm
60from openlp.core.ui.media.mediacontroller import MediaController
61from openlp.core.ui.printserviceform import PrintServiceForm57from openlp.core.ui.printserviceform import PrintServiceForm
62from openlp.core.ui.style import PROGRESSBAR_STYLE, get_library_stylesheet58from openlp.core.ui.style import PROGRESSBAR_STYLE, get_library_stylesheet
63from openlp.core.version import get_version59from openlp.core.version import get_version
@@ -90,9 +86,6 @@
90 self.control_splitter.setOrientation(QtCore.Qt.Horizontal)86 self.control_splitter.setOrientation(QtCore.Qt.Horizontal)
91 self.control_splitter.setObjectName('control_splitter')87 self.control_splitter.setObjectName('control_splitter')
92 self.main_content_layout.addWidget(self.control_splitter)88 self.main_content_layout.addWidget(self.control_splitter)
93 # Create slide controllers
94 PreviewController(self)
95 LiveController(self)
96 preview_visible = Settings().value('user interface/preview panel')89 preview_visible = Settings().value('user interface/preview panel')
97 live_visible = Settings().value('user interface/live panel')90 live_visible = Settings().value('user interface/live panel')
98 panel_locked = Settings().value('user interface/lock panel')91 panel_locked = Settings().value('user interface/lock panel')
@@ -501,16 +494,11 @@
501 self.copy_data = False494 self.copy_data = False
502 Settings().set_up_default_values()495 Settings().set_up_default_values()
503 self.about_form = AboutForm(self)496 self.about_form = AboutForm(self)
504 MediaController()
505 self.ws_server = websockets.WebSocketServer()497 self.ws_server = websockets.WebSocketServer()
506 self.http_server = server.HttpServer(self)498 self.http_server = server.HttpServer(self)
507 SettingsForm(self)499 SettingsForm(self)
508 self.formatting_tag_form = FormattingTagForm(self)500 self.formatting_tag_form = FormattingTagForm(self)
509 self.shortcut_form = ShortcutListForm(self)501 self.shortcut_form = ShortcutListForm(self)
510 # Set up the path with plugins
511 PluginManager(self)
512 ImageManager()
513 Renderer()
514 # Set up the interface502 # Set up the interface
515 self.setupUi(self)503 self.setupUi(self)
516 # Define the media Dock Manager504 # Define the media Dock Manager
@@ -660,22 +648,12 @@
660 self.set_view_mode(False, True, False, False, True, True)648 self.set_view_mode(False, True, False, False, True, True)
661 self.mode_live_item.setChecked(True)649 self.mode_live_item.setChecked(True)
662650
663 def app_startup(self):
664 """
665 Give all the plugins a chance to perform some tasks at startup
666 """
667 self.application.process_events()
668 for plugin in self.plugin_manager.plugins:
669 if plugin.is_active():
670 plugin.app_startup()
671 self.application.process_events()
672
673 def first_time(self):651 def first_time(self):
674 """652 """
675 Import themes if first time653 Import themes if first time
676 """654 """
677 self.application.process_events()655 self.application.process_events()
678 for plugin in self.plugin_manager.plugins:656 for plugin in State().list_plugins():
679 if hasattr(plugin, 'first_time'):657 if hasattr(plugin, 'first_time'):
680 self.application.process_events()658 self.application.process_events()
681 plugin.first_time()659 plugin.first_time()
@@ -713,7 +691,7 @@
713 self.projector_manager_dock.setVisible(True)691 self.projector_manager_dock.setVisible(True)
714 else:692 else:
715 self.projector_manager_dock.setVisible(False)693 self.projector_manager_dock.setVisible(False)
716 for plugin in self.plugin_manager.plugins:694 for plugin in State().list_plugins():
717 self.active_plugin = plugin695 self.active_plugin = plugin
718 old_status = self.active_plugin.status696 old_status = self.active_plugin.status
719 self.active_plugin.set_status()697 self.active_plugin.set_status()
@@ -887,7 +865,7 @@
887 setting_sections.extend([self.header_section])865 setting_sections.extend([self.header_section])
888 setting_sections.extend(['crashreport'])866 setting_sections.extend(['crashreport'])
889 # Add plugin sections.867 # Add plugin sections.
890 setting_sections.extend([plugin.name for plugin in self.plugin_manager.plugins])868 setting_sections.extend([plugin.name for plugin in State().list_plugins()])
891 # Copy the settings file to the tmp dir, because we do not want to change the original one.869 # Copy the settings file to the tmp dir, because we do not want to change the original one.
892 temp_dir_path = Path(gettempdir(), 'openlp')870 temp_dir_path = Path(gettempdir(), 'openlp')
893 create_paths(temp_dir_path)871 create_paths(temp_dir_path)
894872
=== modified file 'openlp/core/ui/media/__init__.py'
--- openlp/core/ui/media/__init__.py 2018-10-27 01:40:20 +0000
+++ openlp/core/ui/media/__init__.py 2019-01-10 22:02:32 +0000
@@ -24,10 +24,6 @@
24"""24"""
25import logging25import logging
2626
27from PyQt5 import QtCore
28
29from openlp.core.common.settings import Settings
30
31log = logging.getLogger(__name__ + '.__init__')27log = logging.getLogger(__name__ + '.__init__')
3228
3329
@@ -54,7 +50,7 @@
54 Folder = 550 Folder = 5
5551
5652
57class MediaInfo(object):53class ItemMediaInfo(object):
58 """54 """
59 This class hold the media related info55 This class hold the media related info
60 """56 """
@@ -73,39 +69,6 @@
73 media_type = MediaType()69 media_type = MediaType()
7470
7571
76def get_media_players():
77 """
78 This method extracts the configured media players and overridden player
79 from the settings.
80 """
81 log.debug('get_media_players')
82 saved_players = Settings().value('media/players')
83 reg_ex = QtCore.QRegExp(r'.*\[(.*)\].*')
84 if Settings().value('media/override player') == QtCore.Qt.Checked:
85 if reg_ex.exactMatch(saved_players):
86 overridden_player = '{text}'.format(text=reg_ex.cap(1))
87 else:
88 overridden_player = 'auto'
89 else:
90 overridden_player = ''
91 saved_players_list = saved_players.replace('[', '').replace(']', '').split(',') if saved_players else []
92 return saved_players_list, overridden_player
93
94
95def set_media_players(players_list, overridden_player='auto'):
96 """
97 This method saves the configured media players and overridden player to the settings
98
99 :param players_list: A list with all active media players.
100 :param overridden_player: Here an special media player is chosen for all media actions.
101 """
102 log.debug('set_media_players')
103 players = ','.join(players_list)
104 if Settings().value('media/override player') == QtCore.Qt.Checked and overridden_player != 'auto':
105 players = players.replace(overridden_player, '[{text}]'.format(text=overridden_player))
106 Settings().setValue('media/players', players)
107
108
109def parse_optical_path(input_string):72def parse_optical_path(input_string):
110 """73 """
111 Split the optical path info.74 Split the optical path info.
11275
=== modified file 'openlp/core/ui/media/mediacontroller.py'
--- openlp/core/ui/media/mediacontroller.py 2018-08-25 14:08:19 +0000
+++ openlp/core/ui/media/mediacontroller.py 2019-01-10 22:02:32 +0000
@@ -25,13 +25,19 @@
25"""25"""
26import datetime26import datetime
27import logging27import logging
28import os28
2929try:
30 from pymediainfo import MediaInfo
31 pymediainfo_available = True
32except ImportError:
33 pymediainfo_available = False
34
35from subprocess import check_output
30from PyQt5 import QtCore, QtWidgets36from PyQt5 import QtCore, QtWidgets
3137
38from openlp.core.state import State
32from openlp.core.api.http import register_endpoint39from openlp.core.api.http import register_endpoint
33from openlp.core.common import extension_loader40from openlp.core.common.i18n import translate
34from openlp.core.common.i18n import UiStrings, translate
35from openlp.core.common.mixins import LogMixin, RegistryProperties41from openlp.core.common.mixins import LogMixin, RegistryProperties
36from openlp.core.common.registry import Registry, RegistryBase42from openlp.core.common.registry import Registry, RegistryBase
37from openlp.core.common.settings import Settings43from openlp.core.common.settings import Settings
@@ -39,11 +45,9 @@
39from openlp.core.lib.ui import critical_error_message_box45from openlp.core.lib.ui import critical_error_message_box
40from openlp.core.ui import DisplayControllerType46from openlp.core.ui import DisplayControllerType
41from openlp.core.ui.icons import UiIcons47from openlp.core.ui.icons import UiIcons
42from openlp.core.ui.media import MediaState, MediaInfo, MediaType, get_media_players, set_media_players, \48from openlp.core.ui.media import MediaState, ItemMediaInfo, MediaType, parse_optical_path
43 parse_optical_path
44from openlp.core.ui.media.endpoint import media_endpoint49from openlp.core.ui.media.endpoint import media_endpoint
45from openlp.core.ui.media.mediaplayer import MediaPlayer50from openlp.core.ui.media.vlcplayer import VlcPlayer, get_vlc
46from openlp.core.ui.media.vendor.mediainfoWrapper import MediaInfoWrapper
47from openlp.core.widgets.toolbar import OpenLPToolbar51from openlp.core.widgets.toolbar import OpenLPToolbar
4852
49log = logging.getLogger(__name__)53log = logging.getLogger(__name__)
@@ -62,7 +66,6 @@
62 super(MediaSlider, self).__init__(direction)66 super(MediaSlider, self).__init__(direction)
63 self.manager = manager67 self.manager = manager
64 self.controller = controller68 self.controller = controller
65 self.no_matching_player = translate('MediaPlugin.MediaItem', 'File %s not supported using player %s')
6669
67 def mouseMoveEvent(self, event):70 def mouseMoveEvent(self, event):
68 """71 """
@@ -77,7 +80,6 @@
77 def mousePressEvent(self, event):80 def mousePressEvent(self, event):
78 """81 """
79 Mouse Press event no new functionality82 Mouse Press event no new functionality
80
81 :param event: The triggering event83 :param event: The triggering event
82 """84 """
83 QtWidgets.QSlider.mousePressEvent(self, event)85 QtWidgets.QSlider.mousePressEvent(self, event)
@@ -110,7 +112,9 @@
110 Constructor112 Constructor
111 """113 """
112 super(MediaController, self).__init__(parent)114 super(MediaController, self).__init__(parent)
113 self.media_players = {}115
116 def setup(self):
117 self.vlc_player = None
114 self.display_controllers = {}118 self.display_controllers = {}
115 self.current_media_players = {}119 self.current_media_players = {}
116 # Timer for video state120 # Timer for video state
@@ -134,70 +138,40 @@
134 Registry().register_function('songs_hide', self.media_hide)138 Registry().register_function('songs_hide', self.media_hide)
135 Registry().register_function('songs_blank', self.media_blank)139 Registry().register_function('songs_blank', self.media_blank)
136 Registry().register_function('songs_unblank', self.media_unblank)140 Registry().register_function('songs_unblank', self.media_unblank)
137 Registry().register_function('mediaitem_media_rebuild', self._set_active_players)
138 Registry().register_function('mediaitem_suffixes', self._generate_extensions_lists)141 Registry().register_function('mediaitem_suffixes', self._generate_extensions_lists)
139 register_endpoint(media_endpoint)142 register_endpoint(media_endpoint)
140143
141 def _set_active_players(self):
142 """
143 Set the active players and available media files
144 """
145 saved_players = get_media_players()[0]
146 for player in list(self.media_players.keys()):
147 self.media_players[player].is_active = player in saved_players
148
149 def _generate_extensions_lists(self):144 def _generate_extensions_lists(self):
150 """145 """
151 Set the active players and available media files146 Set the active players and available media files
152 """147 """
153 suffix_list = []148 suffix_list = []
154 self.audio_extensions_list = []149 self.audio_extensions_list = []
155 for player in list(self.media_players.values()):150 if self.vlc_player.is_active:
156 if player.is_active:151 for item in self.vlc_player.audio_extensions_list:
157 for item in player.audio_extensions_list:152 if item not in self.audio_extensions_list:
158 if item not in self.audio_extensions_list:153 self.audio_extensions_list.append(item)
159 self.audio_extensions_list.append(item)154 suffix_list.append(item[2:])
160 suffix_list.append(item[2:])
161 self.video_extensions_list = []155 self.video_extensions_list = []
162 for player in list(self.media_players.values()):156 if self.vlc_player.is_active:
163 if player.is_active:157 for item in self.vlc_player.video_extensions_list:
164 for item in player.video_extensions_list:158 if item not in self.video_extensions_list:
165 if item not in self.video_extensions_list:159 self.video_extensions_list.append(item)
166 self.video_extensions_list.append(item)160 suffix_list.append(item[2:])
167 suffix_list.append(item[2:])
168 self.service_manager.supported_suffixes(suffix_list)161 self.service_manager.supported_suffixes(suffix_list)
169162
170 def register_players(self, player):
171 """
172 Register each media Player (Webkit, Phonon, etc) and store
173 for later use
174
175 :param player: Individual player class which has been enabled
176 """
177 self.media_players[player.name] = player
178
179 def bootstrap_initialise(self):163 def bootstrap_initialise(self):
180 """164 """
181 Check to see if we have any media Player's available.165 Check to see if we have any media Player's available.
182 """166 """
183 controller_dir = os.path.join('core', 'ui', 'media')167 self.setup()
184 # Find all files that do not begin with '.' (lp:#1738047) and end with player.py168 self.vlc_player = VlcPlayer(self)
185 glob_pattern = os.path.join(controller_dir, '[!.]*player.py')169 State().add_service("mediacontroller", 0)
186 extension_loader(glob_pattern, ['mediaplayer.py'])170 if get_vlc() and pymediainfo_available:
187 player_classes = MediaPlayer.__subclasses__()171 State().update_pre_conditions("mediacontroller", True)
188 for player_class in player_classes:172 else:
189 self.register_players(player_class(self))173 State().missing_text("mediacontroller", translate('OpenLP.SlideController',
190 if not self.media_players:174 "VLC or pymediainfo are missing, so you are unable to play any media"))
191 return False
192 saved_players, overridden_player = get_media_players()
193 invalid_media_players = \
194 [media_player for media_player in saved_players if media_player not in self.media_players or
195 not self.media_players[media_player].check_available()]
196 if invalid_media_players:
197 for invalidPlayer in invalid_media_players:
198 saved_players.remove(invalidPlayer)
199 set_media_players(saved_players, overridden_player)
200 self._set_active_players()
201 self._generate_extensions_lists()175 self._generate_extensions_lists()
202 return True176 return True
203177
@@ -235,36 +209,6 @@
235 if self.display_controllers[DisplayControllerType.Preview].media_info.can_loop_playback:209 if self.display_controllers[DisplayControllerType.Preview].media_info.can_loop_playback:
236 self.media_play(self.display_controllers[DisplayControllerType.Preview], True)210 self.media_play(self.display_controllers[DisplayControllerType.Preview], True)
237211
238 def get_media_display_css(self):
239 """
240 Add css style sheets to htmlbuilder
241 """
242 css = ''
243 for player in list(self.media_players.values()):
244 if player.is_active:
245 css += player.get_media_display_css()
246 return css
247
248 def get_media_display_javascript(self):
249 """
250 Add javascript functions to htmlbuilder
251 """
252 js = ''
253 for player in list(self.media_players.values()):
254 if player.is_active:
255 js += player.get_media_display_javascript()
256 return js
257
258 def get_media_display_html(self):
259 """
260 Add html code to htmlbuilder
261 """
262 html = ''
263 for player in list(self.media_players.values()):
264 if player.is_active:
265 html += player.get_media_display_html()
266 return html
267
268 def register_controller(self, controller):212 def register_controller(self, controller):
269 """213 """
270 Registers media controls where the players will be placed to run.214 Registers media controls where the players will be placed to run.
@@ -280,7 +224,7 @@
280224
281 :param controller: First element is the controller which should be used225 :param controller: First element is the controller which should be used
282 """226 """
283 controller.media_info = MediaInfo()227 controller.media_info = ItemMediaInfo()
284 # Build a Media ToolBar228 # Build a Media ToolBar
285 controller.mediabar = OpenLPToolbar(controller)229 controller.mediabar = OpenLPToolbar(controller)
286 controller.mediabar.add_toolbar_action('playbackPlay', text='media_playback_play',230 controller.mediabar.add_toolbar_action('playbackPlay', text='media_playback_play',
@@ -344,16 +288,12 @@
344 """288 """
345 # clean up possible running old media files289 # clean up possible running old media files
346 self.finalise()290 self.finalise()
347 # update player status
348 self._set_active_players()
349 display.has_audio = True291 display.has_audio = True
350 if display.is_live and preview:292 if display.is_live and preview:
351 return293 return
352 if preview:294 if preview:
353 display.has_audio = False295 display.has_audio = False
354 for player in list(self.media_players.values()):296 self.vlc_player.setup(display)
355 if player.is_active:
356 player.setup(display)
357297
358 def set_controls_visible(self, controller, value):298 def set_controls_visible(self, controller, value):
359 """299 """
@@ -366,8 +306,7 @@
366 controller.mediabar.setVisible(value)306 controller.mediabar.setVisible(value)
367 if controller.is_live and controller.display:307 if controller.is_live and controller.display:
368 if self.current_media_players and value:308 if self.current_media_players and value:
369 if self.current_media_players[controller.controller_type] != self.media_players['webkit']:309 controller.display.set_transparency(False)
370 controller.display.set_transparency(False)
371310
372 @staticmethod311 @staticmethod
373 def resize(display, player):312 def resize(display, player):
@@ -388,16 +327,19 @@
388 :param hidden: The player which is doing the playing327 :param hidden: The player which is doing the playing
389 :param video_behind_text: Is the video to be played behind text.328 :param video_behind_text: Is the video to be played behind text.
390 """329 """
391 is_valid = False330 is_valid = True
392 controller = self.display_controllers[source]331 controller = self.display_controllers[source]
393 # stop running videos332 # stop running videos
394 self.media_reset(controller)333 self.media_reset(controller)
395 controller.media_info = MediaInfo()334 controller.media_info = ItemMediaInfo()
396 controller.media_info.volume = controller.volume_slider.value()335 controller.media_info.volume = controller.volume_slider.value()
397 controller.media_info.is_background = video_behind_text336 controller.media_info.is_background = video_behind_text
398 # background will always loop video.337 # background will always loop video.
399 controller.media_info.can_loop_playback = video_behind_text338 controller.media_info.can_loop_playback = video_behind_text
400 controller.media_info.file_info = QtCore.QFileInfo(service_item.get_frame_path())339 if service_item.is_capable(ItemCapabilities.HasBackgroundAudio):
340 controller.media_info.file_info = service_item.background_audio
341 else:
342 controller.media_info.file_info = [service_item.get_frame_path()]
401 display = self._define_display(controller)343 display = self._define_display(controller)
402 if controller.is_live:344 if controller.is_live:
403 # if this is an optical device use special handling345 # if this is an optical device use special handling
@@ -410,7 +352,7 @@
410 else:352 else:
411 log.debug('video is not optical and live')353 log.debug('video is not optical and live')
412 controller.media_info.length = service_item.media_length354 controller.media_info.length = service_item.media_length
413 is_valid = self._check_file_type(controller, display, service_item)355 is_valid = self._check_file_type(controller, display)
414 display.override['theme'] = ''356 display.override['theme'] = ''
415 display.override['video'] = True357 display.override['video'] = True
416 if controller.media_info.is_background:358 if controller.media_info.is_background:
@@ -430,7 +372,7 @@
430 else:372 else:
431 log.debug('video is not optical and preview')373 log.debug('video is not optical and preview')
432 controller.media_info.length = service_item.media_length374 controller.media_info.length = service_item.media_length
433 is_valid = self._check_file_type(controller, display, service_item)375 is_valid = self._check_file_type(controller, display)
434 if not is_valid:376 if not is_valid:
435 # Media could not be loaded correctly377 # Media could not be loaded correctly
436 critical_error_message_box(translate('MediaPlugin.MediaItem', 'Unsupported File'),378 critical_error_message_box(translate('MediaPlugin.MediaItem', 'Unsupported File'),
@@ -461,19 +403,21 @@
461 return True403 return True
462404
463 @staticmethod405 @staticmethod
464 def media_length(service_item):406 def media_length(media_path):
465 """407 """
466 Uses Media Info to obtain the media length408 Uses Media Info to obtain the media length
467409
468 :param service_item: The ServiceItem containing the details to be played.410 :param media_path: The file path to be checked..
469 """411 """
470 media_info = MediaInfo()412 if MediaInfo.can_parse():
471 media_info.volume = 0413 media_data = MediaInfo.parse(media_path)
472 media_info.file_info = QtCore.QFileInfo(service_item.get_frame_path())414 else:
473 media_data = MediaInfoWrapper.parse(service_item.get_frame_path())415 xml = check_output(['mediainfo', '-f', '--Output=XML', '--Inform=OLDXML', media_path])
416 if not xml.startswith(b'<?xml'):
417 xml = check_output(['mediainfo', '-f', '--Output=XML', media_path])
418 media_data = MediaInfo(xml.decode("utf-8"))
474 # duration returns in milli seconds419 # duration returns in milli seconds
475 service_item.set_media_length(media_data.tracks[0].duration)420 return media_data.tracks[0].duration
476 return True
477421
478 def media_setup_optical(self, filename, title, audio_track, subtitle_track, start, end, display, controller):422 def media_setup_optical(self, filename, title, audio_track, subtitle_track, start, end, display, controller):
479 """423 """
@@ -492,7 +436,7 @@
492 # stop running videos436 # stop running videos
493 self.media_reset(controller)437 self.media_reset(controller)
494 # Setup media info438 # Setup media info
495 controller.media_info = MediaInfo()439 controller.media_info = ItemMediaInfo()
496 controller.media_info.file_info = QtCore.QFileInfo(filename)440 controller.media_info.file_info = QtCore.QFileInfo(filename)
497 if audio_track == -1 and subtitle_track == -1:441 if audio_track == -1 and subtitle_track == -1:
498 controller.media_info.media_type = MediaType.CD442 controller.media_info.media_type = MediaType.CD
@@ -507,86 +451,49 @@
507 # When called from mediaitem display is None451 # When called from mediaitem display is None
508 if display is None:452 if display is None:
509 display = controller.preview_display453 display = controller.preview_display
510 # Find vlc player454 self.vlc_player.load(display)
511 used_players = get_media_players()[0]455 self.resize(display, self.vlc_player)
512 vlc_player = None456 self.current_media_players[controller.controller_type] = self.vlc_player
513 for title in used_players:
514 player = self.media_players[title]
515 if player.name == 'vlc':
516 vlc_player = player
517 if vlc_player is None:
518 critical_error_message_box(translate('MediaPlugin.MediaItem', 'VLC player required'),
519 translate('MediaPlugin.MediaItem',
520 'VLC player required for playback of optical devices'))
521 return False
522 vlc_player.load(display)
523 self.resize(display, vlc_player)
524 self.current_media_players[controller.controller_type] = vlc_player
525 if audio_track == -1 and subtitle_track == -1:457 if audio_track == -1 and subtitle_track == -1:
526 controller.media_info.media_type = MediaType.CD458 controller.media_info.media_type = MediaType.CD
527 else:459 else:
528 controller.media_info.media_type = MediaType.DVD460 controller.media_info.media_type = MediaType.DVD
529 return True461 return True
530462
531 @staticmethod463 def _check_file_type(self, controller, display):
532 def _get_used_players(service_item):
533 """
534 Find the player for a given service item
535
536 :param service_item: where the information is about the media and required player
537 :return: player description
538 """
539 used_players = get_media_players()[0]
540 # If no player, we can't play
541 if not used_players:
542 return False
543 default_player = [used_players[0]]
544 if service_item.processor and service_item.processor != UiStrings().Automatic:
545 # check to see if the player is usable else use the default one.
546 if service_item.processor.lower() not in used_players:
547 used_players = default_player
548 else:
549 used_players = [service_item.processor.lower()]
550 return used_players
551
552 def _check_file_type(self, controller, display, service_item):
553 """464 """
554 Select the correct media Player type from the prioritized Player list465 Select the correct media Player type from the prioritized Player list
555466
556 :param controller: First element is the controller which should be used467 :param controller: First element is the controller which should be used
557 :param display: Which display to use468 :param display: Which display to use
558 :param service_item: The ServiceItem containing the details to be played.
559 """469 """
560 used_players = self._get_used_players(service_item)470 for file in controller.media_info.file_info:
561 if controller.media_info.file_info.isFile():471 if file.is_file:
562 suffix = '*.%s' % controller.media_info.file_info.suffix().lower()472 suffix = '*%s' % file.suffix.lower()
563 for title in used_players:473 player = self.vlc_player
564 if not title:474 file = str(file)
565 continue
566 player = self.media_players[title]
567 if suffix in player.video_extensions_list:475 if suffix in player.video_extensions_list:
568 if not controller.media_info.is_background or controller.media_info.is_background and \476 if not controller.media_info.is_background or controller.media_info.is_background and \
569 player.can_background:477 player.can_background:
570 self.resize(display, player)478 self.resize(display, player)
571 if player.load(display):479 if player.load(display, file):
572 self.current_media_players[controller.controller_type] = player480 self.current_media_players[controller.controller_type] = player
573 controller.media_info.media_type = MediaType.Video481 controller.media_info.media_type = MediaType.Video
574 return True482 return True
575 if suffix in player.audio_extensions_list:483 if suffix in player.audio_extensions_list:
576 if player.load(display):484 if player.load(display, file):
577 self.current_media_players[controller.controller_type] = player485 self.current_media_players[controller.controller_type] = player
578 controller.media_info.media_type = MediaType.Audio486 controller.media_info.media_type = MediaType.Audio
579 return True487 return True
580 else:488 else:
581 for title in used_players:489 player = self.vlc_player
582 player = self.media_players[title]490 file = str(file)
583 if player.can_folder:491 if player.can_folder:
584 self.resize(display, player)492 self.resize(display, player)
585 if player.load(display):493 if player.load(display, file):
586 self.current_media_players[controller.controller_type] = player494 self.current_media_players[controller.controller_type] = player
587 controller.media_info.media_type = MediaType.Video495 controller.media_info.media_type = MediaType.Video
588 return True496 return True
589 # no valid player found
590 return False497 return False
591498
592 def media_play_msg(self, msg, status=True):499 def media_play_msg(self, msg, status=True):
593500
=== modified file 'openlp/core/ui/media/mediaplayer.py'
--- openlp/core/ui/media/mediaplayer.py 2017-12-29 09:15:48 +0000
+++ openlp/core/ui/media/mediaplayer.py 2019-01-10 22:02:32 +0000
@@ -60,11 +60,12 @@
60 """60 """
61 pass61 pass
6262
63 def load(self, display):63 def load(self, display, file):
64 """64 """
65 Load a new media file and check if it is valid65 Load a new media file and check if it is valid
6666
67 :param display: The display to be updated.67 :param display: The display to be updated.
68 :param file: The file to be loaded
68 """69 """
69 return True70 return True
7071
7172
=== modified file 'openlp/core/ui/media/playertab.py'
--- openlp/core/ui/media/playertab.py 2018-08-25 14:08:19 +0000
+++ openlp/core/ui/media/playertab.py 2019-01-10 22:02:32 +0000
@@ -32,7 +32,6 @@
32from openlp.core.lib.settingstab import SettingsTab32from openlp.core.lib.settingstab import SettingsTab
33from openlp.core.lib.ui import create_button33from openlp.core.lib.ui import create_button
34from openlp.core.ui.icons import UiIcons34from openlp.core.ui.icons import UiIcons
35from openlp.core.ui.media import get_media_players, set_media_players
36from openlp.core.widgets.buttons import ColorButton35from openlp.core.widgets.buttons import ColorButton
3736
3837
@@ -202,7 +201,7 @@
202 """201 """
203 if self.saved_used_players:202 if self.saved_used_players:
204 self.used_players = self.saved_used_players203 self.used_players = self.saved_used_players
205 self.used_players = get_media_players()[0]204 # self.used_players = get_media_players()[0]
206 self.saved_used_players = self.used_players205 self.saved_used_players = self.used_players
207 settings = Settings()206 settings = Settings()
208 settings.beginGroup(self.settings_section)207 settings.beginGroup(self.settings_section)
@@ -220,13 +219,13 @@
220 settings.beginGroup(self.settings_section)219 settings.beginGroup(self.settings_section)
221 settings.setValue('background color', self.background_color)220 settings.setValue('background color', self.background_color)
222 settings.endGroup()221 settings.endGroup()
223 old_players, override_player = get_media_players()222 # old_players, override_player = get_media_players()
224 if self.used_players != old_players:223 # if self.used_players != old_players:
225 # clean old Media stuff224 # # clean old Media stuff
226 set_media_players(self.used_players, override_player)225 # set_media_players(self.used_players, override_player)
227 self.settings_form.register_post_process('mediaitem_suffix_reset')226 # self.settings_form.register_post_process('mediaitem_suffix_reset')
228 self.settings_form.register_post_process('mediaitem_media_rebuild')227 # self.settings_form.register_post_process('mediaitem_media_rebuild')
229 self.settings_form.register_post_process('config_screen_changed')228 # self.settings_form.register_post_process('config_screen_changed')
230229
231 def post_set_up(self, post_update=False):230 def post_set_up(self, post_update=False):
232 """231 """
233232
=== removed file 'openlp/core/ui/media/vendor/mediainfoWrapper.py'
--- openlp/core/ui/media/vendor/mediainfoWrapper.py 2018-10-27 01:40:20 +0000
+++ openlp/core/ui/media/vendor/mediainfoWrapper.py 1970-01-01 00:00:00 +0000
@@ -1,128 +0,0 @@
1# -*- coding: utf-8 -*-
2# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
3
4###############################################################################
5# OpenLP - Open Source Lyrics Projection #
6# --------------------------------------------------------------------------- #
7# Copyright (c) 2008-2018 OpenLP Developers #
8# --------------------------------------------------------------------------- #
9# This program is free software; you can redistribute it and/or modify it #
10# under the terms of the GNU General Public License as published by the Free #
11# Software Foundation; version 2 of the License. #
12# #
13# This program is distributed in the hope that it will be useful, but WITHOUT #
14# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
15# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
16# more details. #
17# #
18# You should have received a copy of the GNU General Public License along #
19# with this program; if not, write to the Free Software Foundation, Inc., 59 #
20# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
21###############################################################################
22"""
23The :mod:`~openlp.core.ui.media.mediainfo` module contains code to run mediainfo on a media file and obtain
24information related to the rwquested media.
25"""
26import json
27import os
28from subprocess import check_output
29
30from bs4 import BeautifulSoup, NavigableString
31
32ENV_DICT = os.environ
33
34
35class Track(object):
36
37 def __getattribute__(self, name):
38 try:
39 return object.__getattribute__(self, name)
40 except Exception:
41 pass
42 return None
43
44 def __init__(self, xml_dom_fragment):
45 self.xml_dom_fragment = xml_dom_fragment
46 self.track_type = xml_dom_fragment.attrs['type']
47 for el in self.xml_dom_fragment.children:
48 if not isinstance(el, NavigableString):
49 node_name = el.name.lower().strip().strip('_')
50 if node_name == 'id':
51 node_name = 'track_id'
52 node_value = el.string
53 other_node_name = "other_%s" % node_name
54 if getattr(self, node_name) is None:
55 setattr(self, node_name, node_value)
56 else:
57 if getattr(self, other_node_name) is None:
58 setattr(self, other_node_name, [node_value, ])
59 else:
60 getattr(self, other_node_name).append(node_value)
61
62 for o in [d for d in self.__dict__.keys() if d.startswith('other_')]:
63 try:
64 primary = o.replace('other_', '')
65 setattr(self, primary, int(getattr(self, primary)))
66 except Exception:
67 for v in getattr(self, o):
68 try:
69 current = getattr(self, primary)
70 setattr(self, primary, int(v))
71 getattr(self, o).append(current)
72 break
73 except Exception:
74 pass
75
76 def __repr__(self):
77 return "<Track track_id='{0}', track_type='{1}'>".format(self.track_id, self.track_type)
78
79 def to_data(self):
80 data = {}
81 for k, v in self.__dict__.items():
82 if k != 'xml_dom_fragment':
83 data[k] = v
84 return data
85
86
87class MediaInfoWrapper(object):
88
89 def __init__(self, xml):
90 self.xml_dom = xml
91 xml_types = (str,) # no unicode type in python3
92 if isinstance(xml, xml_types):
93 self.xml_dom = MediaInfoWrapper.parse_xml_data_into_dom(xml)
94
95 @staticmethod
96 def parse_xml_data_into_dom(xml_data):
97 return BeautifulSoup(xml_data, "xml")
98
99 @staticmethod
100 def parse(filename, environment=ENV_DICT):
101 xml = check_output(['mediainfo', '-f', '--Output=XML', '--Inform=OLDXML', filename])
102 if not xml.startswith(b'<?xml'):
103 xml = check_output(['mediainfo', '-f', '--Output=XML', filename])
104 xml_dom = MediaInfoWrapper.parse_xml_data_into_dom(xml)
105 return MediaInfoWrapper(xml_dom)
106
107 def _populate_tracks(self):
108 if self.xml_dom is None:
109 return
110 for xml_track in self.xml_dom.Mediainfo.File.find_all("track"):
111 self._tracks.append(Track(xml_track))
112
113 @property
114 def tracks(self):
115 if not hasattr(self, "_tracks"):
116 self._tracks = []
117 if len(self._tracks) == 0:
118 self._populate_tracks()
119 return self._tracks
120
121 def to_data(self):
122 data = {'tracks': []}
123 for track in self.tracks:
124 data['tracks'].append(track.to_data())
125 return data
126
127 def to_json(self):
128 return json.dumps(self.to_data())
1290
=== modified file 'openlp/core/ui/media/vendor/vlc.py'
--- openlp/core/ui/media/vendor/vlc.py 2017-12-28 08:27:44 +0000
+++ openlp/core/ui/media/vendor/vlc.py 2019-01-10 22:02:32 +0000
@@ -1,8 +1,9 @@
1#! /usr/bin/python1#! /usr/bin/python
2# -*- coding: utf-8 -*-
23
3# Python ctypes bindings for VLC4# Python ctypes bindings for VLC
4#5#
5# Copyright (C) 2009-2012 the VideoLAN team6# Copyright (C) 2009-2017 the VideoLAN team
6# $Id: $7# $Id: $
7#8#
8# Authors: Olivier Aubert <contact at olivieraubert.net>9# Authors: Olivier Aubert <contact at olivieraubert.net>
@@ -27,7 +28,7 @@
27U{http://wiki.videolan.org/LibVLC}.28U{http://wiki.videolan.org/LibVLC}.
2829
29You can find the documentation and a README file with some examples30You can find the documentation and a README file with some examples
30at U{http://www.advene.org/download/python-ctypes/}.31at U{http://www.olivieraubert.net/vlc/python-ctypes/}.
3132
32Basically, the most important class is L{Instance}, which is used33Basically, the most important class is L{Instance}, which is used
33to create a libvlc instance. From this instance, you then create34to create a libvlc instance. From this instance, you then create
@@ -40,15 +41,21 @@
40"""41"""
4142
42import ctypes43import ctypes
43import functools44from ctypes.util import find_library
44import os45import os
45import sys46import sys
46from ctypes.util import find_library47import functools
48
47# Used by EventManager in override.py49# Used by EventManager in override.py
48from inspect import getargspec50from inspect import getargspec
4951
50__version__ = "N/A"52import logging
51build_date = "Mon Jan 25 19:40:05 2016"53logger = logging.getLogger(__name__)
54
55__version__ = "3.0.3104"
56__libvlc_version__ = "3.0.3"
57__generator_version__ = "1.4"
58build_date = "Fri Jul 13 15:18:27 2018 3.0.3"
5259
53# The libvlc doc states that filenames are expected to be in UTF8, do60# The libvlc doc states that filenames are expected to be in UTF8, do
54# not rely on sys.getfilesystemencoding() which will be confused,61# not rely on sys.getfilesystemencoding() which will be confused,
@@ -104,7 +111,19 @@
104111
105def find_lib():112def find_lib():
106 dll = None113 dll = None
107 plugin_path = None114 plugin_path = os.environ.get('PYTHON_VLC_MODULE_PATH', None)
115 if 'PYTHON_VLC_LIB_PATH' in os.environ:
116 try:
117 dll = ctypes.CDLL(os.environ['PYTHON_VLC_LIB_PATH'])
118 except OSError:
119 logger.error("Cannot load lib specified by PYTHON_VLC_LIB_PATH env. variable")
120 sys.exit(1)
121 if plugin_path and not os.path.isdir(plugin_path):
122 logger.error("Invalid PYTHON_VLC_MODULE_PATH specified. Please fix.")
123 sys.exit(1)
124 if dll is not None:
125 return dll, plugin_path
126
108 if sys.platform.startswith('linux'):127 if sys.platform.startswith('linux'):
109 p = find_library('vlc')128 p = find_library('vlc')
110 try:129 try:
@@ -112,7 +131,8 @@
112 except OSError: # may fail131 except OSError: # may fail
113 dll = ctypes.CDLL('libvlc.so.5')132 dll = ctypes.CDLL('libvlc.so.5')
114 elif sys.platform.startswith('win'):133 elif sys.platform.startswith('win'):
115 p = find_library('libvlc.dll')134 libname = 'libvlc.dll'
135 p = find_library(libname)
116 if p is None:136 if p is None:
117 try: # some registry settings137 try: # some registry settings
118 # leaner than win32api, win32con138 # leaner than win32api, win32con
@@ -131,10 +151,14 @@
131 except ImportError: # no PyWin32151 except ImportError: # no PyWin32
132 pass152 pass
133 if plugin_path is None:153 if plugin_path is None:
134 # try some standard locations.154 # try some standard locations.
135 for p in ('Program Files\\VideoLan\\', 'VideoLan\\',155 programfiles = os.environ["ProgramFiles"]
136 'Program Files\\', ''):156 homedir = os.environ["HOMEDRIVE"]
137 p = 'C:\\' + p + 'VLC\\libvlc.dll'157 for p in ('{programfiles}\\VideoLan{libname}', '{homedir}:\\VideoLan{libname}',
158 '{programfiles}{libname}', '{homedir}:{libname}'):
159 p = p.format(homedir = homedir,
160 programfiles = programfiles,
161 libname = '\\VLC\\' + libname)
138 if os.path.exists(p):162 if os.path.exists(p):
139 plugin_path = os.path.dirname(p)163 plugin_path = os.path.dirname(p)
140 break164 break
@@ -142,11 +166,11 @@
142 p = os.getcwd()166 p = os.getcwd()
143 os.chdir(plugin_path)167 os.chdir(plugin_path)
144 # if chdir failed, this will raise an exception168 # if chdir failed, this will raise an exception
145 dll = ctypes.CDLL('libvlc.dll')169 dll = ctypes.CDLL(libname)
146 # restore cwd after dll has been loaded170 # restore cwd after dll has been loaded
147 os.chdir(p)171 os.chdir(p)
148 else: # may fail172 else: # may fail
149 dll = ctypes.CDLL('libvlc.dll')173 dll = ctypes.CDLL(libname)
150 else:174 else:
151 plugin_path = os.path.dirname(p)175 plugin_path = os.path.dirname(p)
152 dll = ctypes.CDLL(p)176 dll = ctypes.CDLL(p)
@@ -154,13 +178,20 @@
154 elif sys.platform.startswith('darwin'):178 elif sys.platform.startswith('darwin'):
155 # FIXME: should find a means to configure path179 # FIXME: should find a means to configure path
156 d = '/Applications/VLC.app/Contents/MacOS/'180 d = '/Applications/VLC.app/Contents/MacOS/'
181 c = d + 'lib/libvlccore.dylib'
157 p = d + 'lib/libvlc.dylib'182 p = d + 'lib/libvlc.dylib'
158 if os.path.exists(p):183 if os.path.exists(p) and os.path.exists(c):
184 # pre-load libvlccore VLC 2.2.8+
185 ctypes.CDLL(c)
159 dll = ctypes.CDLL(p)186 dll = ctypes.CDLL(p)
160 d += 'modules'187 for p in ('modules', 'plugins'):
161 if os.path.isdir(d):188 p = d + p
162 plugin_path = d189 if os.path.isdir(p):
163 else: # hope, some PATH is set...190 plugin_path = p
191 break
192 else: # hope, some [DY]LD_LIBRARY_PATH is set...
193 # pre-load libvlccore VLC 2.2.8+
194 ctypes.CDLL('libvlccore.dylib')
164 dll = ctypes.CDLL('libvlc.dylib')195 dll = ctypes.CDLL('libvlc.dylib')
165196
166 else:197 else:
@@ -292,6 +323,8 @@
292 def from_param(self, param):323 def from_param(self, param):
293 if isinstance(param, _Seqs):324 if isinstance(param, _Seqs):
294 return (self.etype * len(param))(*param)325 return (self.etype * len(param))(*param)
326 else:
327 return ctypes.POINTER(param)
295328
296# errcheck functions for some native functions.329# errcheck functions for some native functions.
297def string_result(result, func, arguments):330def string_result(result, func, arguments):
@@ -393,6 +426,37 @@
393LogLevel.NOTICE = LogLevel(2)426LogLevel.NOTICE = LogLevel(2)
394LogLevel.WARNING = LogLevel(3)427LogLevel.WARNING = LogLevel(3)
395428
429class MediaDiscovererCategory(_Enum):
430 '''Category of a media discoverer
431See libvlc_media_discoverer_list_get().
432 '''
433 _enum_names_ = {
434 0: 'devices',
435 1: 'lan',
436 2: 'podcasts',
437 3: 'localdirs',
438 }
439MediaDiscovererCategory.devices = MediaDiscovererCategory(0)
440MediaDiscovererCategory.lan = MediaDiscovererCategory(1)
441MediaDiscovererCategory.localdirs = MediaDiscovererCategory(3)
442MediaDiscovererCategory.podcasts = MediaDiscovererCategory(2)
443
444class DialogQuestionType(_Enum):
445 '''@defgroup libvlc_dialog libvlc dialog
446@ingroup libvlc
447@{
448@file
449libvlc dialog external api.
450 '''
451 _enum_names_ = {
452 0: 'NORMAL',
453 1: 'WARNING',
454 2: 'CRITICAL',
455 }
456DialogQuestionType.CRITICAL = DialogQuestionType(2)
457DialogQuestionType.NORMAL = DialogQuestionType(0)
458DialogQuestionType.WARNING = DialogQuestionType(1)
459
396class EventType(_Enum):460class EventType(_Enum):
397 '''Event types.461 '''Event types.
398 '''462 '''
@@ -424,10 +488,21 @@
424 273: 'MediaPlayerLengthChanged',488 273: 'MediaPlayerLengthChanged',
425 274: 'MediaPlayerVout',489 274: 'MediaPlayerVout',
426 275: 'MediaPlayerScrambledChanged',490 275: 'MediaPlayerScrambledChanged',
491 276: 'MediaPlayerESAdded',
492 277: 'MediaPlayerESDeleted',
493 278: 'MediaPlayerESSelected',
494 279: 'MediaPlayerCorked',
495 280: 'MediaPlayerUncorked',
496 281: 'MediaPlayerMuted',
497 282: 'MediaPlayerUnmuted',
498 283: 'MediaPlayerAudioVolume',
499 284: 'MediaPlayerAudioDevice',
500 285: 'MediaPlayerChapterChanged',
427 0x200: 'MediaListItemAdded',501 0x200: 'MediaListItemAdded',
428 513: 'MediaListWillAddItem',502 513: 'MediaListWillAddItem',
429 514: 'MediaListItemDeleted',503 514: 'MediaListItemDeleted',
430 515: 'MediaListWillDeleteItem',504 515: 'MediaListWillDeleteItem',
505 516: 'MediaListEndReached',
431 0x300: 'MediaListViewItemAdded',506 0x300: 'MediaListViewItemAdded',
432 769: 'MediaListViewWillAddItem',507 769: 'MediaListViewWillAddItem',
433 770: 'MediaListViewItemDeleted',508 770: 'MediaListViewItemDeleted',
@@ -437,6 +512,8 @@
437 1026: 'MediaListPlayerStopped',512 1026: 'MediaListPlayerStopped',
438 0x500: 'MediaDiscovererStarted',513 0x500: 'MediaDiscovererStarted',
439 1281: 'MediaDiscovererEnded',514 1281: 'MediaDiscovererEnded',
515 1282: 'RendererDiscovererItemAdded',
516 1283: 'RendererDiscovererItemDeleted',
440 0x600: 'VlmMediaAdded',517 0x600: 'VlmMediaAdded',
441 1537: 'VlmMediaRemoved',518 1537: 'VlmMediaRemoved',
442 1538: 'VlmMediaChanged',519 1538: 'VlmMediaChanged',
@@ -453,6 +530,7 @@
453EventType.MediaDiscovererStarted = EventType(0x500)530EventType.MediaDiscovererStarted = EventType(0x500)
454EventType.MediaDurationChanged = EventType(2)531EventType.MediaDurationChanged = EventType(2)
455EventType.MediaFreed = EventType(4)532EventType.MediaFreed = EventType(4)
533EventType.MediaListEndReached = EventType(516)
456EventType.MediaListItemAdded = EventType(0x200)534EventType.MediaListItemAdded = EventType(0x200)
457EventType.MediaListItemDeleted = EventType(514)535EventType.MediaListItemDeleted = EventType(514)
458EventType.MediaListPlayerNextItemSet = EventType(1025)536EventType.MediaListPlayerNextItemSet = EventType(1025)
@@ -466,13 +544,21 @@
466EventType.MediaListWillDeleteItem = EventType(515)544EventType.MediaListWillDeleteItem = EventType(515)
467EventType.MediaMetaChanged = EventType(0)545EventType.MediaMetaChanged = EventType(0)
468EventType.MediaParsedChanged = EventType(3)546EventType.MediaParsedChanged = EventType(3)
547EventType.MediaPlayerAudioDevice = EventType(284)
548EventType.MediaPlayerAudioVolume = EventType(283)
469EventType.MediaPlayerBackward = EventType(264)549EventType.MediaPlayerBackward = EventType(264)
470EventType.MediaPlayerBuffering = EventType(259)550EventType.MediaPlayerBuffering = EventType(259)
551EventType.MediaPlayerChapterChanged = EventType(285)
552EventType.MediaPlayerCorked = EventType(279)
553EventType.MediaPlayerESAdded = EventType(276)
554EventType.MediaPlayerESDeleted = EventType(277)
555EventType.MediaPlayerESSelected = EventType(278)
471EventType.MediaPlayerEncounteredError = EventType(266)556EventType.MediaPlayerEncounteredError = EventType(266)
472EventType.MediaPlayerEndReached = EventType(265)557EventType.MediaPlayerEndReached = EventType(265)
473EventType.MediaPlayerForward = EventType(263)558EventType.MediaPlayerForward = EventType(263)
474EventType.MediaPlayerLengthChanged = EventType(273)559EventType.MediaPlayerLengthChanged = EventType(273)
475EventType.MediaPlayerMediaChanged = EventType(0x100)560EventType.MediaPlayerMediaChanged = EventType(0x100)
561EventType.MediaPlayerMuted = EventType(281)
476EventType.MediaPlayerNothingSpecial = EventType(257)562EventType.MediaPlayerNothingSpecial = EventType(257)
477EventType.MediaPlayerOpening = EventType(258)563EventType.MediaPlayerOpening = EventType(258)
478EventType.MediaPlayerPausableChanged = EventType(270)564EventType.MediaPlayerPausableChanged = EventType(270)
@@ -485,10 +571,14 @@
485EventType.MediaPlayerStopped = EventType(262)571EventType.MediaPlayerStopped = EventType(262)
486EventType.MediaPlayerTimeChanged = EventType(267)572EventType.MediaPlayerTimeChanged = EventType(267)
487EventType.MediaPlayerTitleChanged = EventType(271)573EventType.MediaPlayerTitleChanged = EventType(271)
574EventType.MediaPlayerUncorked = EventType(280)
575EventType.MediaPlayerUnmuted = EventType(282)
488EventType.MediaPlayerVout = EventType(274)576EventType.MediaPlayerVout = EventType(274)
489EventType.MediaStateChanged = EventType(5)577EventType.MediaStateChanged = EventType(5)
490EventType.MediaSubItemAdded = EventType(1)578EventType.MediaSubItemAdded = EventType(1)
491EventType.MediaSubItemTreeAdded = EventType(6)579EventType.MediaSubItemTreeAdded = EventType(6)
580EventType.RendererDiscovererItemAdded = EventType(1282)
581EventType.RendererDiscovererItemDeleted = EventType(1283)
492EventType.VlmMediaAdded = EventType(0x600)582EventType.VlmMediaAdded = EventType(0x600)
493EventType.VlmMediaChanged = EventType(1538)583EventType.VlmMediaChanged = EventType(1538)
494EventType.VlmMediaInstanceStarted = EventType(1539)584EventType.VlmMediaInstanceStarted = EventType(1539)
@@ -528,15 +618,21 @@
528 20: 'Episode',618 20: 'Episode',
529 21: 'ShowName',619 21: 'ShowName',
530 22: 'Actors',620 22: 'Actors',
621 23: 'AlbumArtist',
622 24: 'DiscNumber',
623 25: 'DiscTotal',
531 }624 }
532Meta.Actors = Meta(22)625Meta.Actors = Meta(22)
533Meta.Album = Meta(4)626Meta.Album = Meta(4)
627Meta.AlbumArtist = Meta(23)
534Meta.Artist = Meta(1)628Meta.Artist = Meta(1)
535Meta.ArtworkURL = Meta(15)629Meta.ArtworkURL = Meta(15)
536Meta.Copyright = Meta(3)630Meta.Copyright = Meta(3)
537Meta.Date = Meta(8)631Meta.Date = Meta(8)
538Meta.Description = Meta(6)632Meta.Description = Meta(6)
539Meta.Director = Meta(18)633Meta.Director = Meta(18)
634Meta.DiscNumber = Meta(24)
635Meta.DiscTotal = Meta(25)
540Meta.EncodedBy = Meta(14)636Meta.EncodedBy = Meta(14)
541Meta.Episode = Meta(20)637Meta.Episode = Meta(20)
542Meta.Genre = Meta(2)638Meta.Genre = Meta(2)
@@ -558,7 +654,7 @@
558See mediacontrol_playerstatus, See input_state_e enums,654See mediacontrol_playerstatus, See input_state_e enums,
559and videolan.libvlc.state (at bindings/cil/src/media.cs).655and videolan.libvlc.state (at bindings/cil/src/media.cs).
560expected states by web plugins are:656expected states by web plugins are:
561idle/close=0, opening=1, buffering=2, playing=3, paused=4,657idle/close=0, opening=1, playing=3, paused=4,
562stopping=5, ended=6, error=7.658stopping=5, ended=6, error=7.
563 '''659 '''
564 _enum_names_ = {660 _enum_names_ = {
@@ -594,17 +690,102 @@
594TrackType.unknown = TrackType(-1)690TrackType.unknown = TrackType(-1)
595TrackType.video = TrackType(1)691TrackType.video = TrackType(1)
596692
597class PlaybackMode(_Enum):693class VideoOrient(_Enum):
598 '''Defines playback modes for playlist.694 '''N/A
599 '''695 '''
600 _enum_names_ = {696 _enum_names_ = {
601 0: 'default',697 0: 'left',
602 1: 'loop',698 1: 'right',
603 2: 'repeat',699 2: 'left',
604 }700 3: 'right',
605PlaybackMode.default = PlaybackMode(0)701 4: 'top',
606PlaybackMode.loop = PlaybackMode(1)702 5: 'bottom',
607PlaybackMode.repeat = PlaybackMode(2)703 6: 'top',
704 7: 'bottom',
705 }
706VideoOrient.bottom = VideoOrient(5)
707VideoOrient.bottom = VideoOrient(7)
708VideoOrient.left = VideoOrient(0)
709VideoOrient.left = VideoOrient(2)
710VideoOrient.right = VideoOrient(1)
711VideoOrient.right = VideoOrient(3)
712VideoOrient.top = VideoOrient(4)
713VideoOrient.top = VideoOrient(6)
714
715class VideoProjection(_Enum):
716 '''N/A
717 '''
718 _enum_names_ = {
719 0: 'rectangular',
720 1: 'equirectangular',
721 0x100: 'standard',
722 }
723VideoProjection.equirectangular = VideoProjection(1)
724VideoProjection.rectangular = VideoProjection(0)
725VideoProjection.standard = VideoProjection(0x100)
726
727class MediaType(_Enum):
728 '''Media type
729See libvlc_media_get_type.
730 '''
731 _enum_names_ = {
732 0: 'unknown',
733 1: 'file',
734 2: 'directory',
735 3: 'disc',
736 4: 'stream',
737 5: 'playlist',
738 }
739MediaType.directory = MediaType(2)
740MediaType.disc = MediaType(3)
741MediaType.file = MediaType(1)
742MediaType.playlist = MediaType(5)
743MediaType.stream = MediaType(4)
744MediaType.unknown = MediaType(0)
745
746class MediaParseFlag(_Enum):
747 '''Parse flags used by libvlc_media_parse_with_options()
748See libvlc_media_parse_with_options.
749 '''
750 _enum_names_ = {
751 0x0: 'local',
752 0x1: 'network',
753 0x2: 'local',
754 0x4: 'network',
755 0x8: 'interact',
756 }
757MediaParseFlag.interact = MediaParseFlag(0x8)
758MediaParseFlag.local = MediaParseFlag(0x0)
759MediaParseFlag.local = MediaParseFlag(0x2)
760MediaParseFlag.network = MediaParseFlag(0x1)
761MediaParseFlag.network = MediaParseFlag(0x4)
762
763class MediaParsedStatus(_Enum):
764 '''Parse status used sent by libvlc_media_parse_with_options() or returned by
765libvlc_media_get_parsed_status()
766See libvlc_media_parse_with_options
767See libvlc_media_get_parsed_status.
768 '''
769 _enum_names_ = {
770 1: 'skipped',
771 2: 'failed',
772 3: 'timeout',
773 4: 'done',
774 }
775MediaParsedStatus.done = MediaParsedStatus(4)
776MediaParsedStatus.failed = MediaParsedStatus(2)
777MediaParsedStatus.skipped = MediaParsedStatus(1)
778MediaParsedStatus.timeout = MediaParsedStatus(3)
779
780class MediaSlaveType(_Enum):
781 '''Type of a media slave: subtitle or audio.
782 '''
783 _enum_names_ = {
784 0: 'subtitle',
785 1: 'audio',
786 }
787MediaSlaveType.audio = MediaSlaveType(1)
788MediaSlaveType.subtitle = MediaSlaveType(0)
608789
609class VideoMarqueeOption(_Enum):790class VideoMarqueeOption(_Enum):
610 '''Marq options definition.791 '''Marq options definition.
@@ -641,10 +822,12 @@
641 2: 'down',822 2: 'down',
642 3: 'left',823 3: 'left',
643 4: 'right',824 4: 'right',
825 5: 'popup',
644 }826 }
645NavigateMode.activate = NavigateMode(0)827NavigateMode.activate = NavigateMode(0)
646NavigateMode.down = NavigateMode(2)828NavigateMode.down = NavigateMode(2)
647NavigateMode.left = NavigateMode(3)829NavigateMode.left = NavigateMode(3)
830NavigateMode.popup = NavigateMode(5)
648NavigateMode.right = NavigateMode(4)831NavigateMode.right = NavigateMode(4)
649NavigateMode.up = NavigateMode(1)832NavigateMode.up = NavigateMode(1)
650833
@@ -674,6 +857,23 @@
674Position.right = Position(8)857Position.right = Position(8)
675Position.top = Position(3)858Position.top = Position(3)
676859
860class TeletextKey(_Enum):
861 '''Enumeration of teletext keys than can be passed via
862libvlc_video_set_teletext().
863 '''
864 _enum_names_ = {
865 7471104: 'red',
866 6750208: 'green',
867 7929856: 'yellow',
868 6422528: 'blue',
869 6881280: 'index',
870 }
871TeletextKey.blue = TeletextKey(6422528)
872TeletextKey.green = TeletextKey(6750208)
873TeletextKey.index = TeletextKey(6881280)
874TeletextKey.red = TeletextKey(7471104)
875TeletextKey.yellow = TeletextKey(7929856)
876
677class VideoLogoOption(_Enum):877class VideoLogoOption(_Enum):
678 '''Option values for libvlc_video_{get,set}_logo_{int,string}.878 '''Option values for libvlc_video_{get,set}_logo_{int,string}.
679 '''879 '''
@@ -756,276 +956,366 @@
756AudioOutputChannel.Right = AudioOutputChannel(4)956AudioOutputChannel.Right = AudioOutputChannel(4)
757AudioOutputChannel.Stereo = AudioOutputChannel(1)957AudioOutputChannel.Stereo = AudioOutputChannel(1)
758958
959class MediaPlayerRole(_Enum):
960 '''Media player roles.
961\version libvlc 3.0.0 and later.
962see \ref libvlc_media_player_set_role().
963 '''
964 _enum_names_ = {
965 0: '_None',
966 1: 'Music',
967 2: 'Video',
968 3: 'Communication',
969 4: 'Game',
970 5: 'Notification',
971 6: 'Animation',
972 7: 'Production',
973 8: 'Accessibility',
974 9: 'Test',
975 }
976MediaPlayerRole.Accessibility = MediaPlayerRole(8)
977MediaPlayerRole.Animation = MediaPlayerRole(6)
978MediaPlayerRole.Communication = MediaPlayerRole(3)
979MediaPlayerRole.Game = MediaPlayerRole(4)
980MediaPlayerRole.Music = MediaPlayerRole(1)
981MediaPlayerRole.Notification = MediaPlayerRole(5)
982MediaPlayerRole.Production = MediaPlayerRole(7)
983MediaPlayerRole.Test = MediaPlayerRole(9)
984MediaPlayerRole.Video = MediaPlayerRole(2)
985MediaPlayerRole._None = MediaPlayerRole(0)
986
987class PlaybackMode(_Enum):
988 '''Defines playback modes for playlist.
989 '''
990 _enum_names_ = {
991 0: 'default',
992 1: 'loop',
993 2: 'repeat',
994 }
995PlaybackMode.default = PlaybackMode(0)
996PlaybackMode.loop = PlaybackMode(1)
997PlaybackMode.repeat = PlaybackMode(2)
998
759class Callback(ctypes.c_void_p):999class Callback(ctypes.c_void_p):
760 """Callback function notification1000 """Callback function notification.
761\param p_event the event triggering the callback1001 @param p_event: the event triggering the callback.
762 """1002 """
763 pass1003 pass
764class LogCb(ctypes.c_void_p):1004class LogCb(ctypes.c_void_p):
765 """Callback prototype for LibVLC log message handler.1005 """Callback prototype for LibVLC log message handler.
766\param data data pointer as given to L{libvlc_log_set}()1006 @param data: data pointer as given to L{libvlc_log_set}().
767\param level message level (@ref enum libvlc_log_level)1007 @param level: message level (@ref L{LogLevel}).
768\param ctx message context (meta-information about the message)1008 @param ctx: message context (meta-information about the message).
769\param fmt printf() format string (as defined by ISO C11)1009 @param fmt: printf() format string (as defined by ISO C11).
770\param args variable argument list for the format1010 @param args: variable argument list for the format @note Log message handlers B{must} be thread-safe. @warning The message context pointer, the format string parameters and the variable arguments are only valid until the callback returns.
771\note Log message handlers <b>must</b> be thread-safe.1011 """
772\warning The message context pointer, the format string parameters and the1012 pass
773 variable arguments are only valid until the callback returns.1013class MediaOpenCb(ctypes.c_void_p):
1014 """Callback prototype to open a custom bitstream input media.
1015 The same media item can be opened multiple times. Each time, this callback
1016 is invoked. It should allocate and initialize any instance-specific
1017 resources, then store them in *datap. The instance resources can be freed
1018 in the @ref libvlc_media_close_cb callback.
1019 @param opaque: private pointer as passed to L{libvlc_media_new_callbacks}().
1020 @return: datap storage space for a private data pointer, sizep byte length of the bitstream or UINT64_MAX if unknown.
1021 """
1022 pass
1023class MediaReadCb(ctypes.c_void_p):
1024 """Callback prototype to read data from a custom bitstream input media.
1025 @param opaque: private pointer as set by the @ref libvlc_media_open_cb callback.
1026 @param buf: start address of the buffer to read data into.
1027 @param len: bytes length of the buffer.
1028 @return: strictly positive number of bytes read, 0 on end-of-stream, or -1 on non-recoverable error @note If no data is immediately available, then the callback should sleep. @warning The application is responsible for avoiding deadlock situations. In particular, the callback should return an error if playback is stopped; if it does not return, then L{libvlc_media_player_stop}() will never return.
1029 """
1030 pass
1031class MediaSeekCb(ctypes.c_void_p):
1032 """Callback prototype to seek a custom bitstream input media.
1033 @param opaque: private pointer as set by the @ref libvlc_media_open_cb callback.
1034 @param offset: absolute byte offset to seek to.
1035 @return: 0 on success, -1 on error.
1036 """
1037 pass
1038class MediaCloseCb(ctypes.c_void_p):
1039 """Callback prototype to close a custom bitstream input media.
1040 @param opaque: private pointer as set by the @ref libvlc_media_open_cb callback.
774 """1041 """
775 pass1042 pass
776class VideoLockCb(ctypes.c_void_p):1043class VideoLockCb(ctypes.c_void_p):
777 """Callback prototype to allocate and lock a picture buffer.1044 """Callback prototype to allocate and lock a picture buffer.
778Whenever a new video frame needs to be decoded, the lock callback is1045 Whenever a new video frame needs to be decoded, the lock callback is
779invoked. Depending on the video chroma, one or three pixel planes of1046 invoked. Depending on the video chroma, one or three pixel planes of
780adequate dimensions must be returned via the second parameter. Those1047 adequate dimensions must be returned via the second parameter. Those
781planes must be aligned on 32-bytes boundaries.1048 planes must be aligned on 32-bytes boundaries.
782\param opaque private pointer as passed to L{libvlc_video_set_callbacks}() [IN]1049 @param opaque: private pointer as passed to L{libvlc_video_set_callbacks}() [IN].
783\param planes start address of the pixel planes (LibVLC allocates the array1050 @param planes: start address of the pixel planes (LibVLC allocates the array of void pointers, this callback must initialize the array) [OUT].
784 of void pointers, this callback must initialize the array) [OUT]1051 @return: a private pointer for the display and unlock callbacks to identify the picture buffers.
785\return a private pointer for the display and unlock callbacks to identify
786 the picture buffers
787 """1052 """
788 pass1053 pass
789class VideoUnlockCb(ctypes.c_void_p):1054class VideoUnlockCb(ctypes.c_void_p):
790 """Callback prototype to unlock a picture buffer.1055 """Callback prototype to unlock a picture buffer.
791When the video frame decoding is complete, the unlock callback is invoked.1056 When the video frame decoding is complete, the unlock callback is invoked.
792This callback might not be needed at all. It is only an indication that the1057 This callback might not be needed at all. It is only an indication that the
793application can now read the pixel values if it needs to.1058 application can now read the pixel values if it needs to.
794\warning A picture buffer is unlocked after the picture is decoded,1059 @note: A picture buffer is unlocked after the picture is decoded,
795but before the picture is displayed.1060 but before the picture is displayed.
796\param opaque private pointer as passed to L{libvlc_video_set_callbacks}() [IN]1061 @param opaque: private pointer as passed to L{libvlc_video_set_callbacks}() [IN].
797\param picture private pointer returned from the @ref libvlc_video_lock_cb1062 @param picture: private pointer returned from the @ref libvlc_video_lock_cb callback [IN].
798 callback [IN]1063 @param planes: pixel planes as defined by the @ref libvlc_video_lock_cb callback (this parameter is only for convenience) [IN].
799\param planes pixel planes as defined by the @ref libvlc_video_lock_cb
800 callback (this parameter is only for convenience) [IN]
801 """1064 """
802 pass1065 pass
803class VideoDisplayCb(ctypes.c_void_p):1066class VideoDisplayCb(ctypes.c_void_p):
804 """Callback prototype to display a picture.1067 """Callback prototype to display a picture.
805When the video frame needs to be shown, as determined by the media playback1068 When the video frame needs to be shown, as determined by the media playback
806clock, the display callback is invoked.1069 clock, the display callback is invoked.
807\param opaque private pointer as passed to L{libvlc_video_set_callbacks}() [IN]1070 @param opaque: private pointer as passed to L{libvlc_video_set_callbacks}() [IN].
808\param picture private pointer returned from the @ref libvlc_video_lock_cb1071 @param picture: private pointer returned from the @ref libvlc_video_lock_cb callback [IN].
809 callback [IN]
810 """1072 """
811 pass1073 pass
812class VideoFormatCb(ctypes.c_void_p):1074class VideoFormatCb(ctypes.c_void_p):
813 """Callback prototype to configure picture buffers format.1075 """Callback prototype to configure picture buffers format.
814This callback gets the format of the video as output by the video decoder1076 This callback gets the format of the video as output by the video decoder
815and the chain of video filters (if any). It can opt to change any parameter1077 and the chain of video filters (if any). It can opt to change any parameter
816as it needs. In that case, LibVLC will attempt to convert the video format1078 as it needs. In that case, LibVLC will attempt to convert the video format
817(rescaling and chroma conversion) but these operations can be CPU intensive.1079 (rescaling and chroma conversion) but these operations can be CPU intensive.
818\param opaque pointer to the private pointer passed to1080 @param opaque: pointer to the private pointer passed to L{libvlc_video_set_callbacks}() [IN/OUT].
819 L{libvlc_video_set_callbacks}() [IN/OUT]1081 @param chroma: pointer to the 4 bytes video format identifier [IN/OUT].
820\param chroma pointer to the 4 bytes video format identifier [IN/OUT]1082 @param width: pointer to the pixel width [IN/OUT].
821\param width pointer to the pixel width [IN/OUT]1083 @param height: pointer to the pixel height [IN/OUT].
822\param height pointer to the pixel height [IN/OUT]1084 @param pitches: table of scanline pitches in bytes for each pixel plane (the table is allocated by LibVLC) [OUT].
823\param pitches table of scanline pitches in bytes for each pixel plane1085 @return: lines table of scanlines count for each plane.
824 (the table is allocated by LibVLC) [OUT]
825\param lines table of scanlines count for each plane [OUT]
826\return the number of picture buffers allocated, 0 indicates failure
827\note
828For each pixels plane, the scanline pitch must be bigger than or equal to
829the number of bytes per pixel multiplied by the pixel width.
830Similarly, the number of scanlines must be bigger than of equal to
831the pixel height.
832Furthermore, we recommend that pitches and lines be multiple of 32
833to not break assumption that might be made by various optimizations
834in the video decoders, video filters and/or video converters.
835 """1086 """
836 pass1087 pass
837class VideoCleanupCb(ctypes.c_void_p):1088class VideoCleanupCb(ctypes.c_void_p):
838 """Callback prototype to configure picture buffers format.1089 """Callback prototype to configure picture buffers format.
839\param opaque private pointer as passed to L{libvlc_video_set_callbacks}()1090 @param opaque: private pointer as passed to L{libvlc_video_set_callbacks}() (and possibly modified by @ref libvlc_video_format_cb) [IN].
840 (and possibly modified by @ref libvlc_video_format_cb) [IN]
841 """1091 """
842 pass1092 pass
843class AudioPlayCb(ctypes.c_void_p):1093class AudioPlayCb(ctypes.c_void_p):
844 """Callback prototype for audio playback.1094 """Callback prototype for audio playback.
845\param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN]1095 The LibVLC media player decodes and post-processes the audio signal
846\param samples pointer to the first audio sample to play back [IN]1096 asynchronously (in an internal thread). Whenever audio samples are ready
847\param count number of audio samples to play back1097 to be queued to the output, this callback is invoked.
848\param pts expected play time stamp (see libvlc_delay())1098 The number of samples provided per invocation may depend on the file format,
1099 the audio coding algorithm, the decoder plug-in, the post-processing
1100 filters and timing. Application must not assume a certain number of samples.
1101 The exact format of audio samples is determined by L{libvlc_audio_set_format}()
1102 or L{libvlc_audio_set_format_callbacks}() as is the channels layout.
1103 Note that the number of samples is per channel. For instance, if the audio
1104 track sampling rate is 48000 Hz, then 1200 samples represent 25 milliseconds
1105 of audio signal - regardless of the number of audio channels.
1106 @param data: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN].
1107 @param samples: pointer to a table of audio samples to play back [IN].
1108 @param count: number of audio samples to play back.
1109 @param pts: expected play time stamp (see libvlc_delay()).
849 """1110 """
850 pass1111 pass
851class AudioPauseCb(ctypes.c_void_p):1112class AudioPauseCb(ctypes.c_void_p):
852 """Callback prototype for audio pause.1113 """Callback prototype for audio pause.
853\note The pause callback is never called if the audio is already paused.1114 LibVLC invokes this callback to pause audio playback.
854\param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN]1115 @note: The pause callback is never called if the audio is already paused.
855\param pts time stamp of the pause request (should be elapsed already)1116 @param data: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN].
1117 @param pts: time stamp of the pause request (should be elapsed already).
856 """1118 """
857 pass1119 pass
858class AudioResumeCb(ctypes.c_void_p):1120class AudioResumeCb(ctypes.c_void_p):
859 """Callback prototype for audio resumption (i.e. restart from pause).1121 """Callback prototype for audio resumption.
860\note The resume callback is never called if the audio is not paused.1122 LibVLC invokes this callback to resume audio playback after it was
861\param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN]1123 previously paused.
862\param pts time stamp of the resumption request (should be elapsed already)1124 @note: The resume callback is never called if the audio is not paused.
1125 @param data: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN].
1126 @param pts: time stamp of the resumption request (should be elapsed already).
863 """1127 """
864 pass1128 pass
865class AudioFlushCb(ctypes.c_void_p):1129class AudioFlushCb(ctypes.c_void_p):
866 """Callback prototype for audio buffer flush1130 """Callback prototype for audio buffer flush.
867(i.e. discard all pending buffers and stop playback as soon as possible).1131 LibVLC invokes this callback if it needs to discard all pending buffers and
868\param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN]1132 stop playback as soon as possible. This typically occurs when the media is
1133 stopped.
1134 @param data: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN].
869 """1135 """
870 pass1136 pass
871class AudioDrainCb(ctypes.c_void_p):1137class AudioDrainCb(ctypes.c_void_p):
872 """Callback prototype for audio buffer drain1138 """Callback prototype for audio buffer drain.
873(i.e. wait for pending buffers to be played).1139 LibVLC may invoke this callback when the decoded audio track is ending.
874\param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN]1140 There will be no further decoded samples for the track, but playback should
1141 nevertheless continue until all already pending buffers are rendered.
1142 @param data: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN].
875 """1143 """
876 pass1144 pass
877class AudioSetVolumeCb(ctypes.c_void_p):1145class AudioSetVolumeCb(ctypes.c_void_p):
878 """Callback prototype for audio volume change.1146 """Callback prototype for audio volume change.
879\param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN]1147 @param data: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN].
880\param volume software volume (1. = nominal, 0. = mute)1148 @param volume: software volume (1. = nominal, 0. = mute).
881\param mute muted flag1149 @param mute: muted flag.
882 """1150 """
883 pass1151 pass
884class AudioSetupCb(ctypes.c_void_p):1152class AudioSetupCb(ctypes.c_void_p):
885 """Callback prototype to setup the audio playback.1153 """Callback prototype to setup the audio playback.
886This is called when the media player needs to create a new audio output.1154 This is called when the media player needs to create a new audio output.
887\param opaque pointer to the data pointer passed to1155 @param opaque: pointer to the data pointer passed to L{libvlc_audio_set_callbacks}() [IN/OUT].
888 L{libvlc_audio_set_callbacks}() [IN/OUT]1156 @param format: 4 bytes sample format [IN/OUT].
889\param format 4 bytes sample format [IN/OUT]1157 @param rate: sample rate [IN/OUT].
890\param rate sample rate [IN/OUT]1158 @param channels: channels count [IN/OUT].
891\param channels channels count [IN/OUT]1159 @return: 0 on success, anything else to skip audio playback.
892\return 0 on success, anything else to skip audio playback
893 """1160 """
894 pass1161 pass
895class AudioCleanupCb(ctypes.c_void_p):1162class AudioCleanupCb(ctypes.c_void_p):
896 """Callback prototype for audio playback cleanup.1163 """Callback prototype for audio playback cleanup.
897This is called when the media player no longer needs an audio output.1164 This is called when the media player no longer needs an audio output.
898\param opaque data pointer as passed to L{libvlc_audio_set_callbacks}() [IN]1165 @param opaque: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN].
899 """1166 """
900 pass1167 pass
901class CallbackDecorators(object):1168class CallbackDecorators(object):
902 "Class holding various method decorators for callback functions."1169 "Class holding various method decorators for callback functions."
903 Callback = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p)1170 Callback = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p)
904 Callback.__doc__ = '''Callback function notification1171 Callback.__doc__ = '''Callback function notification.
905\param p_event the event triggering the callback1172 @param p_event: the event triggering the callback.
906 ''' 1173 '''
907 LogCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int, Log_ptr, ctypes.c_char_p, ctypes.c_void_p)1174 LogCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int, Log_ptr, ctypes.c_char_p, ctypes.c_void_p)
908 LogCb.__doc__ = '''Callback prototype for LibVLC log message handler.1175 LogCb.__doc__ = '''Callback prototype for LibVLC log message handler.
909\param data data pointer as given to L{libvlc_log_set}()1176 @param data: data pointer as given to L{libvlc_log_set}().
910\param level message level (@ref enum libvlc_log_level)1177 @param level: message level (@ref L{LogLevel}).
911\param ctx message context (meta-information about the message)1178 @param ctx: message context (meta-information about the message).
912\param fmt printf() format string (as defined by ISO C11)1179 @param fmt: printf() format string (as defined by ISO C11).
913\param args variable argument list for the format1180 @param args: variable argument list for the format @note Log message handlers B{must} be thread-safe. @warning The message context pointer, the format string parameters and the variable arguments are only valid until the callback returns.
914\note Log message handlers <b>must</b> be thread-safe.1181 '''
915\warning The message context pointer, the format string parameters and the1182 MediaOpenCb = ctypes.CFUNCTYPE(ctypes.POINTER(ctypes.c_int), ctypes.c_void_p, ctypes.POINTER(ctypes.c_void_p), ctypes.POINTER(ctypes.c_uint64))
916 variable arguments are only valid until the callback returns.1183 MediaOpenCb.__doc__ = '''Callback prototype to open a custom bitstream input media.
917 ''' 1184 The same media item can be opened multiple times. Each time, this callback
918 VideoLockCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ListPOINTER(ctypes.c_void_p))1185 is invoked. It should allocate and initialize any instance-specific
1186 resources, then store them in *datap. The instance resources can be freed
1187 in the @ref libvlc_media_close_cb callback.
1188 @param opaque: private pointer as passed to L{libvlc_media_new_callbacks}().
1189 @return: datap storage space for a private data pointer, sizep byte length of the bitstream or UINT64_MAX if unknown.
1190 '''
1191 MediaReadCb = ctypes.CFUNCTYPE(ctypes.POINTER(ctypes.c_ssize_t), ctypes.c_void_p, ctypes.c_char_p, ctypes.c_size_t)
1192 MediaReadCb.__doc__ = '''Callback prototype to read data from a custom bitstream input media.
1193 @param opaque: private pointer as set by the @ref libvlc_media_open_cb callback.
1194 @param buf: start address of the buffer to read data into.
1195 @param len: bytes length of the buffer.
1196 @return: strictly positive number of bytes read, 0 on end-of-stream, or -1 on non-recoverable error @note If no data is immediately available, then the callback should sleep. @warning The application is responsible for avoiding deadlock situations. In particular, the callback should return an error if playback is stopped; if it does not return, then L{libvlc_media_player_stop}() will never return.
1197 '''
1198 MediaSeekCb = ctypes.CFUNCTYPE(ctypes.POINTER(ctypes.c_int), ctypes.c_void_p, ctypes.c_uint64)
1199 MediaSeekCb.__doc__ = '''Callback prototype to seek a custom bitstream input media.
1200 @param opaque: private pointer as set by the @ref libvlc_media_open_cb callback.
1201 @param offset: absolute byte offset to seek to.
1202 @return: 0 on success, -1 on error.
1203 '''
1204 MediaCloseCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p)
1205 MediaCloseCb.__doc__ = '''Callback prototype to close a custom bitstream input media.
1206 @param opaque: private pointer as set by the @ref libvlc_media_open_cb callback.
1207 '''
1208 VideoLockCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.POINTER(ctypes.c_void_p))
919 VideoLockCb.__doc__ = '''Callback prototype to allocate and lock a picture buffer.1209 VideoLockCb.__doc__ = '''Callback prototype to allocate and lock a picture buffer.
920Whenever a new video frame needs to be decoded, the lock callback is1210 Whenever a new video frame needs to be decoded, the lock callback is
921invoked. Depending on the video chroma, one or three pixel planes of1211 invoked. Depending on the video chroma, one or three pixel planes of
922adequate dimensions must be returned via the second parameter. Those1212 adequate dimensions must be returned via the second parameter. Those
923planes must be aligned on 32-bytes boundaries.1213 planes must be aligned on 32-bytes boundaries.
924\param opaque private pointer as passed to L{libvlc_video_set_callbacks}() [IN]1214 @param opaque: private pointer as passed to L{libvlc_video_set_callbacks}() [IN].
925\param planes start address of the pixel planes (LibVLC allocates the array1215 @param planes: start address of the pixel planes (LibVLC allocates the array of void pointers, this callback must initialize the array) [OUT].
926 of void pointers, this callback must initialize the array) [OUT]1216 @return: a private pointer for the display and unlock callbacks to identify the picture buffers.
927\return a private pointer for the display and unlock callbacks to identify
928 the picture buffers
929 ''' 1217 '''
930 VideoUnlockCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p, ListPOINTER(ctypes.c_void_p))1218 VideoUnlockCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p, ctypes.POINTER(ctypes.c_void_p))
931 VideoUnlockCb.__doc__ = '''Callback prototype to unlock a picture buffer.1219 VideoUnlockCb.__doc__ = '''Callback prototype to unlock a picture buffer.
932When the video frame decoding is complete, the unlock callback is invoked.1220 When the video frame decoding is complete, the unlock callback is invoked.
933This callback might not be needed at all. It is only an indication that the1221 This callback might not be needed at all. It is only an indication that the
934application can now read the pixel values if it needs to.1222 application can now read the pixel values if it needs to.
935\warning A picture buffer is unlocked after the picture is decoded,1223 @note: A picture buffer is unlocked after the picture is decoded,
936but before the picture is displayed.1224 but before the picture is displayed.
937\param opaque private pointer as passed to L{libvlc_video_set_callbacks}() [IN]1225 @param opaque: private pointer as passed to L{libvlc_video_set_callbacks}() [IN].
938\param picture private pointer returned from the @ref libvlc_video_lock_cb1226 @param picture: private pointer returned from the @ref libvlc_video_lock_cb callback [IN].
939 callback [IN]1227 @param planes: pixel planes as defined by the @ref libvlc_video_lock_cb callback (this parameter is only for convenience) [IN].
940\param planes pixel planes as defined by the @ref libvlc_video_lock_cb
941 callback (this parameter is only for convenience) [IN]
942 ''' 1228 '''
943 VideoDisplayCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p)1229 VideoDisplayCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p)
944 VideoDisplayCb.__doc__ = '''Callback prototype to display a picture.1230 VideoDisplayCb.__doc__ = '''Callback prototype to display a picture.
945When the video frame needs to be shown, as determined by the media playback1231 When the video frame needs to be shown, as determined by the media playback
946clock, the display callback is invoked.1232 clock, the display callback is invoked.
947\param opaque private pointer as passed to L{libvlc_video_set_callbacks}() [IN]1233 @param opaque: private pointer as passed to L{libvlc_video_set_callbacks}() [IN].
948\param picture private pointer returned from the @ref libvlc_video_lock_cb1234 @param picture: private pointer returned from the @ref libvlc_video_lock_cb callback [IN].
949 callback [IN]
950 ''' 1235 '''
951 VideoFormatCb = ctypes.CFUNCTYPE(ctypes.POINTER(ctypes.c_uint), ListPOINTER(ctypes.c_void_p), ctypes.c_char_p, ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint))1236 VideoFormatCb = ctypes.CFUNCTYPE(ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_void_p), ctypes.c_char_p, ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint))
952 VideoFormatCb.__doc__ = '''Callback prototype to configure picture buffers format.1237 VideoFormatCb.__doc__ = '''Callback prototype to configure picture buffers format.
953This callback gets the format of the video as output by the video decoder1238 This callback gets the format of the video as output by the video decoder
954and the chain of video filters (if any). It can opt to change any parameter1239 and the chain of video filters (if any). It can opt to change any parameter
955as it needs. In that case, LibVLC will attempt to convert the video format1240 as it needs. In that case, LibVLC will attempt to convert the video format
956(rescaling and chroma conversion) but these operations can be CPU intensive.1241 (rescaling and chroma conversion) but these operations can be CPU intensive.
957\param opaque pointer to the private pointer passed to1242 @param opaque: pointer to the private pointer passed to L{libvlc_video_set_callbacks}() [IN/OUT].
958 L{libvlc_video_set_callbacks}() [IN/OUT]1243 @param chroma: pointer to the 4 bytes video format identifier [IN/OUT].
959\param chroma pointer to the 4 bytes video format identifier [IN/OUT]1244 @param width: pointer to the pixel width [IN/OUT].
960\param width pointer to the pixel width [IN/OUT]1245 @param height: pointer to the pixel height [IN/OUT].
961\param height pointer to the pixel height [IN/OUT]1246 @param pitches: table of scanline pitches in bytes for each pixel plane (the table is allocated by LibVLC) [OUT].
962\param pitches table of scanline pitches in bytes for each pixel plane1247 @return: lines table of scanlines count for each plane.
963 (the table is allocated by LibVLC) [OUT]
964\param lines table of scanlines count for each plane [OUT]
965\return the number of picture buffers allocated, 0 indicates failure
966\note
967For each pixels plane, the scanline pitch must be bigger than or equal to
968the number of bytes per pixel multiplied by the pixel width.
969Similarly, the number of scanlines must be bigger than of equal to
970the pixel height.
971Furthermore, we recommend that pitches and lines be multiple of 32
972to not break assumption that might be made by various optimizations
973in the video decoders, video filters and/or video converters.
974 ''' 1248 '''
975 VideoCleanupCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p)1249 VideoCleanupCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p)
976 VideoCleanupCb.__doc__ = '''Callback prototype to configure picture buffers format.1250 VideoCleanupCb.__doc__ = '''Callback prototype to configure picture buffers format.
977\param opaque private pointer as passed to L{libvlc_video_set_callbacks}()1251 @param opaque: private pointer as passed to L{libvlc_video_set_callbacks}() (and possibly modified by @ref libvlc_video_format_cb) [IN].
978 (and possibly modified by @ref libvlc_video_format_cb) [IN]
979 ''' 1252 '''
980 AudioPlayCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p, ctypes.c_uint, ctypes.c_int64)1253 AudioPlayCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p, ctypes.c_uint, ctypes.c_int64)
981 AudioPlayCb.__doc__ = '''Callback prototype for audio playback.1254 AudioPlayCb.__doc__ = '''Callback prototype for audio playback.
982\param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN]1255 The LibVLC media player decodes and post-processes the audio signal
983\param samples pointer to the first audio sample to play back [IN]1256 asynchronously (in an internal thread). Whenever audio samples are ready
984\param count number of audio samples to play back1257 to be queued to the output, this callback is invoked.
985\param pts expected play time stamp (see libvlc_delay())1258 The number of samples provided per invocation may depend on the file format,
1259 the audio coding algorithm, the decoder plug-in, the post-processing
1260 filters and timing. Application must not assume a certain number of samples.
1261 The exact format of audio samples is determined by L{libvlc_audio_set_format}()
1262 or L{libvlc_audio_set_format_callbacks}() as is the channels layout.
1263 Note that the number of samples is per channel. For instance, if the audio
1264 track sampling rate is 48000 Hz, then 1200 samples represent 25 milliseconds
1265 of audio signal - regardless of the number of audio channels.
1266 @param data: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN].
1267 @param samples: pointer to a table of audio samples to play back [IN].
1268 @param count: number of audio samples to play back.
1269 @param pts: expected play time stamp (see libvlc_delay()).
986 ''' 1270 '''
987 AudioPauseCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int64)1271 AudioPauseCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int64)
988 AudioPauseCb.__doc__ = '''Callback prototype for audio pause.1272 AudioPauseCb.__doc__ = '''Callback prototype for audio pause.
989\note The pause callback is never called if the audio is already paused.1273 LibVLC invokes this callback to pause audio playback.
990\param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN]1274 @note: The pause callback is never called if the audio is already paused.
991\param pts time stamp of the pause request (should be elapsed already)1275 @param data: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN].
1276 @param pts: time stamp of the pause request (should be elapsed already).
992 ''' 1277 '''
993 AudioResumeCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int64)1278 AudioResumeCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int64)
994 AudioResumeCb.__doc__ = '''Callback prototype for audio resumption (i.e. restart from pause).1279 AudioResumeCb.__doc__ = '''Callback prototype for audio resumption.
995\note The resume callback is never called if the audio is not paused.1280 LibVLC invokes this callback to resume audio playback after it was
996\param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN]1281 previously paused.
997\param pts time stamp of the resumption request (should be elapsed already)1282 @note: The resume callback is never called if the audio is not paused.
1283 @param data: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN].
1284 @param pts: time stamp of the resumption request (should be elapsed already).
998 ''' 1285 '''
999 AudioFlushCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int64)1286 AudioFlushCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int64)
1000 AudioFlushCb.__doc__ = '''Callback prototype for audio buffer flush1287 AudioFlushCb.__doc__ = '''Callback prototype for audio buffer flush.
1001(i.e. discard all pending buffers and stop playback as soon as possible).1288 LibVLC invokes this callback if it needs to discard all pending buffers and
1002\param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN]1289 stop playback as soon as possible. This typically occurs when the media is
1290 stopped.
1291 @param data: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN].
1003 ''' 1292 '''
1004 AudioDrainCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p)1293 AudioDrainCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p)
1005 AudioDrainCb.__doc__ = '''Callback prototype for audio buffer drain1294 AudioDrainCb.__doc__ = '''Callback prototype for audio buffer drain.
1006(i.e. wait for pending buffers to be played).1295 LibVLC may invoke this callback when the decoded audio track is ending.
1007\param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN]1296 There will be no further decoded samples for the track, but playback should
1297 nevertheless continue until all already pending buffers are rendered.
1298 @param data: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN].
1008 ''' 1299 '''
1009 AudioSetVolumeCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_float, ctypes.c_bool)1300 AudioSetVolumeCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_float, ctypes.c_bool)
1010 AudioSetVolumeCb.__doc__ = '''Callback prototype for audio volume change.1301 AudioSetVolumeCb.__doc__ = '''Callback prototype for audio volume change.
1011\param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN]1302 @param data: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN].
1012\param volume software volume (1. = nominal, 0. = mute)1303 @param volume: software volume (1. = nominal, 0. = mute).
1013\param mute muted flag1304 @param mute: muted flag.
1014 ''' 1305 '''
1015 AudioSetupCb = ctypes.CFUNCTYPE(ctypes.POINTER(ctypes.c_int), ListPOINTER(ctypes.c_void_p), ctypes.c_char_p, ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint))1306 AudioSetupCb = ctypes.CFUNCTYPE(ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_void_p), ctypes.c_char_p, ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint))
1016 AudioSetupCb.__doc__ = '''Callback prototype to setup the audio playback.1307 AudioSetupCb.__doc__ = '''Callback prototype to setup the audio playback.
1017This is called when the media player needs to create a new audio output.1308 This is called when the media player needs to create a new audio output.
1018\param opaque pointer to the data pointer passed to1309 @param opaque: pointer to the data pointer passed to L{libvlc_audio_set_callbacks}() [IN/OUT].
1019 L{libvlc_audio_set_callbacks}() [IN/OUT]1310 @param format: 4 bytes sample format [IN/OUT].
1020\param format 4 bytes sample format [IN/OUT]1311 @param rate: sample rate [IN/OUT].
1021\param rate sample rate [IN/OUT]1312 @param channels: channels count [IN/OUT].
1022\param channels channels count [IN/OUT]1313 @return: 0 on success, anything else to skip audio playback.
1023\return 0 on success, anything else to skip audio playback
1024 ''' 1314 '''
1025 AudioCleanupCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p)1315 AudioCleanupCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p)
1026 AudioCleanupCb.__doc__ = '''Callback prototype for audio playback cleanup.1316 AudioCleanupCb.__doc__ = '''Callback prototype for audio playback cleanup.
1027This is called when the media player no longer needs an audio output.1317 This is called when the media player no longer needs an audio output.
1028\param opaque data pointer as passed to L{libvlc_audio_set_callbacks}() [IN]1318 @param opaque: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN].
1029 ''' 1319 '''
1030cb = CallbackDecorators1320cb = CallbackDecorators
1031 # End of generated enum types #1321 # End of generated enum types #
@@ -1277,21 +1567,54 @@
1277 ]1567 ]
12781568
1279class TitleDescription(_Cstruct):1569class TitleDescription(_Cstruct):
1280 _fields = [1570 _fields_ = [
1281 ('duration', ctypes.c_longlong),1571 ('duration', ctypes.c_longlong),
1282 ('name', ctypes.c_char_p),1572 ('name', ctypes.c_char_p),
1283 ('menu', ctypes.c_bool),1573 ('menu', ctypes.c_bool),
1284 ]1574 ]
12851575
1286class ChapterDescription(_Cstruct):1576class ChapterDescription(_Cstruct):
1287 _fields = [1577 _fields_ = [
1288 ('time_offset', ctypes.c_longlong),1578 ('time_offset', ctypes.c_longlong),
1289 ('duration', ctypes.c_longlong),1579 ('duration', ctypes.c_longlong),
1290 ('name', ctypes.c_char_p),1580 ('name', ctypes.c_char_p),
1291 ]1581 ]
12921582
1293 # End of header.py #1583class VideoViewpoint(_Cstruct):
12941584 _fields_ = [
1585 ('yaw', ctypes.c_float),
1586 ('pitch', ctypes.c_float),
1587 ('roll', ctypes.c_float),
1588 ('field_of_view', ctypes.c_float),
1589 ]
1590
1591class MediaDiscovererDescription(_Cstruct):
1592 _fields_ = [
1593 ('name', ctypes.c_char_p),
1594 ('longname', ctypes.c_char_p),
1595 ('cat', MediaDiscovererCategory),
1596 ]
1597
1598 def __str__(self):
1599 return '%s %s (%d) - %s' % (self.__class__.__name__, self.name, self.cat, self.longname)
1600
1601# This struct depends on the MediaSlaveType enum that is defined only
1602# in > 2.2
1603if 'MediaSlaveType' in locals():
1604 class MediaSlave(_Cstruct):
1605 _fields_ = [
1606 ('psz_uri', ctypes.c_char_p),
1607 ('i_type', MediaSlaveType),
1608 ('i_priority', ctypes.c_uint)
1609 ]
1610
1611class RDDescription(_Cstruct):
1612 _fields_ = [
1613 ('name', ctypes.c_char_p),
1614 ('longname', ctypes.c_char_p)
1615 ]
1616
1617# End of header.py #
1295class EventManager(_Ctype):1618class EventManager(_Ctype):
1296 '''Create an event manager with callback handler.1619 '''Create an event manager with callback handler.
12971620
@@ -1397,14 +1720,22 @@
1397 elif isinstance(i, basestring):1720 elif isinstance(i, basestring):
1398 args = i.strip().split()1721 args = i.strip().split()
1399 elif isinstance(i, _Seqs):1722 elif isinstance(i, _Seqs):
1400 args = i1723 args = list(i)
1401 else:1724 else:
1402 raise VLCException('Instance %r' % (args,))1725 raise VLCException('Instance %r' % (args,))
14031726 else:
1404 if not args and plugin_path is not None:1727 args = list(args)
1405 # no parameters passed, for win32 and MacOS,1728
1406 # specify the plugin_path if detected earlier1729 if not args: # no parameters passed
1407 args = ['vlc', '--plugin-path=' + plugin_path]1730 args = ['vlc']
1731 elif args[0] != 'vlc':
1732 args.insert(0, 'vlc')
1733
1734 if plugin_path is not None:
1735 # set plugin_path if detected, win32 and MacOS,
1736 # if the user did not specify it itself.
1737 os.environ.setdefault('VLC_PLUGIN_PATH', plugin_path)
1738
1408 if PYTHON3:1739 if PYTHON3:
1409 args = [ str_to_bytes(a) for a in args ]1740 args = [ str_to_bytes(a) for a in args ]
1410 return libvlc_new(len(args), args)1741 return libvlc_new(len(args), args)
@@ -1547,16 +1878,18 @@
15471878
1548 1879
1549 def log_unset(self):1880 def log_unset(self):
1550 '''Unsets the logging callback for a LibVLC instance. This is rarely needed:1881 '''Unsets the logging callback.
1551 the callback is implicitly unset when the instance is destroyed.1882 This function deregisters the logging callback for a LibVLC instance.
1552 This function will wait for any pending callbacks invocation to complete1883 This is rarely needed as the callback is implicitly unset when the instance
1553 (causing a deadlock if called from within the callback).1884 is destroyed.
1885 @note: This function will wait for any pending callbacks invocation to
1886 complete (causing a deadlock if called from within the callback).
1554 @version: LibVLC 2.1.0 or later.1887 @version: LibVLC 2.1.0 or later.
1555 '''1888 '''
1556 return libvlc_log_unset(self)1889 return libvlc_log_unset(self)
15571890
1558 1891
1559 def log_set(self, data, p_instance):1892 def log_set(self, cb, data):
1560 '''Sets the logging callback for a LibVLC instance.1893 '''Sets the logging callback for a LibVLC instance.
1561 This function is thread-safe: it will wait for any pending callbacks1894 This function is thread-safe: it will wait for any pending callbacks
1562 invocation to complete.1895 invocation to complete.
@@ -1564,7 +1897,7 @@
1564 @param p_instance: libvlc instance.1897 @param p_instance: libvlc instance.
1565 @version: LibVLC 2.1.0 or later.1898 @version: LibVLC 2.1.0 or later.
1566 '''1899 '''
1567 return libvlc_log_set(self, data, p_instance)1900 return libvlc_log_set(self, cb, data)
15681901
1569 1902
1570 def log_set_file(self, stream):1903 def log_set_file(self, stream):
@@ -1575,65 +1908,30 @@
1575 return libvlc_log_set_file(self, stream)1908 return libvlc_log_set_file(self, stream)
15761909
1577 1910
1578 def media_new_location(self, psz_mrl):1911 def media_discoverer_new(self, psz_name):
1579 '''Create a media with a certain given media resource location,1912 '''Create a media discoverer object by name.
1580 for instance a valid URL.1913 After this object is created, you should attach to media_list events in
1581 @note: To refer to a local file with this function,1914 order to be notified of new items discovered.
1582 the file://... URI syntax B{must} be used (see IETF RFC3986).1915 You need to call L{media_discoverer_start}() in order to start the
1583 We recommend using L{media_new_path}() instead when dealing with1916 discovery.
1584 local files.1917 See L{media_discoverer_media_list}
1585 See L{media_release}.1918 See L{media_discoverer_event_manager}
1586 @param psz_mrl: the media location.1919 See L{media_discoverer_start}.
1587 @return: the newly created media or None on error.1920 @param psz_name: service name; use L{media_discoverer_list_get}() to get a list of the discoverer names available in this libVLC instance.
1588 '''
1589 return libvlc_media_new_location(self, str_to_bytes(psz_mrl))
1590
1591
1592 def media_new_path(self, path):
1593 '''Create a media for a certain file path.
1594 See L{media_release}.
1595 @param path: local filesystem path.
1596 @return: the newly created media or None on error.
1597 '''
1598 return libvlc_media_new_path(self, str_to_bytes(path))
1599
1600
1601 def media_new_fd(self, fd):
1602 '''Create a media for an already open file descriptor.
1603 The file descriptor shall be open for reading (or reading and writing).
1604 Regular file descriptors, pipe read descriptors and character device
1605 descriptors (including TTYs) are supported on all platforms.
1606 Block device descriptors are supported where available.
1607 Directory descriptors are supported on systems that provide fdopendir().
1608 Sockets are supported on all platforms where they are file descriptors,
1609 i.e. all except Windows.
1610 @note: This library will B{not} automatically close the file descriptor
1611 under any circumstance. Nevertheless, a file descriptor can usually only be
1612 rendered once in a media player. To render it a second time, the file
1613 descriptor should probably be rewound to the beginning with lseek().
1614 See L{media_release}.
1615 @param fd: open file descriptor.
1616 @return: the newly created media or None on error.
1617 @version: LibVLC 1.1.5 and later.
1618 '''
1619 return libvlc_media_new_fd(self, fd)
1620
1621
1622 def media_new_as_node(self, psz_name):
1623 '''Create a media as an empty node with a given name.
1624 See L{media_release}.
1625 @param psz_name: the name of the node.
1626 @return: the new empty media or None on error.
1627 '''
1628 return libvlc_media_new_as_node(self, str_to_bytes(psz_name))
1629
1630
1631 def media_discoverer_new_from_name(self, psz_name):
1632 '''Discover media service by name.
1633 @param psz_name: service name.
1634 @return: media discover object or None in case of error.1921 @return: media discover object or None in case of error.
1635 '''1922 @version: LibVLC 3.0.0 or later.
1636 return libvlc_media_discoverer_new_from_name(self, str_to_bytes(psz_name))1923 '''
1924 return libvlc_media_discoverer_new(self, str_to_bytes(psz_name))
1925
1926
1927 def media_discoverer_list_get(self, i_cat, ppp_services):
1928 '''Get media discoverer services by category.
1929 @param i_cat: category of services to fetch.
1930 @param ppp_services: address to store an allocated array of media discoverer services (must be freed with L{media_discoverer_list_release}() by the caller) [OUT].
1931 @return: the number of media discoverer services (0 on error).
1932 @version: LibVLC 3.0.0 and later.
1933 '''
1934 return libvlc_media_discoverer_list_get(self, i_cat, ppp_services)
16371935
1638 1936
1639 def media_library_new(self):1937 def media_library_new(self):
@@ -1643,30 +1941,6 @@
1643 return libvlc_media_library_new(self)1941 return libvlc_media_library_new(self)
16441942
1645 1943
1646 def audio_output_list_get(self):
1647 '''Gets the list of available audio output modules.
1648 @return: list of available audio outputs. It must be freed it with In case of error, None is returned.
1649 '''
1650 return libvlc_audio_output_list_get(self)
1651
1652
1653 def audio_output_device_list_get(self, aout):
1654 '''Gets a list of audio output devices for a given audio output module,
1655 See L{audio_output_device_set}().
1656 @note: Not all audio outputs support this. In particular, an empty (None)
1657 list of devices does B{not} imply that the specified audio output does
1658 not work.
1659 @note: The list might not be exhaustive.
1660 @warning: Some audio output devices in the list might not actually work in
1661 some circumstances. By default, it is recommended to not specify any
1662 explicit audio device.
1663 @param psz_aout: audio output name (as returned by L{audio_output_list_get}()).
1664 @return: A None-terminated linked list of potential audio output devices. It must be freed it with L{audio_output_device_list_release}().
1665 @version: LibVLC 2.1.0 or later.
1666 '''
1667 return libvlc_audio_output_device_list_get(self, str_to_bytes(aout))
1668
1669
1670 def vlm_release(self):1944 def vlm_release(self):
1671 '''Release the vlm instance related to the given L{Instance}.1945 '''Release the vlm instance related to the given L{Instance}.
1672 '''1946 '''
@@ -1899,9 +2173,234 @@
1899 '''2173 '''
1900 return libvlc_vlm_get_event_manager(self)2174 return libvlc_vlm_get_event_manager(self)
19012175
2176
2177 def media_new_location(self, psz_mrl):
2178 '''Create a media with a certain given media resource location,
2179 for instance a valid URL.
2180 @note: To refer to a local file with this function,
2181 the file://... URI syntax B{must} be used (see IETF RFC3986).
2182 We recommend using L{media_new_path}() instead when dealing with
2183 local files.
2184 See L{media_release}.
2185 @param psz_mrl: the media location.
2186 @return: the newly created media or None on error.
2187 '''
2188 return libvlc_media_new_location(self, str_to_bytes(psz_mrl))
2189
2190
2191 def media_new_path(self, path):
2192 '''Create a media for a certain file path.
2193 See L{media_release}.
2194 @param path: local filesystem path.
2195 @return: the newly created media or None on error.
2196 '''
2197 return libvlc_media_new_path(self, str_to_bytes(path))
2198
2199
2200 def media_new_fd(self, fd):
2201 '''Create a media for an already open file descriptor.
2202 The file descriptor shall be open for reading (or reading and writing).
2203 Regular file descriptors, pipe read descriptors and character device
2204 descriptors (including TTYs) are supported on all platforms.
2205 Block device descriptors are supported where available.
2206 Directory descriptors are supported on systems that provide fdopendir().
2207 Sockets are supported on all platforms where they are file descriptors,
2208 i.e. all except Windows.
2209 @note: This library will B{not} automatically close the file descriptor
2210 under any circumstance. Nevertheless, a file descriptor can usually only be
2211 rendered once in a media player. To render it a second time, the file
2212 descriptor should probably be rewound to the beginning with lseek().
2213 See L{media_release}.
2214 @param fd: open file descriptor.
2215 @return: the newly created media or None on error.
2216 @version: LibVLC 1.1.5 and later.
2217 '''
2218 return libvlc_media_new_fd(self, fd)
2219
2220
2221 def media_new_callbacks(self, open_cb, read_cb, seek_cb, close_cb, opaque):
2222 '''Create a media with custom callbacks to read the data from.
2223 @param open_cb: callback to open the custom bitstream input media.
2224 @param read_cb: callback to read data (must not be None).
2225 @param seek_cb: callback to seek, or None if seeking is not supported.
2226 @param close_cb: callback to close the media, or None if unnecessary.
2227 @param opaque: data pointer for the open callback.
2228 @return: the newly created media or None on error @note If open_cb is None, the opaque pointer will be passed to read_cb, seek_cb and close_cb, and the stream size will be treated as unknown. @note The callbacks may be called asynchronously (from another thread). A single stream instance need not be reentrant. However the open_cb needs to be reentrant if the media is used by multiple player instances. @warning The callbacks may be used until all or any player instances that were supplied the media item are stopped. See L{media_release}.
2229 @version: LibVLC 3.0.0 and later.
2230 '''
2231 return libvlc_media_new_callbacks(self, open_cb, read_cb, seek_cb, close_cb, opaque)
2232
2233
2234 def media_new_as_node(self, psz_name):
2235 '''Create a media as an empty node with a given name.
2236 See L{media_release}.
2237 @param psz_name: the name of the node.
2238 @return: the new empty media or None on error.
2239 '''
2240 return libvlc_media_new_as_node(self, str_to_bytes(psz_name))
2241
2242
2243 def renderer_discoverer_new(self, psz_name):
2244 '''Create a renderer discoverer object by name
2245 After this object is created, you should attach to events in order to be
2246 notified of the discoverer events.
2247 You need to call L{renderer_discoverer_start}() in order to start the
2248 discovery.
2249 See L{renderer_discoverer_event_manager}()
2250 See L{renderer_discoverer_start}().
2251 @param psz_name: service name; use L{renderer_discoverer_list_get}() to get a list of the discoverer names available in this libVLC instance.
2252 @return: media discover object or None in case of error.
2253 @version: LibVLC 3.0.0 or later.
2254 '''
2255 return libvlc_renderer_discoverer_new(self, str_to_bytes(psz_name))
2256
2257
2258 def renderer_discoverer_list_get(self, ppp_services):
2259 '''Get media discoverer services
2260 See libvlc_renderer_list_release().
2261 @param ppp_services: address to store an allocated array of renderer discoverer services (must be freed with libvlc_renderer_list_release() by the caller) [OUT].
2262 @return: the number of media discoverer services (0 on error).
2263 @version: LibVLC 3.0.0 and later.
2264 '''
2265 return libvlc_renderer_discoverer_list_get(self, ppp_services)
2266
2267
2268 def audio_output_device_count(self, psz_audio_output):
2269 '''Backward compatibility stub. Do not use in new code.
2270 \deprecated Use L{audio_output_device_list_get}() instead.
2271 @return: always 0.
2272 '''
2273 return libvlc_audio_output_device_count(self, str_to_bytes(psz_audio_output))
2274
2275
2276 def audio_output_device_longname(self, psz_output, i_device):
2277 '''Backward compatibility stub. Do not use in new code.
2278 \deprecated Use L{audio_output_device_list_get}() instead.
2279 @return: always None.
2280 '''
2281 return libvlc_audio_output_device_longname(self, str_to_bytes(psz_output), i_device)
2282
2283
2284 def audio_output_device_id(self, psz_audio_output, i_device):
2285 '''Backward compatibility stub. Do not use in new code.
2286 \deprecated Use L{audio_output_device_list_get}() instead.
2287 @return: always None.
2288 '''
2289 return libvlc_audio_output_device_id(self, str_to_bytes(psz_audio_output), i_device)
2290
2291
2292 def media_discoverer_new_from_name(self, psz_name):
2293 '''\deprecated Use L{media_discoverer_new}() and L{media_discoverer_start}().
2294 '''
2295 return libvlc_media_discoverer_new_from_name(self, str_to_bytes(psz_name))
2296
2297
2298 def wait(self):
2299 '''Waits until an interface causes the instance to exit.
2300 You should start at least one interface first, using L{add_intf}().
2301 '''
2302 return libvlc_wait(self)
2303
2304
2305 def get_log_verbosity(self):
2306 '''Always returns minus one.
2307 This function is only provided for backward compatibility.
2308 @return: always -1.
2309 '''
2310 return libvlc_get_log_verbosity(self)
2311
2312
2313 def set_log_verbosity(self, level):
2314 '''This function does nothing.
2315 It is only provided for backward compatibility.
2316 @param level: ignored.
2317 '''
2318 return libvlc_set_log_verbosity(self, level)
2319
2320
2321 def log_open(self):
2322 '''This function does nothing useful.
2323 It is only provided for backward compatibility.
2324 @return: an unique pointer or None on error.
2325 '''
2326 return libvlc_log_open(self)
2327
2328
2329 def playlist_play(self, i_id, i_options, ppsz_options):
2330 '''Start playing (if there is any item in the playlist).
2331 Additionnal playlist item options can be specified for addition to the
2332 item before it is played.
2333 @param i_id: the item to play. If this is a negative number, the next item will be selected. Otherwise, the item with the given ID will be played.
2334 @param i_options: the number of options to add to the item.
2335 @param ppsz_options: the options to add to the item.
2336 '''
2337 return libvlc_playlist_play(self, i_id, i_options, ppsz_options)
2338
2339
2340 def audio_output_list_get(self):
2341 '''Gets the list of available audio output modules.
2342 @return: list of available audio outputs. It must be freed with In case of error, None is returned.
2343 '''
2344 return libvlc_audio_output_list_get(self)
2345
2346
2347 def audio_output_device_list_get(self, aout):
2348 '''Gets a list of audio output devices for a given audio output module,
2349 See L{audio_output_device_set}().
2350 @note: Not all audio outputs support this. In particular, an empty (None)
2351 list of devices does B{not} imply that the specified audio output does
2352 not work.
2353 @note: The list might not be exhaustive.
2354 @warning: Some audio output devices in the list might not actually work in
2355 some circumstances. By default, it is recommended to not specify any
2356 explicit audio device.
2357 @param aout: audio output name (as returned by L{audio_output_list_get}()).
2358 @return: A None-terminated linked list of potential audio output devices. It must be freed with L{audio_output_device_list_release}().
2359 @version: LibVLC 2.1.0 or later.
2360 '''
2361 return libvlc_audio_output_device_list_get(self, str_to_bytes(aout))
2362
2363class LogIterator(_Ctype):
2364 '''Create a new VLC log iterator.
2365
2366 '''
2367
2368 def __new__(cls, ptr=_internal_guard):
2369 '''(INTERNAL) ctypes wrapper constructor.
2370 '''
2371 return _Constructor(cls, ptr)
2372
2373 def __iter__(self):
2374 return self
2375
2376 def next(self):
2377 if self.has_next():
2378 b = LogMessage()
2379 i = libvlc_log_iterator_next(self, b)
2380 return i.contents
2381 raise StopIteration
2382
2383 def __next__(self):
2384 return self.next()
2385
2386
2387
2388 def free(self):
2389 '''Frees memory allocated by L{log_get_iterator}().
2390 '''
2391 return libvlc_log_iterator_free(self)
2392
2393
2394 def has_next(self):
2395 '''Always returns zero.
2396 This function is only provided for backward compatibility.
2397 @return: always zero.
2398 '''
2399 return libvlc_log_iterator_has_next(self)
2400
1902class Media(_Ctype):2401class Media(_Ctype):
1903 '''Create a new Media instance.2402 '''Create a new Media instance.
1904 2403
1905 Usage: Media(MRL, *options)2404 Usage: Media(MRL, *options)
19062405
1907 See vlc.Instance.media_new documentation for details.2406 See vlc.Instance.media_new documentation for details.
@@ -1945,8 +2444,15 @@
1945 """2444 """
1946 mediaTrack_pp = ctypes.POINTER(MediaTrack)()2445 mediaTrack_pp = ctypes.POINTER(MediaTrack)()
1947 n = libvlc_media_tracks_get(self, ctypes.byref(mediaTrack_pp))2446 n = libvlc_media_tracks_get(self, ctypes.byref(mediaTrack_pp))
1948 info = ctypes.cast(ctypes.mediaTrack_pp, ctypes.POINTER(ctypes.POINTER(MediaTrack) * n))2447 info = ctypes.cast(mediaTrack_pp, ctypes.POINTER(ctypes.POINTER(MediaTrack) * n))
1949 return info2448 try:
2449 contents = info.contents
2450 except ValueError:
2451 # Media not parsed, no info.
2452 return None
2453 tracks = ( contents[i].contents for i in range(len(contents)) )
2454 # libvlc_media_tracks_release(mediaTrack_pp, n)
2455 return tracks
19502456
19512457
1952 2458
@@ -1984,7 +2490,7 @@
19842490
1985 2491
1986 def retain(self):2492 def retain(self):
1987 '''Retain a reference to a media descriptor object (libvlc_media_t). Use2493 '''Retain a reference to a media descriptor object (L{Media}). Use
1988 L{release}() to decrement the reference count of a2494 L{release}() to decrement the reference count of a
1989 media descriptor object.2495 media descriptor object.
1990 '''2496 '''
@@ -2017,11 +2523,8 @@
2017 def get_meta(self, e_meta):2523 def get_meta(self, e_meta):
2018 '''Read the meta of the media.2524 '''Read the meta of the media.
2019 If the media has not yet been parsed this will return None.2525 If the media has not yet been parsed this will return None.
2020 This methods automatically calls L{parse_async}(), so after calling
2021 it you may receive a libvlc_MediaMetaChanged event. If you prefer a synchronous
2022 version ensure that you call L{parse}() before get_meta().
2023 See L{parse}2526 See L{parse}
2024 See L{parse_async}2527 See L{parse_with_options}
2025 See libvlc_MediaMetaChanged.2528 See libvlc_MediaMetaChanged.
2026 @param e_meta: the meta to read.2529 @param e_meta: the meta to read.
2027 @return: the media's meta.2530 @return: the media's meta.
@@ -2046,12 +2549,10 @@
20462549
2047 2550
2048 def get_state(self):2551 def get_state(self):
2049 '''Get current state of media descriptor object. Possible media states2552 '''Get current state of media descriptor object. Possible media states are
2050 are defined in libvlc_structures.c ( libvlc_NothingSpecial=0,2553 libvlc_NothingSpecial=0, libvlc_Opening, libvlc_Playing, libvlc_Paused,
2051 libvlc_Opening, libvlc_Buffering, libvlc_Playing, libvlc_Paused,2554 libvlc_Stopped, libvlc_Ended, libvlc_Error.
2052 libvlc_Stopped, libvlc_Ended,2555 See L{State}.
2053 libvlc_Error).
2054 See libvlc_state_t.
2055 @return: state of media descriptor object.2556 @return: state of media descriptor object.
2056 '''2557 '''
2057 return libvlc_media_get_state(self)2558 return libvlc_media_get_state(self)
@@ -2089,55 +2590,162 @@
2089 return libvlc_media_get_duration(self)2590 return libvlc_media_get_duration(self)
20902591
2091 2592
2593 def parse_with_options(self, parse_flag, timeout):
2594 '''Parse the media asynchronously with options.
2595 This fetches (local or network) art, meta data and/or tracks information.
2596 This method is the extended version of L{parse_with_options}().
2597 To track when this is over you can listen to libvlc_MediaParsedChanged
2598 event. However if this functions returns an error, you will not receive any
2599 events.
2600 It uses a flag to specify parse options (see L{MediaParseFlag}). All
2601 these flags can be combined. By default, media is parsed if it's a local
2602 file.
2603 @note: Parsing can be aborted with L{parse_stop}().
2604 See libvlc_MediaParsedChanged
2605 See L{get_meta}
2606 See L{tracks_get}
2607 See L{get_parsed_status}
2608 See L{MediaParseFlag}.
2609 @param parse_flag: parse options:
2610 @param timeout: maximum time allowed to preparse the media. If -1, the default "preparse-timeout" option will be used as a timeout. If 0, it will wait indefinitely. If > 0, the timeout will be used (in milliseconds).
2611 @return: -1 in case of error, 0 otherwise.
2612 @version: LibVLC 3.0.0 or later.
2613 '''
2614 return libvlc_media_parse_with_options(self, parse_flag, timeout)
2615
2616
2617 def parse_stop(self):
2618 '''Stop the parsing of the media
2619 When the media parsing is stopped, the libvlc_MediaParsedChanged event will
2620 be sent with the libvlc_media_parsed_status_timeout status.
2621 See L{parse_with_options}.
2622 @version: LibVLC 3.0.0 or later.
2623 '''
2624 return libvlc_media_parse_stop(self)
2625
2626
2627 def get_parsed_status(self):
2628 '''Get Parsed status for media descriptor object.
2629 See libvlc_MediaParsedChanged
2630 See L{MediaParsedStatus}.
2631 @return: a value of the L{MediaParsedStatus} enum.
2632 @version: LibVLC 3.0.0 or later.
2633 '''
2634 return libvlc_media_get_parsed_status(self)
2635
2636
2637 def set_user_data(self, p_new_user_data):
2638 '''Sets media descriptor's user_data. user_data is specialized data
2639 accessed by the host application, VLC.framework uses it as a pointer to
2640 an native object that references a L{Media} pointer.
2641 @param p_new_user_data: pointer to user data.
2642 '''
2643 return libvlc_media_set_user_data(self, p_new_user_data)
2644
2645
2646 def get_user_data(self):
2647 '''Get media descriptor's user_data. user_data is specialized data
2648 accessed by the host application, VLC.framework uses it as a pointer to
2649 an native object that references a L{Media} pointer.
2650 '''
2651 return libvlc_media_get_user_data(self)
2652
2653
2654 def get_type(self):
2655 '''Get the media type of the media descriptor object.
2656 @return: media type.
2657 @version: LibVLC 3.0.0 and later. See L{MediaType}.
2658 '''
2659 return libvlc_media_get_type(self)
2660
2661
2662 def slaves_add(self, i_type, i_priority, psz_uri):
2663 '''Add a slave to the current media.
2664 A slave is an external input source that may contains an additional subtitle
2665 track (like a .srt) or an additional audio track (like a .ac3).
2666 @note: This function must be called before the media is parsed (via
2667 L{parse_with_options}()) or before the media is played (via
2668 L{player_play}()).
2669 @param i_type: subtitle or audio.
2670 @param i_priority: from 0 (low priority) to 4 (high priority).
2671 @param psz_uri: Uri of the slave (should contain a valid scheme).
2672 @return: 0 on success, -1 on error.
2673 @version: LibVLC 3.0.0 and later.
2674 '''
2675 return libvlc_media_slaves_add(self, i_type, i_priority, str_to_bytes(psz_uri))
2676
2677
2678 def slaves_clear(self):
2679 '''Clear all slaves previously added by L{slaves_add}() or
2680 internally.
2681 @version: LibVLC 3.0.0 and later.
2682 '''
2683 return libvlc_media_slaves_clear(self)
2684
2685
2686 def slaves_get(self, ppp_slaves):
2687 '''Get a media descriptor's slave list
2688 The list will contain slaves parsed by VLC or previously added by
2689 L{slaves_add}(). The typical use case of this function is to save
2690 a list of slave in a database for a later use.
2691 @param ppp_slaves: address to store an allocated array of slaves (must be freed with L{slaves_release}()) [OUT].
2692 @return: the number of slaves (zero on error).
2693 @version: LibVLC 3.0.0 and later. See L{slaves_add}.
2694 '''
2695 return libvlc_media_slaves_get(self, ppp_slaves)
2696
2697
2092 def parse(self):2698 def parse(self):
2093 '''Parse a media.2699 '''Parse a media.
2094 This fetches (local) meta data and tracks information.2700 This fetches (local) art, meta data and tracks information.
2095 The method is synchronous.2701 The method is synchronous.
2096 See L{parse_async}2702 \deprecated This function could block indefinitely.
2703 Use L{parse_with_options}() instead
2704 See L{parse_with_options}
2097 See L{get_meta}2705 See L{get_meta}
2098 See libvlc_media_get_tracks_info.2706 See L{get_tracks_info}.
2099 '''2707 '''
2100 return libvlc_media_parse(self)2708 return libvlc_media_parse(self)
21012709
2102 2710
2103 def parse_async(self):2711 def parse_async(self):
2104 '''Parse a media.2712 '''Parse a media.
2105 This fetches (local) meta data and tracks information.2713 This fetches (local) art, meta data and tracks information.
2106 The method is the asynchronous of L{parse}().2714 The method is the asynchronous of L{parse}().
2107 To track when this is over you can listen to libvlc_MediaParsedChanged2715 To track when this is over you can listen to libvlc_MediaParsedChanged
2108 event. However if the media was already parsed you will not receive this2716 event. However if the media was already parsed you will not receive this
2109 event.2717 event.
2718 \deprecated You can't be sure to receive the libvlc_MediaParsedChanged
2719 event (you can wait indefinitely for this event).
2720 Use L{parse_with_options}() instead
2110 See L{parse}2721 See L{parse}
2111 See libvlc_MediaParsedChanged2722 See libvlc_MediaParsedChanged
2112 See L{get_meta}2723 See L{get_meta}
2113 See libvlc_media_get_tracks_info.2724 See L{get_tracks_info}.
2114 '''2725 '''
2115 return libvlc_media_parse_async(self)2726 return libvlc_media_parse_async(self)
21162727
2117 2728
2118 def is_parsed(self):2729 def is_parsed(self):
2119 '''Get Parsed status for media descriptor object.2730 '''Return true is the media descriptor object is parsed
2731 \deprecated This can return true in case of failure.
2732 Use L{get_parsed_status}() instead
2120 See libvlc_MediaParsedChanged.2733 See libvlc_MediaParsedChanged.
2121 @return: true if media object has been parsed otherwise it returns false \libvlc_return_bool.2734 @return: true if media object has been parsed otherwise it returns false \libvlc_return_bool.
2122 '''2735 '''
2123 return libvlc_media_is_parsed(self)2736 return libvlc_media_is_parsed(self)
21242737
2125 2738
2126 def set_user_data(self, p_new_user_data):2739 def get_tracks_info(self):
2127 '''Sets media descriptor's user_data. user_data is specialized data2740 '''Get media descriptor's elementary streams description
2128 accessed by the host application, VLC.framework uses it as a pointer to2741 Note, you need to call L{parse}() or play the media at least once
2129 an native object that references a L{Media} pointer.2742 before calling this function.
2130 @param p_new_user_data: pointer to user data.2743 Not doing this will result in an empty array.
2131 '''2744 \deprecated Use L{tracks_get}() instead.
2132 return libvlc_media_set_user_data(self, p_new_user_data)2745 @param tracks: address to store an allocated array of Elementary Streams descriptions (must be freed by the caller) [OUT].
21332746 @return: the number of Elementary Streams.
2134 2747 '''
2135 def get_user_data(self):2748 return libvlc_media_get_tracks_info(self)
2136 '''Get media descriptor's user_data. user_data is specialized data
2137 accessed by the host application, VLC.framework uses it as a pointer to
2138 an native object that references a L{Media} pointer.
2139 '''
2140 return libvlc_media_get_user_data(self)
21412749
2142 2750
2143 def player_new_from_media(self):2751 def player_new_from_media(self):
@@ -2155,6 +2763,25 @@
2155 '''2763 '''
2156 return _Constructor(cls, ptr)2764 return _Constructor(cls, ptr)
2157 2765
2766 def start(self):
2767 '''Start media discovery.
2768 To stop it, call L{stop}() or
2769 L{list_release}() directly.
2770 See L{stop}.
2771 @return: -1 in case of error, 0 otherwise.
2772 @version: LibVLC 3.0.0 or later.
2773 '''
2774 return libvlc_media_discoverer_start(self)
2775
2776
2777 def stop(self):
2778 '''Stop media discovery.
2779 See L{start}.
2780 @version: LibVLC 3.0.0 or later.
2781 '''
2782 return libvlc_media_discoverer_stop(self)
2783
2784
2158 def release(self):2785 def release(self):
2159 '''Release media discover object. If the reference count reaches 0, then2786 '''Release media discover object. If the reference count reaches 0, then
2160 the object will be released.2787 the object will be released.
@@ -2162,26 +2789,12 @@
2162 return libvlc_media_discoverer_release(self)2789 return libvlc_media_discoverer_release(self)
21632790
2164 2791
2165 def localized_name(self):
2166 '''Get media service discover object its localized name.
2167 @return: localized name.
2168 '''
2169 return libvlc_media_discoverer_localized_name(self)
2170
2171
2172 def media_list(self):2792 def media_list(self):
2173 '''Get media service discover media list.2793 '''Get media service discover media list.
2174 @return: list of media items.2794 @return: list of media items.
2175 '''2795 '''
2176 return libvlc_media_discoverer_media_list(self)2796 return libvlc_media_discoverer_media_list(self)
21772797
2178 @memoize_parameterless
2179 def event_manager(self):
2180 '''Get event manager from media service discover object.
2181 @return: event manager object.
2182 '''
2183 return libvlc_media_discoverer_event_manager(self)
2184
2185 2798
2186 def is_running(self):2799 def is_running(self):
2187 '''Query if media service discover object is running.2800 '''Query if media service discover object is running.
@@ -2189,6 +2802,24 @@
2189 '''2802 '''
2190 return libvlc_media_discoverer_is_running(self)2803 return libvlc_media_discoverer_is_running(self)
21912804
2805
2806 def localized_name(self):
2807 '''Get media service discover object its localized name.
2808 \deprecated Useless, use L{list_get}() to get the
2809 longname of the service discovery.
2810 @return: localized name or None if the media_discoverer is not started.
2811 '''
2812 return libvlc_media_discoverer_localized_name(self)
2813
2814 @memoize_parameterless
2815 def event_manager(self):
2816 '''Get event manager from media service discover object.
2817 \deprecated Useless, media_discoverer events are only triggered when calling
2818 L{start}() and L{stop}().
2819 @return: event manager object.
2820 '''
2821 return libvlc_media_discoverer_event_manager(self)
2822
2192class MediaLibrary(_Ctype):2823class MediaLibrary(_Ctype):
2193 '''N/A2824 '''N/A
2194 '''2825 '''
@@ -2229,7 +2860,7 @@
22292860
2230class MediaList(_Ctype):2861class MediaList(_Ctype):
2231 '''Create a new MediaList instance.2862 '''Create a new MediaList instance.
2232 2863
2233 Usage: MediaList(list_of_MRLs)2864 Usage: MediaList(list_of_MRLs)
22342865
2235 See vlc.Instance.media_list_new documentation for details.2866 See vlc.Instance.media_list_new documentation for details.
@@ -2249,10 +2880,10 @@
22492880
2250 def get_instance(self):2881 def get_instance(self):
2251 return getattr(self, '_instance', None)2882 return getattr(self, '_instance', None)
2252 2883
2253 def add_media(self, mrl):2884 def add_media(self, mrl):
2254 """Add media instance to media list.2885 """Add media instance to media list.
2255 2886
2256 The L{lock} should be held upon entering this function.2887 The L{lock} should be held upon entering this function.
2257 @param mrl: a media instance or a MRL.2888 @param mrl: a media instance or a MRL.
2258 @return: 0 on success, -1 if the media list is read-only.2889 @return: 0 on success, -1 if the media list is read-only.
@@ -2435,6 +3066,13 @@
2435 return libvlc_media_list_player_set_media_player(self, p_mi)3066 return libvlc_media_list_player_set_media_player(self, p_mi)
24363067
2437 3068
3069 def get_media_player(self):
3070 '''Get media player of the media_list_player instance.
3071 @return: media player instance @note the caller is responsible for releasing the returned instance.
3072 '''
3073 return libvlc_media_list_player_get_media_player(self)
3074
3075
2438 def set_media_list(self, p_mlist):3076 def set_media_list(self, p_mlist):
2439 '''Set the media list associated with the player.3077 '''Set the media list associated with the player.
2440 @param p_mlist: list of media.3078 @param p_mlist: list of media.
@@ -2454,6 +3092,14 @@
2454 return libvlc_media_list_player_pause(self)3092 return libvlc_media_list_player_pause(self)
24553093
2456 3094
3095 def set_pause(self, do_pause):
3096 '''Pause or resume media list.
3097 @param do_pause: play/resume if zero, pause if non-zero.
3098 @version: LibVLC 3.0.0 or later.
3099 '''
3100 return libvlc_media_list_player_set_pause(self, do_pause)
3101
3102
2457 def is_playing(self):3103 def is_playing(self):
2458 '''Is media list playing?3104 '''Is media list playing?
2459 @return: true for playing and false for not playing \libvlc_return_bool.3105 @return: true for playing and false for not playing \libvlc_return_bool.
@@ -2463,7 +3109,7 @@
2463 3109
2464 def get_state(self):3110 def get_state(self):
2465 '''Get current libvlc_state of media list player.3111 '''Get current libvlc_state of media list player.
2466 @return: libvlc_state_t for media list player.3112 @return: L{State} for media list player.
2467 '''3113 '''
2468 return libvlc_media_list_player_get_state(self)3114 return libvlc_media_list_player_get_state(self)
24693115
@@ -2529,7 +3175,7 @@
2529 def __new__(cls, *args):3175 def __new__(cls, *args):
2530 if len(args) == 1 and isinstance(args[0], _Ints):3176 if len(args) == 1 and isinstance(args[0], _Ints):
2531 return _Constructor(cls, args[0])3177 return _Constructor(cls, args[0])
2532 3178
2533 if args and isinstance(args[0], Instance):3179 if args and isinstance(args[0], Instance):
2534 instance = args[0]3180 instance = args[0]
2535 args = args[1:]3181 args = args[1:]
@@ -2595,19 +3241,31 @@
2595 '''3241 '''
2596 titleDescription_pp = ctypes.POINTER(TitleDescription)()3242 titleDescription_pp = ctypes.POINTER(TitleDescription)()
2597 n = libvlc_media_player_get_full_title_descriptions(self, ctypes.byref(titleDescription_pp))3243 n = libvlc_media_player_get_full_title_descriptions(self, ctypes.byref(titleDescription_pp))
2598 info = ctypes.cast(ctypes.titleDescription_pp, ctypes.POINTER(ctypes.POINTER(TitleDescription) * n))3244 info = ctypes.cast(titleDescription_pp, ctypes.POINTER(ctypes.POINTER(TitleDescription) * n))
2599 return info3245 try:
3246 contents = info.contents
3247 except ValueError:
3248 # Media not parsed, no info.
3249 return None
3250 descr = ( contents[i].contents for i in range(len(contents)) )
3251 return descr
26003252
2601 def get_full_chapter_descriptions(self, i_chapters_of_title):3253 def get_full_chapter_descriptions(self, i_chapters_of_title):
2602 '''Get the full description of available chapters.3254 '''Get the full description of available chapters.
2603 @param index: of the title to query for chapters.3255 @param i_chapters_of_title: index of the title to query for chapters (uses current title if set to -1).
2604 @return: the chapter list3256 @return: the chapters list
2605 @version: LibVLC 3.0.0 and later.3257 @version: LibVLC 3.0.0 and later.
2606 '''3258 '''
2607 chapterDescription_pp = ctypes.POINTER(ChapterDescription)()3259 chapterDescription_pp = ctypes.POINTER(ChapterDescription)()
2608 n = libvlc_media_player_get_full_chapter_descriptions(self, ctypes.byref(chapterDescription_pp))3260 n = libvlc_media_player_get_full_chapter_descriptions(self, ctypes.byref(chapterDescription_pp))
2609 info = ctypes.cast(ctypes.chapterDescription_pp, ctypes.POINTER(ctypes.POINTER(ChapterDescription) * n))3261 info = ctypes.cast(chapterDescription_pp, ctypes.POINTER(ctypes.POINTER(ChapterDescription) * n))
2610 return info3262 try:
3263 contents = info.contents
3264 except ValueError:
3265 # Media not parsed, no info.
3266 return None
3267 descr = ( contents[i].contents for i in range(len(contents)) )
3268 return descr
26113269
2612 def video_get_size(self, num=0):3270 def video_get_size(self, num=0):
2613 """Get the video size in pixels as 2-tuple (width, height).3271 """Get the video size in pixels as 2-tuple (width, height).
@@ -2626,13 +3284,13 @@
2626 Specify where the media player should render its video3284 Specify where the media player should render its video
2627 output. If LibVLC was built without Win32/Win64 API output3285 output. If LibVLC was built without Win32/Win64 API output
2628 support, then this has no effects.3286 support, then this has no effects.
2629 3287
2630 @param drawable: windows handle of the drawable.3288 @param drawable: windows handle of the drawable.
2631 """3289 """
2632 if not isinstance(drawable, ctypes.c_void_p):3290 if not isinstance(drawable, ctypes.c_void_p):
2633 drawable = ctypes.c_void_p(int(drawable))3291 drawable = ctypes.c_void_p(int(drawable))
2634 libvlc_media_player_set_hwnd(self, drawable)3292 libvlc_media_player_set_hwnd(self, drawable)
2635 3293
2636 def video_get_width(self, num=0):3294 def video_get_width(self, num=0):
2637 """Get the width of a video in pixels.3295 """Get the width of a video in pixels.
26383296
@@ -2673,6 +3331,45 @@
26733331
26743332
2675 3333
3334 def get_fps(self):
3335 '''Get movie fps rate
3336 This function is provided for backward compatibility. It cannot deal with
3337 multiple video tracks. In LibVLC versions prior to 3.0, it would also fail
3338 if the file format did not convey the frame rate explicitly.
3339 \deprecated Consider using L{media_tracks_get}() instead.
3340 @return: frames per second (fps) for this playing movie, or 0 if unspecified.
3341 '''
3342 return libvlc_media_player_get_fps(self)
3343
3344
3345 def set_agl(self, drawable):
3346 '''\deprecated Use L{set_nsobject}() instead.
3347 '''
3348 return libvlc_media_player_set_agl(self, drawable)
3349
3350
3351 def get_agl(self):
3352 '''\deprecated Use L{get_nsobject}() instead.
3353 '''
3354 return libvlc_media_player_get_agl(self)
3355
3356
3357 def video_set_subtitle_file(self, psz_subtitle):
3358 '''Set new video subtitle file.
3359 \deprecated Use L{add_slave}() instead.
3360 @param psz_subtitle: new video subtitle file.
3361 @return: the success status (boolean).
3362 '''
3363 return libvlc_video_set_subtitle_file(self, str_to_bytes(psz_subtitle))
3364
3365
3366 def toggle_teletext(self):
3367 '''Toggle teletext transparent status on video output.
3368 \deprecated use L{video_set_teletext}() instead.
3369 '''
3370 return libvlc_toggle_teletext(self)
3371
3372
2676 def release(self):3373 def release(self):
2677 '''Release a media_player after use3374 '''Release a media_player after use
2678 Decrement the reference count of a media player object. If the3375 Decrement the reference count of a media player object. If the
@@ -2746,11 +3443,43 @@
2746 return libvlc_media_player_stop(self)3443 return libvlc_media_player_stop(self)
27473444
2748 3445
3446 def set_renderer(self, p_item):
3447 '''Set a renderer to the media player
3448 @note: must be called before the first call of L{play}() to
3449 take effect.
3450 See L{renderer_discoverer_new}.
3451 @param p_item: an item discovered by L{renderer_discoverer_start}().
3452 @return: 0 on success, -1 on error.
3453 @version: LibVLC 3.0.0 or later.
3454 '''
3455 return libvlc_media_player_set_renderer(self, p_item)
3456
3457
2749 def video_set_callbacks(self, lock, unlock, display, opaque):3458 def video_set_callbacks(self, lock, unlock, display, opaque):
2750 '''Set callbacks and private data to render decoded video to a custom area3459 '''Set callbacks and private data to render decoded video to a custom area
2751 in memory.3460 in memory.
2752 Use L{video_set_format}() or L{video_set_format_callbacks}()3461 Use L{video_set_format}() or L{video_set_format_callbacks}()
2753 to configure the decoded format.3462 to configure the decoded format.
3463 @warning: Rendering video into custom memory buffers is considerably less
3464 efficient than rendering in a custom window as normal.
3465 For optimal perfomances, VLC media player renders into a custom window, and
3466 does not use this function and associated callbacks. It is B{highly
3467 recommended} that other LibVLC-based application do likewise.
3468 To embed video in a window, use libvlc_media_player_set_xid() or equivalent
3469 depending on the operating system.
3470 If window embedding does not fit the application use case, then a custom
3471 LibVLC video output display plugin is required to maintain optimal video
3472 rendering performances.
3473 The following limitations affect performance:
3474 - Hardware video decoding acceleration will either be disabled completely,
3475 or require (relatively slow) copy from video/DSP memory to main memory.
3476 - Sub-pictures (subtitles, on-screen display, etc.) must be blent into the
3477 main picture by the CPU instead of the GPU.
3478 - Depending on the video format, pixel format conversion, picture scaling,
3479 cropping and/or picture re-orientation, must be performed by the CPU
3480 instead of the GPU.
3481 - Memory copying is required between LibVLC reference picture buffers and
3482 application buffers (between lock and unlock callbacks).
2754 @param lock: callback to lock video memory (must not be None).3483 @param lock: callback to lock video memory (must not be None).
2755 @param unlock: callback to unlock video memory (or None if not needed).3484 @param unlock: callback to unlock video memory (or None if not needed).
2756 @param display: callback to display video (or None if not needed).3485 @param display: callback to display video (or None if not needed).
@@ -2789,16 +3518,16 @@
2789 Use the vout called "macosx".3518 Use the vout called "macosx".
2790 The drawable is an NSObject that follow the VLCOpenGLVideoViewEmbedding3519 The drawable is an NSObject that follow the VLCOpenGLVideoViewEmbedding
2791 protocol:3520 protocol:
2792 @begincode3521 @code.m
2793 \@protocol VLCOpenGLVideoViewEmbedding <NSObject>3522 \@protocol VLCOpenGLVideoViewEmbedding <NSObject>
2794 - (void)addVoutSubview:(NSView *)view;3523 - (void)addVoutSubview:(NSView *)view;
2795 - (void)removeVoutSubview:(NSView *)view;3524 - (void)removeVoutSubview:(NSView *)view;
2796 \@end3525 \@end
2797 @endcode3526 @endcode
2798 Or it can be an NSView object.3527 Or it can be an NSView object.
2799 If you want to use it along with Qt4 see the QMacCocoaViewContainer. Then3528 If you want to use it along with Qt see the QMacCocoaViewContainer. Then
2800 the following code should work:3529 the following code should work:
2801 @begincode3530 @code.mm
2802 3531
2803 NSView *video = [[NSView alloc] init];3532 NSView *video = [[NSView alloc] init];
2804 QMacCocoaViewContainer *container = new QMacCocoaViewContainer(video, parent);3533 QMacCocoaViewContainer *container = new QMacCocoaViewContainer(video, parent);
@@ -2819,30 +3548,25 @@
2819 return libvlc_media_player_get_nsobject(self)3548 return libvlc_media_player_get_nsobject(self)
28203549
2821 3550
2822 def set_agl(self, drawable):
2823 '''Set the agl handler where the media player should render its video output.
2824 @param drawable: the agl handler.
2825 '''
2826 return libvlc_media_player_set_agl(self, drawable)
2827
2828
2829 def get_agl(self):
2830 '''Get the agl handler previously set with L{set_agl}().
2831 @return: the agl handler or 0 if none where set.
2832 '''
2833 return libvlc_media_player_get_agl(self)
2834
2835
2836 def set_xwindow(self, drawable):3551 def set_xwindow(self, drawable):
2837 '''Set an X Window System drawable where the media player should render its3552 '''Set an X Window System drawable where the media player should render its
2838 video output. If LibVLC was built without X11 output support, then this has3553 video output. The call takes effect when the playback starts. If it is
2839 no effects.3554 already started, it might need to be stopped before changes apply.
2840 The specified identifier must correspond to an existing Input/Output class3555 If LibVLC was built without X11 output support, then this function has no
2841 X11 window. Pixmaps are B{not} supported. The caller shall ensure that3556 effects.
2842 the X11 server is the same as the one the VLC instance has been configured3557 By default, LibVLC will capture input events on the video rendering area.
2843 with. This function must be called before video playback is started;3558 Use L{video_set_mouse_input}() and L{video_set_key_input}() to
2844 otherwise it will only take effect after playback stop and restart.3559 disable that and deliver events to the parent window / to the application
2845 @param drawable: the ID of the X window.3560 instead. By design, the X11 protocol delivers input events to only one
3561 recipient.
3562 @warning
3563 The application must call the XInitThreads() function from Xlib before
3564 L{new}(), and before any call to XOpenDisplay() directly or via any
3565 other library. Failure to call XInitThreads() will seriously impede LibVLC
3566 performance. Calling XOpenDisplay() before XInitThreads() will eventually
3567 crash the process. That is a limitation of Xlib.
3568 @param drawable: X11 window ID @note The specified identifier must correspond to an existing Input/Output class X11 window. Pixmaps are B{not} currently supported. The default X11 server is assumed, i.e. that specified in the DISPLAY environment variable. @warning LibVLC can deal with invalid X11 handle errors, however some display drivers (EGL, GLX, VA and/or VDPAU) can unfortunately not. Thus the window handle must remain valid until playback is stopped, otherwise the process may abort or crash.
3569 @bug No more than one window handle per media player instance can be specified. If the media has multiple simultaneously active video tracks, extra tracks will be rendered into external windows beyond the control of the application.
2846 '''3570 '''
2847 return libvlc_media_player_set_xwindow(self, drawable)3571 return libvlc_media_player_set_xwindow(self, drawable)
28483572
@@ -2866,10 +3590,29 @@
2866 return libvlc_media_player_get_hwnd(self)3590 return libvlc_media_player_get_hwnd(self)
28673591
2868 3592
3593 def set_android_context(self, p_awindow_handler):
3594 '''Set the android context.
3595 @param p_awindow_handler: org.videolan.libvlc.AWindow jobject owned by the org.videolan.libvlc.MediaPlayer class from the libvlc-android project.
3596 @version: LibVLC 3.0.0 and later.
3597 '''
3598 return libvlc_media_player_set_android_context(self, p_awindow_handler)
3599
3600
3601 def set_evas_object(self, p_evas_object):
3602 '''Set the EFL Evas Object.
3603 @param p_evas_object: a valid EFL Evas Object (Evas_Object).
3604 @return: -1 if an error was detected, 0 otherwise.
3605 @version: LibVLC 3.0.0 and later.
3606 '''
3607 return libvlc_media_player_set_evas_object(self, p_evas_object)
3608
3609
2869 def audio_set_callbacks(self, play, pause, resume, flush, drain, opaque):3610 def audio_set_callbacks(self, play, pause, resume, flush, drain, opaque):
2870 '''Set callbacks and private data for decoded audio.3611 '''Sets callbacks and private data for decoded audio.
2871 Use L{audio_set_format}() or L{audio_set_format_callbacks}()3612 Use L{audio_set_format}() or L{audio_set_format_callbacks}()
2872 to configure the decoded audio format.3613 to configure the decoded audio format.
3614 @note: The audio callbacks override any other audio output mechanism.
3615 If the callbacks are set, LibVLC will B{not} output audio in any way.
2873 @param play: callback to play audio samples (must not be None).3616 @param play: callback to play audio samples (must not be None).
2874 @param pause: callback to pause playback (or None to ignore).3617 @param pause: callback to pause playback (or None to ignore).
2875 @param resume: callback to resume playback (or None to ignore).3618 @param resume: callback to resume playback (or None to ignore).
@@ -2893,8 +3636,8 @@
28933636
2894 3637
2895 def audio_set_format_callbacks(self, setup, cleanup):3638 def audio_set_format_callbacks(self, setup, cleanup):
2896 '''Set decoded audio format. This only works in combination with3639 '''Sets decoded audio format via callbacks.
2897 L{audio_set_callbacks}().3640 This only works in combination with L{audio_set_callbacks}().
2898 @param setup: callback to select the audio format (cannot be None).3641 @param setup: callback to select the audio format (cannot be None).
2899 @param cleanup: callback to release any allocated resources (or None).3642 @param cleanup: callback to release any allocated resources (or None).
2900 @version: LibVLC 2.0.0 or later.3643 @version: LibVLC 2.0.0 or later.
@@ -2903,7 +3646,7 @@
29033646
2904 3647
2905 def audio_set_format(self, format, rate, channels):3648 def audio_set_format(self, format, rate, channels):
2906 '''Set decoded audio format.3649 '''Sets a fixed decoded audio format.
2907 This only works in combination with L{audio_set_callbacks}(),3650 This only works in combination with L{audio_set_callbacks}(),
2908 and is mutually exclusive with L{audio_set_format_callbacks}().3651 and is mutually exclusive with L{audio_set_format_callbacks}().
2909 @param format: a four-characters string identifying the sample format (e.g. "S16N" or "FL32").3652 @param format: a four-characters string identifying the sample format (e.g. "S16N" or "FL32").
@@ -3040,18 +3783,11 @@
3040 3783
3041 def get_state(self):3784 def get_state(self):
3042 '''Get current movie state.3785 '''Get current movie state.
3043 @return: the current state of the media player (playing, paused, ...) See libvlc_state_t.3786 @return: the current state of the media player (playing, paused, ...) See L{State}.
3044 '''3787 '''
3045 return libvlc_media_player_get_state(self)3788 return libvlc_media_player_get_state(self)
30463789
3047 3790
3048 def get_fps(self):
3049 '''Get movie fps rate.
3050 @return: frames per second (fps) for this playing movie, or 0 if unspecified.
3051 '''
3052 return libvlc_media_player_get_fps(self)
3053
3054
3055 def has_vout(self):3791 def has_vout(self):
3056 '''How many video outputs does this media player have?3792 '''How many video outputs does this media player have?
3057 @return: the number of video outputs.3793 @return: the number of video outputs.
@@ -3104,6 +3840,19 @@
3104 return libvlc_media_player_set_video_title_display(self, position, timeout)3840 return libvlc_media_player_set_video_title_display(self, position, timeout)
31053841
3106 3842
3843 def add_slave(self, i_type, psz_uri, b_select):
3844 '''Add a slave to the current media player.
3845 @note: If the player is playing, the slave will be added directly. This call
3846 will also update the slave list of the attached L{Media}.
3847 @param i_type: subtitle or audio.
3848 @param psz_uri: Uri of the slave (should contain a valid scheme).
3849 @param b_select: True if this slave should be selected when it's loaded.
3850 @return: 0 on success, -1 on error.
3851 @version: LibVLC 3.0.0 and later. See L{media_slaves_add}.
3852 '''
3853 return libvlc_media_player_add_slave(self, i_type, str_to_bytes(psz_uri), b_select)
3854
3855
3107 def toggle_fullscreen(self):3856 def toggle_fullscreen(self):
3108 '''Toggle fullscreen status on non-embedded video outputs.3857 '''Toggle fullscreen status on non-embedded video outputs.
3109 @warning: The same limitations applies to this function3858 @warning: The same limitations applies to this function
@@ -3190,6 +3939,17 @@
3190 return libvlc_video_set_aspect_ratio(self, str_to_bytes(psz_aspect))3939 return libvlc_video_set_aspect_ratio(self, str_to_bytes(psz_aspect))
31913940
3192 3941
3942 def video_update_viewpoint(self, p_viewpoint, b_absolute):
3943 '''Update the video viewpoint information.
3944 @note: It is safe to call this function before the media player is started.
3945 @param p_viewpoint: video viewpoint allocated via L{video_new_viewpoint}().
3946 @param b_absolute: if true replace the old viewpoint with the new one. If false, increase/decrease it.
3947 @return: -1 in case of error, 0 otherwise @note the values are set asynchronously, it will be used by the next frame displayed.
3948 @version: LibVLC 3.0.0 and later.
3949 '''
3950 return libvlc_video_update_viewpoint(self, p_viewpoint, b_absolute)
3951
3952
3193 def video_get_spu(self):3953 def video_get_spu(self):
3194 '''Get current video subtitle.3954 '''Get current video subtitle.
3195 @return: the video subtitle selected, or -1 if none.3955 @return: the video subtitle selected, or -1 if none.
@@ -3212,14 +3972,6 @@
3212 return libvlc_video_set_spu(self, i_spu)3972 return libvlc_video_set_spu(self, i_spu)
32133973
3214 3974
3215 def video_set_subtitle_file(self, psz_subtitle):
3216 '''Set new video subtitle file.
3217 @param psz_subtitle: new video subtitle file.
3218 @return: the success status (boolean).
3219 '''
3220 return libvlc_video_set_subtitle_file(self, str_to_bytes(psz_subtitle))
3221
3222
3223 def video_get_spu_delay(self):3975 def video_get_spu_delay(self):
3224 '''Get the current subtitle delay. Positive values means subtitles are being3976 '''Get the current subtitle delay. Positive values means subtitles are being
3225 displayed later, negative values earlier.3977 displayed later, negative values earlier.
@@ -3256,7 +4008,9 @@
32564008
3257 4009
3258 def video_get_teletext(self):4010 def video_get_teletext(self):
3259 '''Get current teletext page requested.4011 '''Get current teletext page requested or 0 if it's disabled.
4012 Teletext is disabled by default, call L{video_set_teletext}() to enable
4013 it.
3260 @return: the current teletext page requested.4014 @return: the current teletext page requested.
3261 '''4015 '''
3262 return libvlc_video_get_teletext(self)4016 return libvlc_video_get_teletext(self)
@@ -3264,17 +4018,12 @@
3264 4018
3265 def video_set_teletext(self, i_page):4019 def video_set_teletext(self, i_page):
3266 '''Set new teletext page to retrieve.4020 '''Set new teletext page to retrieve.
3267 @param i_page: teletex page number requested.4021 This function can also be used to send a teletext key.
4022 @param i_page: teletex page number requested. This value can be 0 to disable teletext, a number in the range ]0;1000[ to show the requested page, or a \ref L{TeletextKey}. 100 is the default teletext page.
3268 '''4023 '''
3269 return libvlc_video_set_teletext(self, i_page)4024 return libvlc_video_set_teletext(self, i_page)
32704025
3271 4026
3272 def toggle_teletext(self):
3273 '''Toggle teletext transparent status on video output.
3274 '''
3275 return libvlc_toggle_teletext(self)
3276
3277
3278 def video_get_track_count(self):4027 def video_get_track_count(self):
3279 '''Get number of available video tracks.4028 '''Get number of available video tracks.
3280 @return: the number of available video tracks (int).4029 @return: the number of available video tracks (int).
@@ -3302,7 +4051,7 @@
3302 If i_width AND i_height is 0, original size is used.4051 If i_width AND i_height is 0, original size is used.
3303 If i_width XOR i_height is 0, original aspect-ratio is preserved.4052 If i_width XOR i_height is 0, original aspect-ratio is preserved.
3304 @param num: number of video output (typically 0 for the first/only one).4053 @param num: number of video output (typically 0 for the first/only one).
3305 @param psz_filepath: the path where to save the screenshot to.4054 @param psz_filepath: the path of a file or a folder to save the screenshot into.
3306 @param i_width: the snapshot's width.4055 @param i_width: the snapshot's width.
3307 @param i_height: the snapshot's height.4056 @param i_height: the snapshot's height.
3308 @return: 0 on success, -1 if the video was not found.4057 @return: 0 on success, -1 if the video was not found.
@@ -3351,7 +4100,7 @@
3351 4100
3352 def video_get_logo_int(self, option):4101 def video_get_logo_int(self, option):
3353 '''Get integer logo option.4102 '''Get integer logo option.
3354 @param option: logo option to get, values of libvlc_video_logo_option_t.4103 @param option: logo option to get, values of L{VideoLogoOption}.
3355 '''4104 '''
3356 return libvlc_video_get_logo_int(self, option)4105 return libvlc_video_get_logo_int(self, option)
33574106
@@ -3361,7 +4110,7 @@
3361 are ignored.4110 are ignored.
3362 Passing libvlc_logo_enable as option value has the side effect of4111 Passing libvlc_logo_enable as option value has the side effect of
3363 starting (arg !0) or stopping (arg 0) the logo filter.4112 starting (arg !0) or stopping (arg 0) the logo filter.
3364 @param option: logo option to set, values of libvlc_video_logo_option_t.4113 @param option: logo option to set, values of L{VideoLogoOption}.
3365 @param value: logo option value.4114 @param value: logo option value.
3366 '''4115 '''
3367 return libvlc_video_set_logo_int(self, option, value)4116 return libvlc_video_set_logo_int(self, option, value)
@@ -3370,7 +4119,7 @@
3370 def video_set_logo_string(self, option, psz_value):4119 def video_set_logo_string(self, option, psz_value):
3371 '''Set logo option as string. Options that take a different type value4120 '''Set logo option as string. Options that take a different type value
3372 are ignored.4121 are ignored.
3373 @param option: logo option to set, values of libvlc_video_logo_option_t.4122 @param option: logo option to set, values of L{VideoLogoOption}.
3374 @param psz_value: logo option value.4123 @param psz_value: logo option value.
3375 '''4124 '''
3376 return libvlc_video_set_logo_string(self, option, str_to_bytes(psz_value))4125 return libvlc_video_set_logo_string(self, option, str_to_bytes(psz_value))
@@ -3378,7 +4127,7 @@
3378 4127
3379 def video_get_adjust_int(self, option):4128 def video_get_adjust_int(self, option):
3380 '''Get integer adjust option.4129 '''Get integer adjust option.
3381 @param option: adjust option to get, values of libvlc_video_adjust_option_t.4130 @param option: adjust option to get, values of L{VideoAdjustOption}.
3382 @version: LibVLC 1.1.1 and later.4131 @version: LibVLC 1.1.1 and later.
3383 '''4132 '''
3384 return libvlc_video_get_adjust_int(self, option)4133 return libvlc_video_get_adjust_int(self, option)
@@ -3389,7 +4138,7 @@
3389 are ignored.4138 are ignored.
3390 Passing libvlc_adjust_enable as option value has the side effect of4139 Passing libvlc_adjust_enable as option value has the side effect of
3391 starting (arg !0) or stopping (arg 0) the adjust filter.4140 starting (arg !0) or stopping (arg 0) the adjust filter.
3392 @param option: adust option to set, values of libvlc_video_adjust_option_t.4141 @param option: adust option to set, values of L{VideoAdjustOption}.
3393 @param value: adjust option value.4142 @param value: adjust option value.
3394 @version: LibVLC 1.1.1 and later.4143 @version: LibVLC 1.1.1 and later.
3395 '''4144 '''
@@ -3398,7 +4147,7 @@
3398 4147
3399 def video_get_adjust_float(self, option):4148 def video_get_adjust_float(self, option):
3400 '''Get float adjust option.4149 '''Get float adjust option.
3401 @param option: adjust option to get, values of libvlc_video_adjust_option_t.4150 @param option: adjust option to get, values of L{VideoAdjustOption}.
3402 @version: LibVLC 1.1.1 and later.4151 @version: LibVLC 1.1.1 and later.
3403 '''4152 '''
3404 return libvlc_video_get_adjust_float(self, option)4153 return libvlc_video_get_adjust_float(self, option)
@@ -3407,7 +4156,7 @@
3407 def video_set_adjust_float(self, option, value):4156 def video_set_adjust_float(self, option, value):
3408 '''Set adjust option as float. Options that take a different type value4157 '''Set adjust option as float. Options that take a different type value
3409 are ignored.4158 are ignored.
3410 @param option: adust option to set, values of libvlc_video_adjust_option_t.4159 @param option: adust option to set, values of L{VideoAdjustOption}.
3411 @param value: adjust option value.4160 @param value: adjust option value.
3412 @version: LibVLC 1.1.1 and later.4161 @version: LibVLC 1.1.1 and later.
3413 '''4162 '''
@@ -3419,7 +4168,7 @@
3419 @note: Any change will take be effect only after playback is stopped and4168 @note: Any change will take be effect only after playback is stopped and
3420 restarted. Audio output cannot be changed while playing.4169 restarted. Audio output cannot be changed while playing.
3421 @param psz_name: name of audio output, use psz_name of See L{AudioOutput}.4170 @param psz_name: name of audio output, use psz_name of See L{AudioOutput}.
3422 @return: 0 if function succeded, -1 on error.4171 @return: 0 if function succeeded, -1 on error.
3423 '''4172 '''
3424 return libvlc_audio_output_set(self, str_to_bytes(psz_name))4173 return libvlc_audio_output_set(self, str_to_bytes(psz_name))
34254174
@@ -3433,7 +4182,7 @@
3433 @warning: Some audio output devices in the list might not actually work in4182 @warning: Some audio output devices in the list might not actually work in
3434 some circumstances. By default, it is recommended to not specify any4183 some circumstances. By default, it is recommended to not specify any
3435 explicit audio device.4184 explicit audio device.
3436 @return: A None-terminated linked list of potential audio output devices. It must be freed it with L{audio_output_device_list_release}().4185 @return: A None-terminated linked list of potential audio output devices. It must be freed with L{audio_output_device_list_release}().
3437 @version: LibVLC 2.2.0 or later.4186 @version: LibVLC 2.2.0 or later.
3438 '''4187 '''
3439 return libvlc_audio_output_device_enum(self)4188 return libvlc_audio_output_device_enum(self)
@@ -3467,6 +4216,24 @@
3467 return libvlc_audio_output_device_set(self, str_to_bytes(module), str_to_bytes(device_id))4216 return libvlc_audio_output_device_set(self, str_to_bytes(module), str_to_bytes(device_id))
34684217
3469 4218
4219 def audio_output_device_get(self):
4220 '''Get the current audio output device identifier.
4221 This complements L{audio_output_device_set}().
4222 @warning: The initial value for the current audio output device identifier
4223 may not be set or may be some unknown value. A LibVLC application should
4224 compare this value against the known device identifiers (e.g. those that
4225 were previously retrieved by a call to L{audio_output_device_enum} or
4226 L{audio_output_device_list_get}) to find the current audio output device.
4227 It is possible that the selected audio output device changes (an external
4228 change) without a call to L{audio_output_device_set}. That may make this
4229 method unsuitable to use if a LibVLC application is attempting to track
4230 dynamic audio device changes as they happen.
4231 @return: the current audio output device identifier None if no device is selected or in case of error (the result must be released with free() or L{free}()).
4232 @version: LibVLC 3.0.0 or later.
4233 '''
4234 return libvlc_audio_output_device_get(self)
4235
4236
3470 def audio_toggle_mute(self):4237 def audio_toggle_mute(self):
3471 '''Toggle mute status.4238 '''Toggle mute status.
3472 '''4239 '''
@@ -3526,14 +4293,14 @@
3526 4293
3527 def audio_get_channel(self):4294 def audio_get_channel(self):
3528 '''Get current audio channel.4295 '''Get current audio channel.
3529 @return: the audio channel See libvlc_audio_output_channel_t.4296 @return: the audio channel See L{AudioOutputChannel}.
3530 '''4297 '''
3531 return libvlc_audio_get_channel(self)4298 return libvlc_audio_get_channel(self)
35324299
3533 4300
3534 def audio_set_channel(self, channel):4301 def audio_set_channel(self, channel):
3535 '''Set current audio channel.4302 '''Set current audio channel.
3536 @param channel: the audio channel, See libvlc_audio_output_channel_t.4303 @param channel: the audio channel, See L{AudioOutputChannel}.
3537 @return: 0 on success, -1 on error.4304 @return: 0 on success, -1 on error.
3538 '''4305 '''
3539 return libvlc_audio_set_channel(self, channel)4306 return libvlc_audio_set_channel(self, channel)
@@ -3578,21 +4345,25 @@
3578 '''4345 '''
3579 return libvlc_media_player_set_equalizer(self, p_equalizer)4346 return libvlc_media_player_set_equalizer(self, p_equalizer)
35804347
4348
4349 def get_role(self):
4350 '''Gets the media role.
4351 @return: the media player role (\ref libvlc_media_player_role_t).
4352 @version: LibVLC 3.0.0 and later.
4353 '''
4354 return libvlc_media_player_get_role(self)
4355
4356
4357 def set_role(self, role):
4358 '''Sets the media role.
4359 @param role: the media player role (\ref libvlc_media_player_role_t).
4360 @return: 0 on success, -1 on error.
4361 '''
4362 return libvlc_media_player_set_role(self, role)
4363
35814364
3582 # LibVLC __version__ functions #4365 # LibVLC __version__ functions #
35834366
3584def libvlc_errmsg():
3585 '''A human-readable error message for the last LibVLC error in the calling
3586 thread. The resulting string is valid until another error occurs (at least
3587 until the next LibVLC call).
3588 @warning
3589 This will be None if there was no error.
3590 '''
3591 f = _Cfunctions.get('libvlc_errmsg', None) or \
3592 _Cfunction('libvlc_errmsg', (), None,
3593 ctypes.c_char_p)
3594 return f()
3595
3596def libvlc_clearerr():4367def libvlc_clearerr():
3597 '''Clears the LibVLC error status for the current thread. This is optional.4368 '''Clears the LibVLC error status for the current thread. This is optional.
3598 By default, the error status is automatically overridden when a new error4369 By default, the error status is automatically overridden when a new error
@@ -3619,6 +4390,34 @@
3619 '''Create and initialize a libvlc instance.4390 '''Create and initialize a libvlc instance.
3620 This functions accept a list of "command line" arguments similar to the4391 This functions accept a list of "command line" arguments similar to the
3621 main(). These arguments affect the LibVLC instance default configuration.4392 main(). These arguments affect the LibVLC instance default configuration.
4393 @note
4394 LibVLC may create threads. Therefore, any thread-unsafe process
4395 initialization must be performed before calling L{libvlc_new}(). In particular
4396 and where applicable:
4397 - setlocale() and textdomain(),
4398 - setenv(), unsetenv() and putenv(),
4399 - with the X11 display system, XInitThreads()
4400 (see also L{libvlc_media_player_set_xwindow}()) and
4401 - on Microsoft Windows, SetErrorMode().
4402 - sigprocmask() shall never be invoked; pthread_sigmask() can be used.
4403 On POSIX systems, the SIGCHLD signal B{must not} be ignored, i.e. the
4404 signal handler must set to SIG_DFL or a function pointer, not SIG_IGN.
4405 Also while LibVLC is active, the wait() function shall not be called, and
4406 any call to waitpid() shall use a strictly positive value for the first
4407 parameter (i.e. the PID). Failure to follow those rules may lead to a
4408 deadlock or a busy loop.
4409 Also on POSIX systems, it is recommended that the SIGPIPE signal be blocked,
4410 even if it is not, in principles, necessary, e.g.:
4411 @code
4412 @endcode
4413 On Microsoft Windows Vista/2008, the process error mode
4414 SEM_FAILCRITICALERRORS flag B{must} be set before using LibVLC.
4415 On later versions, that is optional and unnecessary.
4416 Also on Microsoft Windows (Vista and any later version), setting the default
4417 DLL directories to SYSTEM32 exclusively is strongly recommended for
4418 security reasons:
4419 @code
4420 @endcode.
3622 @param argc: the number of arguments (should be 0).4421 @param argc: the number of arguments (should be 0).
3623 @param argv: list of arguments (should be None).4422 @param argv: list of arguments (should be None).
3624 @return: the libvlc instance or None in case of error.4423 @return: the libvlc instance or None in case of error.
@@ -3763,8 +4562,11 @@
3763 return f(event_type)4562 return f(event_type)
37644563
3765def libvlc_log_get_context(ctx):4564def libvlc_log_get_context(ctx):
3766 '''Gets debugging information about a log message: the name of the VLC module4565 '''Gets log message debug infos.
3767 emitting the message and the message location within the source code.4566 This function retrieves self-debug information about a log message:
4567 - the name of the VLC module emitting the message,
4568 - the name of the source code module (i.e. file) and
4569 - the line number within the source code module.
3768 The returned module name and file name will be None if unknown.4570 The returned module name and file name will be None if unknown.
3769 The returned line number will similarly be zero if unknown.4571 The returned line number will similarly be zero if unknown.
3770 @param ctx: message context (as passed to the @ref libvlc_log_cb callback).4572 @param ctx: message context (as passed to the @ref libvlc_log_cb callback).
@@ -3777,10 +4579,12 @@
3777 return f(ctx)4579 return f(ctx)
37784580
3779def libvlc_log_get_object(ctx, id):4581def libvlc_log_get_object(ctx, id):
3780 '''Gets VLC object information about a log message: the type name of the VLC4582 '''Gets log message info.
3781 object emitting the message, the object header if any and a temporaly-unique4583 This function retrieves meta-information about a log message:
3782 object identifier. This information is mainly meant for B{manual}4584 - the type name of the VLC object emitting the message,
3783 troubleshooting.4585 - the object header if any, and
4586 - a temporaly-unique object identifier.
4587 This information is mainly meant for B{manual} troubleshooting.
3784 The returned type name may be "generic" if unknown, but it cannot be None.4588 The returned type name may be "generic" if unknown, but it cannot be None.
3785 The returned header will be None if unset; in current versions, the header4589 The returned header will be None if unset; in current versions, the header
3786 is used to distinguish for VLM inputs.4590 is used to distinguish for VLM inputs.
@@ -3796,10 +4600,12 @@
3796 return f(ctx, id)4600 return f(ctx, id)
37974601
3798def libvlc_log_unset(p_instance):4602def libvlc_log_unset(p_instance):
3799 '''Unsets the logging callback for a LibVLC instance. This is rarely needed:4603 '''Unsets the logging callback.
3800 the callback is implicitly unset when the instance is destroyed.4604 This function deregisters the logging callback for a LibVLC instance.
3801 This function will wait for any pending callbacks invocation to complete4605 This is rarely needed as the callback is implicitly unset when the instance
3802 (causing a deadlock if called from within the callback).4606 is destroyed.
4607 @note: This function will wait for any pending callbacks invocation to
4608 complete (causing a deadlock if called from within the callback).
3803 @param p_instance: libvlc instance.4609 @param p_instance: libvlc instance.
3804 @version: LibVLC 2.1.0 or later.4610 @version: LibVLC 2.1.0 or later.
3805 '''4611 '''
@@ -3808,7 +4614,7 @@
3808 None, Instance)4614 None, Instance)
3809 return f(p_instance)4615 return f(p_instance)
38104616
3811def libvlc_log_set(cb, data, p_instance):4617def libvlc_log_set(p_instance, cb, data):
3812 '''Sets the logging callback for a LibVLC instance.4618 '''Sets the logging callback for a LibVLC instance.
3813 This function is thread-safe: it will wait for any pending callbacks4619 This function is thread-safe: it will wait for any pending callbacks
3814 invocation to complete.4620 invocation to complete.
@@ -3820,7 +4626,7 @@
3820 f = _Cfunctions.get('libvlc_log_set', None) or \4626 f = _Cfunctions.get('libvlc_log_set', None) or \
3821 _Cfunction('libvlc_log_set', ((1,), (1,), (1,),), None,4627 _Cfunction('libvlc_log_set', ((1,), (1,), (1,),), None,
3822 None, Instance, LogCb, ctypes.c_void_p)4628 None, Instance, LogCb, ctypes.c_void_p)
3823 return f(cb, data, p_instance)4629 return f(p_instance, cb, data)
38244630
3825def libvlc_log_set_file(p_instance, stream):4631def libvlc_log_set_file(p_instance, stream):
3826 '''Sets up logging to a file.4632 '''Sets up logging to a file.
@@ -3875,6 +4681,522 @@
3875 ctypes.c_int64)4681 ctypes.c_int64)
3876 return f()4682 return f()
38774683
4684def libvlc_media_discoverer_new(p_inst, psz_name):
4685 '''Create a media discoverer object by name.
4686 After this object is created, you should attach to media_list events in
4687 order to be notified of new items discovered.
4688 You need to call L{libvlc_media_discoverer_start}() in order to start the
4689 discovery.
4690 See L{libvlc_media_discoverer_media_list}
4691 See L{libvlc_media_discoverer_event_manager}
4692 See L{libvlc_media_discoverer_start}.
4693 @param p_inst: libvlc instance.
4694 @param psz_name: service name; use L{libvlc_media_discoverer_list_get}() to get a list of the discoverer names available in this libVLC instance.
4695 @return: media discover object or None in case of error.
4696 @version: LibVLC 3.0.0 or later.
4697 '''
4698 f = _Cfunctions.get('libvlc_media_discoverer_new', None) or \
4699 _Cfunction('libvlc_media_discoverer_new', ((1,), (1,),), class_result(MediaDiscoverer),
4700 ctypes.c_void_p, Instance, ctypes.c_char_p)
4701 return f(p_inst, psz_name)
4702
4703def libvlc_media_discoverer_start(p_mdis):
4704 '''Start media discovery.
4705 To stop it, call L{libvlc_media_discoverer_stop}() or
4706 L{libvlc_media_discoverer_list_release}() directly.
4707 See L{libvlc_media_discoverer_stop}.
4708 @param p_mdis: media discover object.
4709 @return: -1 in case of error, 0 otherwise.
4710 @version: LibVLC 3.0.0 or later.
4711 '''
4712 f = _Cfunctions.get('libvlc_media_discoverer_start', None) or \
4713 _Cfunction('libvlc_media_discoverer_start', ((1,),), None,
4714 ctypes.c_int, MediaDiscoverer)
4715 return f(p_mdis)
4716
4717def libvlc_media_discoverer_stop(p_mdis):
4718 '''Stop media discovery.
4719 See L{libvlc_media_discoverer_start}.
4720 @param p_mdis: media discover object.
4721 @version: LibVLC 3.0.0 or later.
4722 '''
4723 f = _Cfunctions.get('libvlc_media_discoverer_stop', None) or \
4724 _Cfunction('libvlc_media_discoverer_stop', ((1,),), None,
4725 None, MediaDiscoverer)
4726 return f(p_mdis)
4727
4728def libvlc_media_discoverer_release(p_mdis):
4729 '''Release media discover object. If the reference count reaches 0, then
4730 the object will be released.
4731 @param p_mdis: media service discover object.
4732 '''
4733 f = _Cfunctions.get('libvlc_media_discoverer_release', None) or \
4734 _Cfunction('libvlc_media_discoverer_release', ((1,),), None,
4735 None, MediaDiscoverer)
4736 return f(p_mdis)
4737
4738def libvlc_media_discoverer_media_list(p_mdis):
4739 '''Get media service discover media list.
4740 @param p_mdis: media service discover object.
4741 @return: list of media items.
4742 '''
4743 f = _Cfunctions.get('libvlc_media_discoverer_media_list', None) or \
4744 _Cfunction('libvlc_media_discoverer_media_list', ((1,),), class_result(MediaList),
4745 ctypes.c_void_p, MediaDiscoverer)
4746 return f(p_mdis)
4747
4748def libvlc_media_discoverer_is_running(p_mdis):
4749 '''Query if media service discover object is running.
4750 @param p_mdis: media service discover object.
4751 @return: true if running, false if not \libvlc_return_bool.
4752 '''
4753 f = _Cfunctions.get('libvlc_media_discoverer_is_running', None) or \
4754 _Cfunction('libvlc_media_discoverer_is_running', ((1,),), None,
4755 ctypes.c_int, MediaDiscoverer)
4756 return f(p_mdis)
4757
4758def libvlc_media_discoverer_list_get(p_inst, i_cat, ppp_services):
4759 '''Get media discoverer services by category.
4760 @param p_inst: libvlc instance.
4761 @param i_cat: category of services to fetch.
4762 @param ppp_services: address to store an allocated array of media discoverer services (must be freed with L{libvlc_media_discoverer_list_release}() by the caller) [OUT].
4763 @return: the number of media discoverer services (0 on error).
4764 @version: LibVLC 3.0.0 and later.
4765 '''
4766 f = _Cfunctions.get('libvlc_media_discoverer_list_get', None) or \
4767 _Cfunction('libvlc_media_discoverer_list_get', ((1,), (1,), (1,),), None,
4768 ctypes.c_size_t, Instance, MediaDiscovererCategory, ctypes.POINTER(ctypes.POINTER(MediaDiscovererDescription)))
4769 return f(p_inst, i_cat, ppp_services)
4770
4771def libvlc_media_discoverer_list_release(pp_services, i_count):
4772 '''Release an array of media discoverer services.
4773 @param pp_services: array to release.
4774 @param i_count: number of elements in the array.
4775 @version: LibVLC 3.0.0 and later. See L{libvlc_media_discoverer_list_get}().
4776 '''
4777 f = _Cfunctions.get('libvlc_media_discoverer_list_release', None) or \
4778 _Cfunction('libvlc_media_discoverer_list_release', ((1,), (1,),), None,
4779 None, ctypes.POINTER(MediaDiscovererDescription), ctypes.c_size_t)
4780 return f(pp_services, i_count)
4781
4782def libvlc_dialog_set_context(p_id, p_context):
4783 '''Associate an opaque pointer with the dialog id.
4784 @version: LibVLC 3.0.0 and later.
4785 '''
4786 f = _Cfunctions.get('libvlc_dialog_set_context', None) or \
4787 _Cfunction('libvlc_dialog_set_context', ((1,), (1,),), None,
4788 None, ctypes.c_void_p, ctypes.c_void_p)
4789 return f(p_id, p_context)
4790
4791def libvlc_dialog_get_context(p_id):
4792 '''Return the opaque pointer associated with the dialog id.
4793 @version: LibVLC 3.0.0 and later.
4794 '''
4795 f = _Cfunctions.get('libvlc_dialog_get_context', None) or \
4796 _Cfunction('libvlc_dialog_get_context', ((1,),), None,
4797 ctypes.c_void_p, ctypes.c_void_p)
4798 return f(p_id)
4799
4800def libvlc_dialog_post_login(p_id, psz_username, psz_password, b_store):
4801 '''Post a login answer
4802 After this call, p_id won't be valid anymore
4803 See libvlc_dialog_cbs.pf_display_login.
4804 @param p_id: id of the dialog.
4805 @param psz_username: valid and non empty string.
4806 @param psz_password: valid string (can be empty).
4807 @param b_store: if true, store the credentials.
4808 @return: 0 on success, or -1 on error.
4809 @version: LibVLC 3.0.0 and later.
4810 '''
4811 f = _Cfunctions.get('libvlc_dialog_post_login', None) or \
4812 _Cfunction('libvlc_dialog_post_login', ((1,), (1,), (1,), (1,),), None,
4813 ctypes.c_int, ctypes.c_void_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_bool)
4814 return f(p_id, psz_username, psz_password, b_store)
4815
4816def libvlc_dialog_post_action(p_id, i_action):
4817 '''Post a question answer
4818 After this call, p_id won't be valid anymore
4819 See libvlc_dialog_cbs.pf_display_question.
4820 @param p_id: id of the dialog.
4821 @param i_action: 1 for action1, 2 for action2.
4822 @return: 0 on success, or -1 on error.
4823 @version: LibVLC 3.0.0 and later.
4824 '''
4825 f = _Cfunctions.get('libvlc_dialog_post_action', None) or \
4826 _Cfunction('libvlc_dialog_post_action', ((1,), (1,),), None,
4827 ctypes.c_int, ctypes.c_void_p, ctypes.c_int)
4828 return f(p_id, i_action)
4829
4830def libvlc_dialog_dismiss(p_id):
4831 '''Dismiss a dialog
4832 After this call, p_id won't be valid anymore
4833 See libvlc_dialog_cbs.pf_cancel.
4834 @param p_id: id of the dialog.
4835 @return: 0 on success, or -1 on error.
4836 @version: LibVLC 3.0.0 and later.
4837 '''
4838 f = _Cfunctions.get('libvlc_dialog_dismiss', None) or \
4839 _Cfunction('libvlc_dialog_dismiss', ((1,),), None,
4840 ctypes.c_int, ctypes.c_void_p)
4841 return f(p_id)
4842
4843def libvlc_media_library_new(p_instance):
4844 '''Create an new Media Library object.
4845 @param p_instance: the libvlc instance.
4846 @return: a new object or None on error.
4847 '''
4848 f = _Cfunctions.get('libvlc_media_library_new', None) or \
4849 _Cfunction('libvlc_media_library_new', ((1,),), class_result(MediaLibrary),
4850 ctypes.c_void_p, Instance)
4851 return f(p_instance)
4852
4853def libvlc_media_library_release(p_mlib):
4854 '''Release media library object. This functions decrements the
4855 reference count of the media library object. If it reaches 0,
4856 then the object will be released.
4857 @param p_mlib: media library object.
4858 '''
4859 f = _Cfunctions.get('libvlc_media_library_release', None) or \
4860 _Cfunction('libvlc_media_library_release', ((1,),), None,
4861 None, MediaLibrary)
4862 return f(p_mlib)
4863
4864def libvlc_media_library_retain(p_mlib):
4865 '''Retain a reference to a media library object. This function will
4866 increment the reference counting for this object. Use
4867 L{libvlc_media_library_release}() to decrement the reference count.
4868 @param p_mlib: media library object.
4869 '''
4870 f = _Cfunctions.get('libvlc_media_library_retain', None) or \
4871 _Cfunction('libvlc_media_library_retain', ((1,),), None,
4872 None, MediaLibrary)
4873 return f(p_mlib)
4874
4875def libvlc_media_library_load(p_mlib):
4876 '''Load media library.
4877 @param p_mlib: media library object.
4878 @return: 0 on success, -1 on error.
4879 '''
4880 f = _Cfunctions.get('libvlc_media_library_load', None) or \
4881 _Cfunction('libvlc_media_library_load', ((1,),), None,
4882 ctypes.c_int, MediaLibrary)
4883 return f(p_mlib)
4884
4885def libvlc_media_library_media_list(p_mlib):
4886 '''Get media library subitems.
4887 @param p_mlib: media library object.
4888 @return: media list subitems.
4889 '''
4890 f = _Cfunctions.get('libvlc_media_library_media_list', None) or \
4891 _Cfunction('libvlc_media_library_media_list', ((1,),), class_result(MediaList),
4892 ctypes.c_void_p, MediaLibrary)
4893 return f(p_mlib)
4894
4895def libvlc_vlm_release(p_instance):
4896 '''Release the vlm instance related to the given L{Instance}.
4897 @param p_instance: the instance.
4898 '''
4899 f = _Cfunctions.get('libvlc_vlm_release', None) or \
4900 _Cfunction('libvlc_vlm_release', ((1,),), None,
4901 None, Instance)
4902 return f(p_instance)
4903
4904def libvlc_vlm_add_broadcast(p_instance, psz_name, psz_input, psz_output, i_options, ppsz_options, b_enabled, b_loop):
4905 '''Add a broadcast, with one input.
4906 @param p_instance: the instance.
4907 @param psz_name: the name of the new broadcast.
4908 @param psz_input: the input MRL.
4909 @param psz_output: the output MRL (the parameter to the "sout" variable).
4910 @param i_options: number of additional options.
4911 @param ppsz_options: additional options.
4912 @param b_enabled: boolean for enabling the new broadcast.
4913 @param b_loop: Should this broadcast be played in loop ?
4914 @return: 0 on success, -1 on error.
4915 '''
4916 f = _Cfunctions.get('libvlc_vlm_add_broadcast', None) or \
4917 _Cfunction('libvlc_vlm_add_broadcast', ((1,), (1,), (1,), (1,), (1,), (1,), (1,), (1,),), None,
4918 ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_int, ListPOINTER(ctypes.c_char_p), ctypes.c_int, ctypes.c_int)
4919 return f(p_instance, psz_name, psz_input, psz_output, i_options, ppsz_options, b_enabled, b_loop)
4920
4921def libvlc_vlm_add_vod(p_instance, psz_name, psz_input, i_options, ppsz_options, b_enabled, psz_mux):
4922 '''Add a vod, with one input.
4923 @param p_instance: the instance.
4924 @param psz_name: the name of the new vod media.
4925 @param psz_input: the input MRL.
4926 @param i_options: number of additional options.
4927 @param ppsz_options: additional options.
4928 @param b_enabled: boolean for enabling the new vod.
4929 @param psz_mux: the muxer of the vod media.
4930 @return: 0 on success, -1 on error.
4931 '''
4932 f = _Cfunctions.get('libvlc_vlm_add_vod', None) or \
4933 _Cfunction('libvlc_vlm_add_vod', ((1,), (1,), (1,), (1,), (1,), (1,), (1,),), None,
4934 ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_int, ListPOINTER(ctypes.c_char_p), ctypes.c_int, ctypes.c_char_p)
4935 return f(p_instance, psz_name, psz_input, i_options, ppsz_options, b_enabled, psz_mux)
4936
4937def libvlc_vlm_del_media(p_instance, psz_name):
4938 '''Delete a media (VOD or broadcast).
4939 @param p_instance: the instance.
4940 @param psz_name: the media to delete.
4941 @return: 0 on success, -1 on error.
4942 '''
4943 f = _Cfunctions.get('libvlc_vlm_del_media', None) or \
4944 _Cfunction('libvlc_vlm_del_media', ((1,), (1,),), None,
4945 ctypes.c_int, Instance, ctypes.c_char_p)
4946 return f(p_instance, psz_name)
4947
4948def libvlc_vlm_set_enabled(p_instance, psz_name, b_enabled):
4949 '''Enable or disable a media (VOD or broadcast).
4950 @param p_instance: the instance.
4951 @param psz_name: the media to work on.
4952 @param b_enabled: the new status.
4953 @return: 0 on success, -1 on error.
4954 '''
4955 f = _Cfunctions.get('libvlc_vlm_set_enabled', None) or \
4956 _Cfunction('libvlc_vlm_set_enabled', ((1,), (1,), (1,),), None,
4957 ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_int)
4958 return f(p_instance, psz_name, b_enabled)
4959
4960def libvlc_vlm_set_output(p_instance, psz_name, psz_output):
4961 '''Set the output for a media.
4962 @param p_instance: the instance.
4963 @param psz_name: the media to work on.
4964 @param psz_output: the output MRL (the parameter to the "sout" variable).
4965 @return: 0 on success, -1 on error.
4966 '''
4967 f = _Cfunctions.get('libvlc_vlm_set_output', None) or \
4968 _Cfunction('libvlc_vlm_set_output', ((1,), (1,), (1,),), None,
4969 ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_char_p)
4970 return f(p_instance, psz_name, psz_output)
4971
4972def libvlc_vlm_set_input(p_instance, psz_name, psz_input):
4973 '''Set a media's input MRL. This will delete all existing inputs and
4974 add the specified one.
4975 @param p_instance: the instance.
4976 @param psz_name: the media to work on.
4977 @param psz_input: the input MRL.
4978 @return: 0 on success, -1 on error.
4979 '''
4980 f = _Cfunctions.get('libvlc_vlm_set_input', None) or \
4981 _Cfunction('libvlc_vlm_set_input', ((1,), (1,), (1,),), None,
4982 ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_char_p)
4983 return f(p_instance, psz_name, psz_input)
4984
4985def libvlc_vlm_add_input(p_instance, psz_name, psz_input):
4986 '''Add a media's input MRL. This will add the specified one.
4987 @param p_instance: the instance.
4988 @param psz_name: the media to work on.
4989 @param psz_input: the input MRL.
4990 @return: 0 on success, -1 on error.
4991 '''
4992 f = _Cfunctions.get('libvlc_vlm_add_input', None) or \
4993 _Cfunction('libvlc_vlm_add_input', ((1,), (1,), (1,),), None,
4994 ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_char_p)
4995 return f(p_instance, psz_name, psz_input)
4996
4997def libvlc_vlm_set_loop(p_instance, psz_name, b_loop):
4998 '''Set a media's loop status.
4999 @param p_instance: the instance.
5000 @param psz_name: the media to work on.
5001 @param b_loop: the new status.
5002 @return: 0 on success, -1 on error.
5003 '''
5004 f = _Cfunctions.get('libvlc_vlm_set_loop', None) or \
5005 _Cfunction('libvlc_vlm_set_loop', ((1,), (1,), (1,),), None,
5006 ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_int)
5007 return f(p_instance, psz_name, b_loop)
5008
5009def libvlc_vlm_set_mux(p_instance, psz_name, psz_mux):
5010 '''Set a media's vod muxer.
5011 @param p_instance: the instance.
5012 @param psz_name: the media to work on.
5013 @param psz_mux: the new muxer.
5014 @return: 0 on success, -1 on error.
5015 '''
5016 f = _Cfunctions.get('libvlc_vlm_set_mux', None) or \
5017 _Cfunction('libvlc_vlm_set_mux', ((1,), (1,), (1,),), None,
5018 ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_char_p)
5019 return f(p_instance, psz_name, psz_mux)
5020
5021def libvlc_vlm_change_media(p_instance, psz_name, psz_input, psz_output, i_options, ppsz_options, b_enabled, b_loop):
5022 '''Edit the parameters of a media. This will delete all existing inputs and
5023 add the specified one.
5024 @param p_instance: the instance.
5025 @param psz_name: the name of the new broadcast.
5026 @param psz_input: the input MRL.
5027 @param psz_output: the output MRL (the parameter to the "sout" variable).
5028 @param i_options: number of additional options.
5029 @param ppsz_options: additional options.
5030 @param b_enabled: boolean for enabling the new broadcast.
5031 @param b_loop: Should this broadcast be played in loop ?
5032 @return: 0 on success, -1 on error.
5033 '''
5034 f = _Cfunctions.get('libvlc_vlm_change_media', None) or \
5035 _Cfunction('libvlc_vlm_change_media', ((1,), (1,), (1,), (1,), (1,), (1,), (1,), (1,),), None,
5036 ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_int, ListPOINTER(ctypes.c_char_p), ctypes.c_int, ctypes.c_int)
5037 return f(p_instance, psz_name, psz_input, psz_output, i_options, ppsz_options, b_enabled, b_loop)
5038
5039def libvlc_vlm_play_media(p_instance, psz_name):
5040 '''Play the named broadcast.
5041 @param p_instance: the instance.
5042 @param psz_name: the name of the broadcast.
5043 @return: 0 on success, -1 on error.
5044 '''
5045 f = _Cfunctions.get('libvlc_vlm_play_media', None) or \
5046 _Cfunction('libvlc_vlm_play_media', ((1,), (1,),), None,
5047 ctypes.c_int, Instance, ctypes.c_char_p)
5048 return f(p_instance, psz_name)
5049
5050def libvlc_vlm_stop_media(p_instance, psz_name):
5051 '''Stop the named broadcast.
5052 @param p_instance: the instance.
5053 @param psz_name: the name of the broadcast.
5054 @return: 0 on success, -1 on error.
5055 '''
5056 f = _Cfunctions.get('libvlc_vlm_stop_media', None) or \
5057 _Cfunction('libvlc_vlm_stop_media', ((1,), (1,),), None,
5058 ctypes.c_int, Instance, ctypes.c_char_p)
5059 return f(p_instance, psz_name)
5060
5061def libvlc_vlm_pause_media(p_instance, psz_name):
5062 '''Pause the named broadcast.
5063 @param p_instance: the instance.
5064 @param psz_name: the name of the broadcast.
5065 @return: 0 on success, -1 on error.
5066 '''
5067 f = _Cfunctions.get('libvlc_vlm_pause_media', None) or \
5068 _Cfunction('libvlc_vlm_pause_media', ((1,), (1,),), None,
5069 ctypes.c_int, Instance, ctypes.c_char_p)
5070 return f(p_instance, psz_name)
5071
5072def libvlc_vlm_seek_media(p_instance, psz_name, f_percentage):
5073 '''Seek in the named broadcast.
5074 @param p_instance: the instance.
5075 @param psz_name: the name of the broadcast.
5076 @param f_percentage: the percentage to seek to.
5077 @return: 0 on success, -1 on error.
5078 '''
5079 f = _Cfunctions.get('libvlc_vlm_seek_media', None) or \
5080 _Cfunction('libvlc_vlm_seek_media', ((1,), (1,), (1,),), None,
5081 ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_float)
5082 return f(p_instance, psz_name, f_percentage)
5083
5084def libvlc_vlm_show_media(p_instance, psz_name):
5085 '''Return information about the named media as a JSON
5086 string representation.
5087 This function is mainly intended for debugging use,
5088 if you want programmatic access to the state of
5089 a vlm_media_instance_t, please use the corresponding
5090 libvlc_vlm_get_media_instance_xxx -functions.
5091 Currently there are no such functions available for
5092 vlm_media_t though.
5093 @param p_instance: the instance.
5094 @param psz_name: the name of the media, if the name is an empty string, all media is described.
5095 @return: string with information about named media, or None on error.
5096 '''
5097 f = _Cfunctions.get('libvlc_vlm_show_media', None) or \
5098 _Cfunction('libvlc_vlm_show_media', ((1,), (1,),), string_result,
5099 ctypes.c_void_p, Instance, ctypes.c_char_p)
5100 return f(p_instance, psz_name)
5101
5102def libvlc_vlm_get_media_instance_position(p_instance, psz_name, i_instance):
5103 '''Get vlm_media instance position by name or instance id.
5104 @param p_instance: a libvlc instance.
5105 @param psz_name: name of vlm media instance.
5106 @param i_instance: instance id.
5107 @return: position as float or -1. on error.
5108 '''
5109 f = _Cfunctions.get('libvlc_vlm_get_media_instance_position', None) or \
5110 _Cfunction('libvlc_vlm_get_media_instance_position', ((1,), (1,), (1,),), None,
5111 ctypes.c_float, Instance, ctypes.c_char_p, ctypes.c_int)
5112 return f(p_instance, psz_name, i_instance)
5113
5114def libvlc_vlm_get_media_instance_time(p_instance, psz_name, i_instance):
5115 '''Get vlm_media instance time by name or instance id.
5116 @param p_instance: a libvlc instance.
5117 @param psz_name: name of vlm media instance.
5118 @param i_instance: instance id.
5119 @return: time as integer or -1 on error.
5120 '''
5121 f = _Cfunctions.get('libvlc_vlm_get_media_instance_time', None) or \
5122 _Cfunction('libvlc_vlm_get_media_instance_time', ((1,), (1,), (1,),), None,
5123 ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_int)
5124 return f(p_instance, psz_name, i_instance)
5125
5126def libvlc_vlm_get_media_instance_length(p_instance, psz_name, i_instance):
5127 '''Get vlm_media instance length by name or instance id.
5128 @param p_instance: a libvlc instance.
5129 @param psz_name: name of vlm media instance.
5130 @param i_instance: instance id.
5131 @return: length of media item or -1 on error.
5132 '''
5133 f = _Cfunctions.get('libvlc_vlm_get_media_instance_length', None) or \
5134 _Cfunction('libvlc_vlm_get_media_instance_length', ((1,), (1,), (1,),), None,
5135 ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_int)
5136 return f(p_instance, psz_name, i_instance)
5137
5138def libvlc_vlm_get_media_instance_rate(p_instance, psz_name, i_instance):
5139 '''Get vlm_media instance playback rate by name or instance id.
5140 @param p_instance: a libvlc instance.
5141 @param psz_name: name of vlm media instance.
5142 @param i_instance: instance id.
5143 @return: playback rate or -1 on error.
5144 '''
5145 f = _Cfunctions.get('libvlc_vlm_get_media_instance_rate', None) or \
5146 _Cfunction('libvlc_vlm_get_media_instance_rate', ((1,), (1,), (1,),), None,
5147 ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_int)
5148 return f(p_instance, psz_name, i_instance)
5149
5150def libvlc_vlm_get_media_instance_title(p_instance, psz_name, i_instance):
5151 '''Get vlm_media instance title number by name or instance id.
5152 @param p_instance: a libvlc instance.
5153 @param psz_name: name of vlm media instance.
5154 @param i_instance: instance id.
5155 @return: title as number or -1 on error.
5156 @bug: will always return 0.
5157 '''
5158 f = _Cfunctions.get('libvlc_vlm_get_media_instance_title', None) or \
5159 _Cfunction('libvlc_vlm_get_media_instance_title', ((1,), (1,), (1,),), None,
5160 ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_int)
5161 return f(p_instance, psz_name, i_instance)
5162
5163def libvlc_vlm_get_media_instance_chapter(p_instance, psz_name, i_instance):
5164 '''Get vlm_media instance chapter number by name or instance id.
5165 @param p_instance: a libvlc instance.
5166 @param psz_name: name of vlm media instance.
5167 @param i_instance: instance id.
5168 @return: chapter as number or -1 on error.
5169 @bug: will always return 0.
5170 '''
5171 f = _Cfunctions.get('libvlc_vlm_get_media_instance_chapter', None) or \
5172 _Cfunction('libvlc_vlm_get_media_instance_chapter', ((1,), (1,), (1,),), None,
5173 ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_int)
5174 return f(p_instance, psz_name, i_instance)
5175
5176def libvlc_vlm_get_media_instance_seekable(p_instance, psz_name, i_instance):
5177 '''Is libvlc instance seekable ?
5178 @param p_instance: a libvlc instance.
5179 @param psz_name: name of vlm media instance.
5180 @param i_instance: instance id.
5181 @return: 1 if seekable, 0 if not, -1 if media does not exist.
5182 @bug: will always return 0.
5183 '''
5184 f = _Cfunctions.get('libvlc_vlm_get_media_instance_seekable', None) or \
5185 _Cfunction('libvlc_vlm_get_media_instance_seekable', ((1,), (1,), (1,),), None,
5186 ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_int)
5187 return f(p_instance, psz_name, i_instance)
5188
5189def libvlc_vlm_get_event_manager(p_instance):
5190 '''Get libvlc_event_manager from a vlm media.
5191 The p_event_manager is immutable, so you don't have to hold the lock.
5192 @param p_instance: a libvlc instance.
5193 @return: libvlc_event_manager.
5194 '''
5195 f = _Cfunctions.get('libvlc_vlm_get_event_manager', None) or \
5196 _Cfunction('libvlc_vlm_get_event_manager', ((1,),), class_result(EventManager),
5197 ctypes.c_void_p, Instance)
5198 return f(p_instance)
5199
3878def libvlc_media_new_location(p_instance, psz_mrl):5200def libvlc_media_new_location(p_instance, psz_mrl):
3879 '''Create a media with a certain given media resource location,5201 '''Create a media with a certain given media resource location,
3880 for instance a valid URL.5202 for instance a valid URL.
@@ -3928,6 +5250,22 @@
3928 ctypes.c_void_p, Instance, ctypes.c_int)5250 ctypes.c_void_p, Instance, ctypes.c_int)
3929 return f(p_instance, fd)5251 return f(p_instance, fd)
39305252
5253def libvlc_media_new_callbacks(instance, open_cb, read_cb, seek_cb, close_cb, opaque):
5254 '''Create a media with custom callbacks to read the data from.
5255 @param instance: LibVLC instance.
5256 @param open_cb: callback to open the custom bitstream input media.
5257 @param read_cb: callback to read data (must not be None).
5258 @param seek_cb: callback to seek, or None if seeking is not supported.
5259 @param close_cb: callback to close the media, or None if unnecessary.
5260 @param opaque: data pointer for the open callback.
5261 @return: the newly created media or None on error @note If open_cb is None, the opaque pointer will be passed to read_cb, seek_cb and close_cb, and the stream size will be treated as unknown. @note The callbacks may be called asynchronously (from another thread). A single stream instance need not be reentrant. However the open_cb needs to be reentrant if the media is used by multiple player instances. @warning The callbacks may be used until all or any player instances that were supplied the media item are stopped. See L{libvlc_media_release}.
5262 @version: LibVLC 3.0.0 and later.
5263 '''
5264 f = _Cfunctions.get('libvlc_media_new_callbacks', None) or \
5265 _Cfunction('libvlc_media_new_callbacks', ((1,), (1,), (1,), (1,), (1,), (1,),), class_result(Media),
5266 ctypes.c_void_p, Instance, MediaOpenCb, MediaReadCb, MediaSeekCb, MediaCloseCb, ctypes.c_void_p)
5267 return f(instance, open_cb, read_cb, seek_cb, close_cb, opaque)
5268
3931def libvlc_media_new_as_node(p_instance, psz_name):5269def libvlc_media_new_as_node(p_instance, psz_name):
3932 '''Create a media as an empty node with a given name.5270 '''Create a media as an empty node with a given name.
3933 See L{libvlc_media_release}.5271 See L{libvlc_media_release}.
@@ -3980,7 +5318,7 @@
3980 return f(p_md, psz_options, i_flags)5318 return f(p_md, psz_options, i_flags)
39815319
3982def libvlc_media_retain(p_md):5320def libvlc_media_retain(p_md):
3983 '''Retain a reference to a media descriptor object (libvlc_media_t). Use5321 '''Retain a reference to a media descriptor object (L{Media}). Use
3984 L{libvlc_media_release}() to decrement the reference count of a5322 L{libvlc_media_release}() to decrement the reference count of a
3985 media descriptor object.5323 media descriptor object.
3986 @param p_md: the media descriptor.5324 @param p_md: the media descriptor.
@@ -4025,11 +5363,8 @@
4025def libvlc_media_get_meta(p_md, e_meta):5363def libvlc_media_get_meta(p_md, e_meta):
4026 '''Read the meta of the media.5364 '''Read the meta of the media.
4027 If the media has not yet been parsed this will return None.5365 If the media has not yet been parsed this will return None.
4028 This methods automatically calls L{libvlc_media_parse_async}(), so after calling
4029 it you may receive a libvlc_MediaMetaChanged event. If you prefer a synchronous
4030 version ensure that you call L{libvlc_media_parse}() before get_meta().
4031 See L{libvlc_media_parse}5366 See L{libvlc_media_parse}
4032 See L{libvlc_media_parse_async}5367 See L{libvlc_media_parse_with_options}
4033 See libvlc_MediaMetaChanged.5368 See libvlc_MediaMetaChanged.
4034 @param p_md: the media descriptor.5369 @param p_md: the media descriptor.
4035 @param e_meta: the meta to read.5370 @param e_meta: the meta to read.
@@ -4063,12 +5398,10 @@
4063 return f(p_md)5398 return f(p_md)
40645399
4065def libvlc_media_get_state(p_md):5400def libvlc_media_get_state(p_md):
4066 '''Get current state of media descriptor object. Possible media states5401 '''Get current state of media descriptor object. Possible media states are
4067 are defined in libvlc_structures.c ( libvlc_NothingSpecial=0,5402 libvlc_NothingSpecial=0, libvlc_Opening, libvlc_Playing, libvlc_Paused,
4068 libvlc_Opening, libvlc_Buffering, libvlc_Playing, libvlc_Paused,5403 libvlc_Stopped, libvlc_Ended, libvlc_Error.
4069 libvlc_Stopped, libvlc_Ended,5404 See L{State}.
4070 libvlc_Error).
4071 See libvlc_state_t.
4072 @param p_md: a media descriptor object.5405 @param p_md: a media descriptor object.
4073 @return: state of media descriptor object.5406 @return: state of media descriptor object.
4074 '''5407 '''
@@ -4121,47 +5454,57 @@
4121 ctypes.c_longlong, Media)5454 ctypes.c_longlong, Media)
4122 return f(p_md)5455 return f(p_md)
41235456
4124def libvlc_media_parse(p_md):5457def libvlc_media_parse_with_options(p_md, parse_flag, timeout):
4125 '''Parse a media.5458 '''Parse the media asynchronously with options.
4126 This fetches (local) meta data and tracks information.5459 This fetches (local or network) art, meta data and/or tracks information.
4127 The method is synchronous.5460 This method is the extended version of L{libvlc_media_parse_with_options}().
4128 See L{libvlc_media_parse_async}
4129 See L{libvlc_media_get_meta}
4130 See libvlc_media_get_tracks_info.
4131 @param p_md: media descriptor object.
4132 '''
4133 f = _Cfunctions.get('libvlc_media_parse', None) or \
4134 _Cfunction('libvlc_media_parse', ((1,),), None,
4135 None, Media)
4136 return f(p_md)
4137
4138def libvlc_media_parse_async(p_md):
4139 '''Parse a media.
4140 This fetches (local) meta data and tracks information.
4141 The method is the asynchronous of L{libvlc_media_parse}().
4142 To track when this is over you can listen to libvlc_MediaParsedChanged5461 To track when this is over you can listen to libvlc_MediaParsedChanged
4143 event. However if the media was already parsed you will not receive this5462 event. However if this functions returns an error, you will not receive any
4144 event.5463 events.
4145 See L{libvlc_media_parse}5464 It uses a flag to specify parse options (see L{MediaParseFlag}). All
5465 these flags can be combined. By default, media is parsed if it's a local
5466 file.
5467 @note: Parsing can be aborted with L{libvlc_media_parse_stop}().
4146 See libvlc_MediaParsedChanged5468 See libvlc_MediaParsedChanged
4147 See L{libvlc_media_get_meta}5469 See L{libvlc_media_get_meta}
4148 See libvlc_media_get_tracks_info.5470 See L{libvlc_media_tracks_get}
4149 @param p_md: media descriptor object.5471 See L{libvlc_media_get_parsed_status}
4150 '''5472 See L{MediaParseFlag}.
4151 f = _Cfunctions.get('libvlc_media_parse_async', None) or \5473 @param p_md: media descriptor object.
4152 _Cfunction('libvlc_media_parse_async', ((1,),), None,5474 @param parse_flag: parse options:
5475 @param timeout: maximum time allowed to preparse the media. If -1, the default "preparse-timeout" option will be used as a timeout. If 0, it will wait indefinitely. If > 0, the timeout will be used (in milliseconds).
5476 @return: -1 in case of error, 0 otherwise.
5477 @version: LibVLC 3.0.0 or later.
5478 '''
5479 f = _Cfunctions.get('libvlc_media_parse_with_options', None) or \
5480 _Cfunction('libvlc_media_parse_with_options', ((1,), (1,), (1,),), None,
5481 ctypes.c_int, Media, MediaParseFlag, ctypes.c_int)
5482 return f(p_md, parse_flag, timeout)
5483
5484def libvlc_media_parse_stop(p_md):
5485 '''Stop the parsing of the media
5486 When the media parsing is stopped, the libvlc_MediaParsedChanged event will
5487 be sent with the libvlc_media_parsed_status_timeout status.
5488 See L{libvlc_media_parse_with_options}.
5489 @param p_md: media descriptor object.
5490 @version: LibVLC 3.0.0 or later.
5491 '''
5492 f = _Cfunctions.get('libvlc_media_parse_stop', None) or \
5493 _Cfunction('libvlc_media_parse_stop', ((1,),), None,
4153 None, Media)5494 None, Media)
4154 return f(p_md)5495 return f(p_md)
41555496
4156def libvlc_media_is_parsed(p_md):5497def libvlc_media_get_parsed_status(p_md):
4157 '''Get Parsed status for media descriptor object.5498 '''Get Parsed status for media descriptor object.
4158 See libvlc_MediaParsedChanged.5499 See libvlc_MediaParsedChanged
5500 See L{MediaParsedStatus}.
4159 @param p_md: media descriptor object.5501 @param p_md: media descriptor object.
4160 @return: true if media object has been parsed otherwise it returns false \libvlc_return_bool.5502 @return: a value of the L{MediaParsedStatus} enum.
5503 @version: LibVLC 3.0.0 or later.
4161 '''5504 '''
4162 f = _Cfunctions.get('libvlc_media_is_parsed', None) or \5505 f = _Cfunctions.get('libvlc_media_get_parsed_status', None) or \
4163 _Cfunction('libvlc_media_is_parsed', ((1,),), None,5506 _Cfunction('libvlc_media_get_parsed_status', ((1,),), None,
4164 ctypes.c_int, Media)5507 MediaParsedStatus, Media)
4165 return f(p_md)5508 return f(p_md)
41665509
4167def libvlc_media_set_user_data(p_md, p_new_user_data):5510def libvlc_media_set_user_data(p_md, p_new_user_data):
@@ -4202,6 +5545,18 @@
4202 ctypes.c_uint, Media, ctypes.POINTER(ctypes.POINTER(MediaTrack)))5545 ctypes.c_uint, Media, ctypes.POINTER(ctypes.POINTER(MediaTrack)))
4203 return f(p_md, tracks)5546 return f(p_md, tracks)
42045547
5548def libvlc_media_get_codec_description(i_type, i_codec):
5549 '''Get codec description from media elementary stream.
5550 @param i_type: i_type from L{MediaTrack}.
5551 @param i_codec: i_codec or i_original_fourcc from L{MediaTrack}.
5552 @return: codec description.
5553 @version: LibVLC 3.0.0 and later. See L{MediaTrack}.
5554 '''
5555 f = _Cfunctions.get('libvlc_media_get_codec_description', None) or \
5556 _Cfunction('libvlc_media_get_codec_description', ((1,), (1,),), None,
5557 ctypes.c_char_p, TrackType, ctypes.c_uint32)
5558 return f(i_type, i_codec)
5559
4205def libvlc_media_tracks_release(p_tracks, i_count):5560def libvlc_media_tracks_release(p_tracks, i_count):
4206 '''Release media descriptor's elementary streams description array.5561 '''Release media descriptor's elementary streams description array.
4207 @param p_tracks: tracks info array to release.5562 @param p_tracks: tracks info array to release.
@@ -4213,118 +5568,232 @@
4213 None, ctypes.POINTER(MediaTrack), ctypes.c_uint)5568 None, ctypes.POINTER(MediaTrack), ctypes.c_uint)
4214 return f(p_tracks, i_count)5569 return f(p_tracks, i_count)
42155570
4216def libvlc_media_discoverer_new_from_name(p_inst, psz_name):5571def libvlc_media_get_type(p_md):
4217 '''Discover media service by name.5572 '''Get the media type of the media descriptor object.
5573 @param p_md: media descriptor object.
5574 @return: media type.
5575 @version: LibVLC 3.0.0 and later. See L{MediaType}.
5576 '''
5577 f = _Cfunctions.get('libvlc_media_get_type', None) or \
5578 _Cfunction('libvlc_media_get_type', ((1,),), None,
5579 MediaType, Media)
5580 return f(p_md)
5581
5582def libvlc_media_slaves_add(p_md, i_type, i_priority, psz_uri):
5583 '''Add a slave to the current media.
5584 A slave is an external input source that may contains an additional subtitle
5585 track (like a .srt) or an additional audio track (like a .ac3).
5586 @note: This function must be called before the media is parsed (via
5587 L{libvlc_media_parse_with_options}()) or before the media is played (via
5588 L{libvlc_media_player_play}()).
5589 @param p_md: media descriptor object.
5590 @param i_type: subtitle or audio.
5591 @param i_priority: from 0 (low priority) to 4 (high priority).
5592 @param psz_uri: Uri of the slave (should contain a valid scheme).
5593 @return: 0 on success, -1 on error.
5594 @version: LibVLC 3.0.0 and later.
5595 '''
5596 f = _Cfunctions.get('libvlc_media_slaves_add', None) or \
5597 _Cfunction('libvlc_media_slaves_add', ((1,), (1,), (1,), (1,),), None,
5598 ctypes.c_int, Media, MediaSlaveType, ctypes.c_int, ctypes.c_char_p)
5599 return f(p_md, i_type, i_priority, psz_uri)
5600
5601def libvlc_media_slaves_clear(p_md):
5602 '''Clear all slaves previously added by L{libvlc_media_slaves_add}() or
5603 internally.
5604 @param p_md: media descriptor object.
5605 @version: LibVLC 3.0.0 and later.
5606 '''
5607 f = _Cfunctions.get('libvlc_media_slaves_clear', None) or \
5608 _Cfunction('libvlc_media_slaves_clear', ((1,),), None,
5609 None, Media)
5610 return f(p_md)
5611
5612def libvlc_media_slaves_get(p_md, ppp_slaves):
5613 '''Get a media descriptor's slave list
5614 The list will contain slaves parsed by VLC or previously added by
5615 L{libvlc_media_slaves_add}(). The typical use case of this function is to save
5616 a list of slave in a database for a later use.
5617 @param p_md: media descriptor object.
5618 @param ppp_slaves: address to store an allocated array of slaves (must be freed with L{libvlc_media_slaves_release}()) [OUT].
5619 @return: the number of slaves (zero on error).
5620 @version: LibVLC 3.0.0 and later. See L{libvlc_media_slaves_add}.
5621 '''
5622 f = _Cfunctions.get('libvlc_media_slaves_get', None) or \
5623 _Cfunction('libvlc_media_slaves_get', ((1,), (1,),), None,
5624 ctypes.c_int, Media, ctypes.POINTER(ctypes.POINTER(MediaSlave)))
5625 return f(p_md, ppp_slaves)
5626
5627def libvlc_media_slaves_release(pp_slaves, i_count):
5628 '''Release a media descriptor's slave list.
5629 @param pp_slaves: slave array to release.
5630 @param i_count: number of elements in the array.
5631 @version: LibVLC 3.0.0 and later.
5632 '''
5633 f = _Cfunctions.get('libvlc_media_slaves_release', None) or \
5634 _Cfunction('libvlc_media_slaves_release', ((1,), (1,),), None,
5635 None, ctypes.POINTER(MediaSlave), ctypes.c_int)
5636 return f(pp_slaves, i_count)
5637
5638def libvlc_renderer_item_hold(p_item):
5639 '''Hold a renderer item, i.e. creates a new reference
5640 This functions need to called from the libvlc_RendererDiscovererItemAdded
5641 callback if the libvlc user wants to use this item after. (for display or
5642 for passing it to the mediaplayer for example).
5643 @return: the current item.
5644 @version: LibVLC 3.0.0 or later.
5645 '''
5646 f = _Cfunctions.get('libvlc_renderer_item_hold', None) or \
5647 _Cfunction('libvlc_renderer_item_hold', ((1,),), None,
5648 ctypes.c_void_p, ctypes.c_void_p)
5649 return f(p_item)
5650
5651def libvlc_renderer_item_release(p_item):
5652 '''Releases a renderer item, i.e. decrements its reference counter.
5653 @version: LibVLC 3.0.0 or later.
5654 '''
5655 f = _Cfunctions.get('libvlc_renderer_item_release', None) or \
5656 _Cfunction('libvlc_renderer_item_release', ((1,),), None,
5657 None, ctypes.c_void_p)
5658 return f(p_item)
5659
5660def libvlc_renderer_item_name(p_item):
5661 '''Get the human readable name of a renderer item.
5662 @return: the name of the item (can't be None, must *not* be freed).
5663 @version: LibVLC 3.0.0 or later.
5664 '''
5665 f = _Cfunctions.get('libvlc_renderer_item_name', None) or \
5666 _Cfunction('libvlc_renderer_item_name', ((1,),), None,
5667 ctypes.c_char_p, ctypes.c_void_p)
5668 return f(p_item)
5669
5670def libvlc_renderer_item_type(p_item):
5671 '''Get the type (not translated) of a renderer item. For now, the type can only
5672 be "chromecast" ("upnp", "airplay" may come later).
5673 @return: the type of the item (can't be None, must *not* be freed).
5674 @version: LibVLC 3.0.0 or later.
5675 '''
5676 f = _Cfunctions.get('libvlc_renderer_item_type', None) or \
5677 _Cfunction('libvlc_renderer_item_type', ((1,),), None,
5678 ctypes.c_char_p, ctypes.c_void_p)
5679 return f(p_item)
5680
5681def libvlc_renderer_item_icon_uri(p_item):
5682 '''Get the icon uri of a renderer item.
5683 @return: the uri of the item's icon (can be None, must *not* be freed).
5684 @version: LibVLC 3.0.0 or later.
5685 '''
5686 f = _Cfunctions.get('libvlc_renderer_item_icon_uri', None) or \
5687 _Cfunction('libvlc_renderer_item_icon_uri', ((1,),), None,
5688 ctypes.c_char_p, ctypes.c_void_p)
5689 return f(p_item)
5690
5691def libvlc_renderer_item_flags(p_item):
5692 '''Get the flags of a renderer item
5693 See LIBVLC_RENDERER_CAN_AUDIO
5694 See LIBVLC_RENDERER_CAN_VIDEO.
5695 @return: bitwise flag: capabilities of the renderer, see.
5696 @version: LibVLC 3.0.0 or later.
5697 '''
5698 f = _Cfunctions.get('libvlc_renderer_item_flags', None) or \
5699 _Cfunction('libvlc_renderer_item_flags', ((1,),), None,
5700 ctypes.c_int, ctypes.c_void_p)
5701 return f(p_item)
5702
5703def libvlc_renderer_discoverer_new(p_inst, psz_name):
5704 '''Create a renderer discoverer object by name
5705 After this object is created, you should attach to events in order to be
5706 notified of the discoverer events.
5707 You need to call L{libvlc_renderer_discoverer_start}() in order to start the
5708 discovery.
5709 See L{libvlc_renderer_discoverer_event_manager}()
5710 See L{libvlc_renderer_discoverer_start}().
4218 @param p_inst: libvlc instance.5711 @param p_inst: libvlc instance.
4219 @param psz_name: service name.5712 @param psz_name: service name; use L{libvlc_renderer_discoverer_list_get}() to get a list of the discoverer names available in this libVLC instance.
4220 @return: media discover object or None in case of error.5713 @return: media discover object or None in case of error.
5714 @version: LibVLC 3.0.0 or later.
4221 '''5715 '''
4222 f = _Cfunctions.get('libvlc_media_discoverer_new_from_name', None) or \5716 f = _Cfunctions.get('libvlc_renderer_discoverer_new', None) or \
4223 _Cfunction('libvlc_media_discoverer_new_from_name', ((1,), (1,),), class_result(MediaDiscoverer),5717 _Cfunction('libvlc_renderer_discoverer_new', ((1,), (1,),), None,
4224 ctypes.c_void_p, Instance, ctypes.c_char_p)5718 ctypes.c_void_p, Instance, ctypes.c_char_p)
4225 return f(p_inst, psz_name)5719 return f(p_inst, psz_name)
42265720
4227def libvlc_media_discoverer_release(p_mdis):
4228 '''Release media discover object. If the reference count reaches 0, then
4229 the object will be released.
4230 @param p_mdis: media service discover object.
4231 '''
4232 f = _Cfunctions.get('libvlc_media_discoverer_release', None) or \
4233 _Cfunction('libvlc_media_discoverer_release', ((1,),), None,
4234 None, MediaDiscoverer)
4235 return f(p_mdis)
4236
4237def libvlc_media_discoverer_localized_name(p_mdis):
4238 '''Get media service discover object its localized name.
4239 @param p_mdis: media discover object.
4240 @return: localized name.
4241 '''
4242 f = _Cfunctions.get('libvlc_media_discoverer_localized_name', None) or \
The diff has been truncated for viewing.