From dbce448da135c803e470363f5ab95de75b7e304f Mon Sep 17 00:00:00 2001 From: "rimach crichter@web.de" Date: Sun, 5 Jun 2011 23:10:49 +0200 Subject: [PATCH] update --- openlp/core/lib/htmlbuilder.py | 36 +- openlp/core/lib/plugin.py | 6 + openlp/core/lib/pluginmanager.py | 5 + openlp/core/ui/mainwindow.py | 5 + openlp/core/ui/slidecontroller.py | 99 +-- openlp/plugins/media/lib/__init__.py | 44 +- openlp/plugins/media/lib/mediacontroller.py | 356 -------- openlp/plugins/media/lib/mediaitem.py | 2 +- openlp/plugins/media/lib/mediamanager.py | 385 +++++++++ openlp/plugins/media/lib/mediatab.py | 130 +-- .../lib/{phononcontroller.py => phononapi.py} | 54 +- openlp/plugins/media/lib/vlc.py | 811 +++++++++++------- .../media/lib/{vlccontroller.py => vlcapi.py} | 48 +- .../lib/{webkitcontroller.py => webkitapi.py} | 100 ++- openlp/plugins/media/mediaplugin.py | 3 + 15 files changed, 1143 insertions(+), 941 deletions(-) delete mode 100644 openlp/plugins/media/lib/mediacontroller.py create mode 100644 openlp/plugins/media/lib/mediamanager.py rename openlp/plugins/media/lib/{phononcontroller.py => phononapi.py} (85%) rename openlp/plugins/media/lib/{vlccontroller.py => vlcapi.py} (85%) rename openlp/plugins/media/lib/{webkitcontroller.py => webkitapi.py} (66%) diff --git a/openlp/core/lib/htmlbuilder.py b/openlp/core/lib/htmlbuilder.py index 69126163a..a0944054f 100644 --- a/openlp/core/lib/htmlbuilder.py +++ b/openlp/core/lib/htmlbuilder.py @@ -183,7 +183,8 @@ sup { case 'currentTime': return vid.currentTime; case 'seek': - vid.currentTime = seekVal; + // doesnt work curently + //vid.currentTime = seekVal; break; } } @@ -327,20 +328,22 @@ sup { } } - function show_flash(state, path){ +// http://www.adobe.com/support/flash/publishexport/scriptingwithflash/scriptingwithflash_03.html + function show_flash(state, path, volume, seekVal){ var text = document.getElementById('flash'); var flashMovie = getFlashMovieObject("OpenLPFlashMovie"); var src = "src = 'file:///" + path + "'"; var view_parm = " wmode='opaque'" + " width='" + window.innerWidth + "'" + " height='" + window.innerHeight + "'"; - var swf_parm = " autostart='false' loop='false' play='false'" + - " hidden='false' swliveconnect='true'" + - " name='OpenLPFlashMovie'>"; + var swf_parm = " name='OpenLPFlashMovie'" + + " autostart='true' loop='false' play='true'" + + " hidden='false' swliveconnect='true' allowscriptaccess='always'" + + " volume='" + volume + "'"; switch(state){ case 'load': - text.innerHTML = ""; + text.innerHTML = ""; flashMovie = getFlashMovieObject("OpenLPFlashMovie"); text.style.visibility = 'visible'; flashMovie.Play(); @@ -349,28 +352,29 @@ sup { text.style.visibility = 'visible'; flashMovie.Play(); break; - case 'rewind': - ret = 'rewind'; - alert(' Wert: ' + flashMovie.TGetProperty("/", 4)); -// flashMovie.TotalFrames() -// PercentLoaded() -// GotoFrame() - break; case 'pause': flashMovie.StopPlay(); text.style.visibility = 'hidden'; break; case 'stop': flashMovie.StopPlay(); -// flashMovie.GotoFrame(0); text.style.visibility = 'hidden'; + tempHtml = text.innerHTML; + text.innerHTML = ''; + text.innerHTML = tempHtml; break; case 'close': flashMovie.StopPlay(); text.style.visibility = 'hidden'; - break; text.innerHTML = ''; - break; + break; + case 'length': + return flashMovie.TotalFrames(); + case 'currentTime': + return flashMovie.CurrentFrame(); + case 'seek': +// flashMovie.GotoFrame(seekVal); + break; } } diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index d0d83cd0c..ef02a3a3e 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -244,6 +244,12 @@ class Plugin(QtCore.QObject): """ pass + def addControllerItems(self, controller, control_panel): + """ + Create items for all controller Panes + """ + pass + def getSettingsTab(self, parent): """ Create a tab for the settings window to display the configurable diff --git a/openlp/core/lib/pluginmanager.py b/openlp/core/lib/pluginmanager.py index 682352aa5..885c1c207 100644 --- a/openlp/core/lib/pluginmanager.py +++ b/openlp/core/lib/pluginmanager.py @@ -187,6 +187,11 @@ class PluginManager(object): if plugin.status is not PluginStatus.Disabled: plugin.addToolsMenuItem(tools_menu) + def hook_controller_items(self, controller, control_panel): + for plugin in self.plugins: + if plugin.status is not PluginStatus.Disabled: + plugin.addControllerItems(controller, control_panel) + def initialise_plugins(self): """ Loop through all the plugins and give them an opportunity to diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index bf6b7fa98..ff214dbd0 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -580,6 +580,11 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.pluginManager.hook_export_menu(self.FileExportMenu) # Call the hook method to pull in tools menus. self.pluginManager.hook_tools_menu(self.ToolsMenu) + # Call the hook method to pull in plugin Controller items + self.pluginManager.hook_controller_items( + self.previewController, self.previewController.getControlPanel()) + self.pluginManager.hook_controller_items( + self.liveController, self.liveController.getControlPanel()) # Call the initialise method to setup plugins. log.info(u'initialise plugins') self.pluginManager.initialise_plugins() diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 7f91c3670..93532285a 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -73,7 +73,6 @@ class SlideController(QtGui.QWidget): self.songEditList = [ u'Edit Song', ] - self.volume = 10 self.timer_id = 0 self.songEdit = False self.selectedRow = 0 @@ -224,20 +223,6 @@ class SlideController(QtGui.QWidget): 'Edit and reload song preview'), self.onEditSong) self.controllerLayout.addWidget(self.toolbar) - # Build a Media ToolBar - self.mediabar = OpenLPToolbar(self) - self.mediabar.addToolbarButton( - u'Media Start', u':/slides/media_playback_start.png', - translate('OpenLP.SlideController', 'Start playing media'), - self.onMediaPlay) - self.mediabar.addToolbarButton( - u'Media Pause', u':/slides/media_playback_pause.png', - translate('OpenLP.SlideController', 'Start playing media'), - self.onMediaPause) - self.mediabar.addToolbarButton( - u'Media Stop', u':/slides/media_playback_stop.png', - translate('OpenLP.SlideController', 'Start playing media'), - self.onMediaStop) if self.isLive: # Build the Song Toolbar self.songMenu = QtGui.QToolButton(self.toolbar) @@ -247,22 +232,6 @@ class SlideController(QtGui.QWidget): self.songMenu.setMenu(QtGui.QMenu( translate('OpenLP.SlideController', 'Go To'), self.toolbar)) self.toolbar.makeWidgetsInvisible([u'Song Menu']) - # Build the seekSlider. - self.seekSlider = QtGui.QSlider(QtCore.Qt.Horizontal) - self.seekSlider.setMaximum(1000) - # Build the volumeSlider. - self.volumeSlider = QtGui.QSlider(QtCore.Qt.Horizontal) - self.volumeSlider.setTickInterval(1) - self.volumeSlider.setTickPosition(QtGui.QSlider.TicksAbove) - self.volumeSlider.setMinimum(0) - self.volumeSlider.setMaximum(10) - self.seekSlider.setGeometry(QtCore.QRect(90, 260, 221, 24)) - self.seekSlider.setObjectName(u'seekSlider') - self.mediabar.addToolbarWidget(u'Seek Slider', self.seekSlider) - self.volumeSlider.setGeometry(QtCore.QRect(90, 160, 221, 24)) - self.volumeSlider.setObjectName(u'volumeSlider') - self.mediabar.addToolbarWidget(u'Audio Volume', self.volumeSlider) - self.controllerLayout.addWidget(self.mediabar) # Screen preview area self.previewFrame = QtGui.QFrame(self.splitter) self.previewFrame.setGeometry(QtCore.QRect(0, 0, 300, 300 * self.ratio)) @@ -302,10 +271,6 @@ class SlideController(QtGui.QWidget): # Signals QtCore.QObject.connect(self.previewListWidget, QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onSlideSelected) - QtCore.QObject.connect(self.seekSlider, - QtCore.SIGNAL(u'sliderMoved(int)'), self.mediaSeek) - QtCore.QObject.connect(self.volumeSlider, - QtCore.SIGNAL(u'sliderMoved(int)'), self.mediaVolume) if self.isLive: QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'maindisplay_active'), self.updatePreview) @@ -319,7 +284,6 @@ class SlideController(QtGui.QWidget): QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onGoLiveClick) self.toolbar.makeWidgetsInvisible(self.songEditList) - self.mediabar.setVisible(False) if self.isLive: self.setLiveHotkeys(self) self.__addActionsToWidget(self.previewListWidget) @@ -366,6 +330,19 @@ class SlideController(QtGui.QWidget): QtCore.SIGNAL(u'slidecontroller_%s_text_request' % self.typePrefix), self.onTextRequest) + def getControlPanel(self): + return self.controllerLayout + + def sendToPlugins(self, v1=None, v2=None, v3=None, v4=None, v5=None): + """ + This is the generic function to send signal for control widgets, + created from within other plugins + This function is needed to catch the current controller + """ + sender = self.sender().objectName() or self.sender().text() + controller = self + Receiver.send_message('%s' % sender, [controller, v1, v2, v3, v4, v5]) + def setPreviewHotkeys(self, parent=None): self.previousItem.setObjectName(u'previousItemPreview') self.nextItem.setObjectName(u'nextItemPreview') @@ -523,14 +500,9 @@ class SlideController(QtGui.QWidget): Allows the Preview toolbar to be customised """ self.toolbar.setVisible(True) - self.mediabar.setVisible(False) self.toolbar.makeWidgetsInvisible(self.songEditList) if item.is_capable(ItemCapabilities.AllowsEdit) and item.from_plugin: self.toolbar.makeWidgetsVisible(self.songEditList) - elif item.is_media(): - #self.toolbar.setVisible(False) - self.mediabar.setVisible(True) -# self.volumeSlider.setAudioOutput(self.audio) def refreshServiceItem(self): """ @@ -1089,58 +1061,15 @@ class SlideController(QtGui.QWidget): """ log.debug(u'SlideController onMediaStart') file = os.path.join(item.get_frame_path(), item.get_frame_title()) - Receiver.send_message(u'media_video', [self, file, self.volume, False]) - self.volumeSlider.setValue(self.volume) + Receiver.send_message(u'media_video', [self, file, False]) self.slidePreview.hide() - def mediaSeek(self): - """ - Respond to the release of Seek Slider - """ - log.debug(u'SlideController mediaSeek') - self.seekPos = self.seekSlider.value() - Receiver.send_message(u'media_seek', [self, self.seekPos]) - - def mediaVolume(self): - """ - Respond to the release of Volume Slider - """ - log.debug(u'SlideController mediaVolume') - self.volume = self.volumeSlider.value() - Receiver.send_message(u'media_volume', [self, self.volume]) - - - def onMediaPause(self): - """ - Respond to the Pause from the media Toolbar - """ - log.debug(u'SlideController onMediaPause') - Receiver.send_message(u'media_pause', self) - - def onMediaPlay(self): - """ - Respond to the Play from the media Toolbar - """ - log.debug(u'SlideController onMediaPlay') - Receiver.send_message(u'media_play', self) - self.slidePreview.hide() - - def onMediaStop(self): - """ - Respond to the Stop from the media Toolbar - """ - log.debug(u'SlideController onMediaStop') - Receiver.send_message(u'media_stop', self) - self.slidePreview.clear() - self.slidePreview.show() - def onMediaClose(self): """ Respond to a request to close the Video """ log.debug(u'SlideController onMediaClose') Receiver.send_message(u'media_reset', self) - self.slidePreview.clear() self.slidePreview.show() def _resetBlank(self): diff --git a/openlp/plugins/media/lib/__init__.py b/openlp/plugins/media/lib/__init__.py index 4469a3be4..79bc09e6c 100644 --- a/openlp/plugins/media/lib/__init__.py +++ b/openlp/plugins/media/lib/__init__.py @@ -24,9 +24,9 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -class MediaBackends(object): +class MediaAPIs(object): """ - An enumeration for possible Backends. + An enumeration for possible APIs. """ Webkit = 0 Phonon = 1 @@ -43,10 +43,32 @@ class MediaState(object): Paused = 4 Off = 6 -class MediaController(object): +class MediaType(object): """ - Specialiced MediaController class - to reflect Features of the related backend + """ + Audio = 0 + Video = 1 + Cd = 3 + Dvd = 4 + +class MediaInfo(object): + """ + This class hold the media related infos + """ + file_info = None + volume = 100 + isFlash = False + is_background = False + length = 0 + start_time = 0 + end_time = 0 + media_type = MediaType() + + +class MediaAPI(object): + """ + Specialiced Media API class + to reflect Features of the related API """ def __init__(self, parent): self.parent = parent @@ -57,19 +79,19 @@ class MediaController(object): self.audio_extensions_list = [] self.video_extensions_list = [] - def setup(self, display, hasAudio): + def setup(self, display): """ Create the related widgets for the current display """ pass - def load(self, display, path, volume, isBackground): + def load(self, display): """ Load a new media file and check if it is valid """ return True - def resize(self, display, controller): + def resize(self, display): """ If the main display size or position is changed, the media widgets should also resized @@ -118,7 +140,7 @@ class MediaController(object): """ pass - def update_ui(self, controller, display): + def update_ui(self, display): """ Do some ui related stuff (e.g. update the seek slider) @@ -128,7 +150,7 @@ class MediaController(object): @staticmethod def is_available(): """ - Check availability of the related backend + Check availability of the related API """ return False @@ -143,6 +165,6 @@ class MediaController(object): from mediaitem import MediaMediaItem from mediatab import MediaTab -from mediacontroller import MediaManager +from mediamanager import MediaManager __all__ = ['MediaMediaItem'] diff --git a/openlp/plugins/media/lib/mediacontroller.py b/openlp/plugins/media/lib/mediacontroller.py deleted file mode 100644 index b84fdc5a9..000000000 --- a/openlp/plugins/media/lib/mediacontroller.py +++ /dev/null @@ -1,356 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael # -# Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, Armin Köhler, # -# Andreas Preikschat, Mattias Põldaru, Christian Richter, Philip Ridout, # -# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund # -# --------------------------------------------------------------------------- # -# This program is free software; you can redistribute it and/or modify it # -# under the terms of the GNU General Public License as published by the Free # -# Software Foundation; version 2 of the License. # -# # -# This program is distributed in the hope that it will be useful, but WITHOUT # -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # -# more details. # -# # -# You should have received a copy of the GNU General Public License along # -# with this program; if not, write to the Free Software Foundation, Inc., 59 # -# Temple Place, Suite 330, Boston, MA 02111-1307 USA # -############################################################################### - -import logging - -import sys, os -from PyQt4 import QtCore, QtGui, QtWebKit - -from openlp.core.lib import Receiver, translate -from openlp.core.lib.ui import UiStrings, critical_error_message_box -from openlp.plugins.media.lib import MediaBackends, MediaState -from webkitcontroller import WebkitController -from phononcontroller import PhononController -from vlccontroller import VlcController - -log = logging.getLogger(__name__) - -class MediaManager(object): - """ - The implementation of a Media Manager - The idea is to separate the media related implementation - into the plugin files and unify the access from other parts of code - The media manager adds an own class for every type of backend - Currently these are QtWebkit, Phonon and planed Vlc. - """ - - def __init__(self, parent): - self.parent = parent - self.backends = {} - self.curDisplayMediaController = {} - #Create Backend Controllers - if WebkitController.is_available(): - self.backends[u'Webkit'] = WebkitController(self) - if PhononController.is_available(): - self.backends[u'Phonon'] = PhononController(self) - if VlcController.is_available(): - self.backends[u'Vlc'] = VlcController(self) - #Timer for video state - self.Timer = QtCore.QTimer() - self.Timer.setInterval(200) - self.withLivePreview = False - #Signals - QtCore.QObject.connect(self.Timer, - QtCore.SIGNAL("timeout()"), self.video_state) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'setup_display'), self.setup_display) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'media_video'), self.video) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'media_play'), self.video_play) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'media_pause'), self.video_pause) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'media_stop'), self.video_stop) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'media_seek'), self.video_seek) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'media_volume'), self.video_volume) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'media_reset'), self.video_reset) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'media_hide'), self.video_hide) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'media_blank'), self.video_blank) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'media_unblank'), self.video_unblank) - - def video_state(self): - """ - Check if there is an assigned media backend and do some - updating stuff (e.g. update the UI) - """ - isAnyonePlaying = False - if len(self.curDisplayMediaController.keys()) == 0: - self.Timer.stop() - else: - for display in self.curDisplayMediaController.keys(): - if display == self.parent.previewController.previewDisplay or \ - display == self.parent.previewController.display: - self.curDisplayMediaController[display] \ - .update_ui(self.parent.previewController, display) - else: - self.curDisplayMediaController[display] \ - .update_ui(self.parent.liveController, display) - if self.curDisplayMediaController[display] \ - .state == MediaState.Playing: - isAnyonePlaying = True - if not isAnyonePlaying: - self.Timer.stop() - - def setup_display(self, display): - """ - After a new display is configured, all media related widget - will be created too - """ - hasAudio = True - if not self.withLivePreview and \ - display == self.parent.liveController.previewDisplay: - return - if display == self.parent.previewController.previewDisplay or \ - display == self.parent.liveController.previewDisplay: - hasAudio = False - for backend in self.backends.values(): - backend.setup(display, hasAudio) - - def resize(self, controller): - """ - After Mainwindow changes or Splitter moved all related media - widgets have to be resized - """ - for display in self.curDisplayMediaController.keys(): - if display == self.parent.previewController.previewDisplay or \ - display == self.parent.liveController.previewDisplay: - display.resize(display.parent.slidePreview.size()) - self.curDisplayMediaController[display].resize(display, controller) - - def video(self, msg): - """ - Loads and starts a video to run with the option of sound - """ - controller = msg[0] - videoPath = os.path.abspath(msg[1]) - volume = msg[2] - isBackground = msg[3] - log.debug(u'video') - vol = float(volume) / float(10) - isValid = False - #stop running videos - self.video_reset(controller) - if controller.isLive: - if self.withLivePreview: - display = controller.previewDisplay - if self.check_file_type(display, videoPath, False): - #check size of all media_widgets - self.resize(controller) - self.curDisplayMediaController[display] \ - .load(display, videoPath, volume, isBackground) - display = controller.display - if self.check_file_type(display, videoPath, isBackground): - #check size of all media_widgets - self.resize(controller) - isValid = self.curDisplayMediaController[display] \ - .load(display, videoPath, volume, isBackground) - else: - display = controller.previewDisplay - if self.check_file_type(display, videoPath, isBackground): - #check size of all media_widgets - self.resize(controller) - isValid = self.curDisplayMediaController[display] \ - .load(display, videoPath, volume, isBackground) - if not isValid: - #Media could not be loaded correctly - critical_error_message_box( - translate('MediaPlugin.MediaItem', 'Unsupported File'), - unicode(translate('MediaPlugin.MediaItem', - 'Unsupported File'))) - return -# controller.display.webLoaded = True - #now start playing - self.video_play(controller) - - def check_file_type(self, display, videoPath, isBackground): - """ - Used to choose the right media backend type - from the prioritized backend list - """ - usedBackends = QtCore.QSettings().value(u'media/backends', - QtCore.QVariant(u'Webkit')).toString().split(u',') - media_path = QtCore.QFileInfo(videoPath) - if media_path.isFile(): - suffix = u'*.%s' % media_path.suffix() - for title in usedBackends: - backend = self.backends[str(title)] - if suffix in backend.video_extensions_list: - if isBackground: - if backend.canBackground: - self.curDisplayMediaController[display] = backend - return True - else: - self.curDisplayMediaController[display] = backend - return True - return False -# # Special FileType Check -# if videoPath.endswith(u'.swf') or isBackground: -# self.curDisplayMediaController[display] = self.backends[u'Webkit'] -# else: -# # search extension in available backends -# # currently only use the first available backend -# self.curDisplayMediaController[display] = self.backends[str(usedBackends[0])] -# return True - - def video_play(self, controller): - """ - Responds to the request to play a loaded video - """ - log.debug(u'video_play') - for display in self.curDisplayMediaController.keys(): - if display.parent == controller: - self.curDisplayMediaController[display].play(display) - # show screen - if not self.Timer.isActive(): - self.Timer.start() - - def video_pause(self, controller): - """ - Responds to the request to pause a loaded video - """ - log.debug(u'videoPause') - for display in self.curDisplayMediaController.keys(): - if display.parent == controller: - self.curDisplayMediaController[display].pause(display) - - def video_stop(self, controller): - """ - Responds to the request to stop a loaded video - """ - log.debug(u'video_stop') - for display in self.curDisplayMediaController.keys(): - if display.parent == controller: - self.curDisplayMediaController[display].stop(display) - self.curDisplayMediaController[display].set_visible(display, False) - - def video_volume(self, msg): - """ - Changes the volume of a running video - """ - controller = msg[0] - volume = msg[1] - log.debug(u'video_volume %d' % volume) - vol = float(volume) / float(10) - for display in self.curDisplayMediaController.keys(): - if display.parent == controller: - self.curDisplayMediaController[display].volume(display, vol) - - def video_finished(self): - """ - Blank the Video when it has finished so the final frame is not left - hanging - """ - display.videoStop() - display.hideDisplay(HideMode.Blank) - display.videoHide = True - - def video_tick(self, tick): - """ - Triggered on video tick every 200 milli seconds - """ - if tick > display.serviceItem.end_time * 1000: - display.videoFinished() - - def video_seek(self, msg): - """ - Responds to the request to change the seek Slider of a loaded video - """ - log.debug(u'video_seek') - controller = msg[0] - seekVal = msg[1] - for display in self.curDisplayMediaController.keys(): - if display.parent == controller: - self.curDisplayMediaController[display].seek(display, seekVal) - - def video_reset(self, controller): - """ - Responds to the request to reset a loaded video - """ - log.debug(u'video_reset') - for display in self.curDisplayMediaController.keys(): - if display.parent == controller: - self.curDisplayMediaController[display].reset(display) - del self.curDisplayMediaController[display] - - def video_hide(self, msg): - """ - Hide the related video Widget - """ - isLive = msg[1] - if isLive: - controller = self.parent.liveController - for display in self.curDisplayMediaController.keys(): - if display.parent == controller: - if self.curDisplayMediaController[display] \ - .state == MediaState.Playing: - self.curDisplayMediaController[display].pause(display) - self.curDisplayMediaController[display] \ - .set_visible(display, False) - - def video_blank(self, msg): - """ - Blank the related video Widget - """ - isLive = msg[1] - if isLive: - controller = self.parent.liveController - for display in self.curDisplayMediaController.keys(): - if display.parent == controller: - if self.curDisplayMediaController[display] \ - .state == MediaState.Playing: - self.curDisplayMediaController[display].pause(display) - self.curDisplayMediaController[display] \ - .set_visible(display, False) - - def video_unblank(self, msg): - """ - Unblank the related video Widget - """ - Receiver.send_message(u'maindisplay_show') - isLive = msg[1] - if isLive: - controller = self.parent.liveController - for display in self.curDisplayMediaController.keys(): - if display.parent == controller: - if self.curDisplayMediaController[display] \ - .state == MediaState.Paused: - self.curDisplayMediaController[display].play(display) - self.curDisplayMediaController[display] \ - .set_visible(display, True) - - def get_audio_extensions_list(self): - audio_list = [] - for backend in self.backends.values(): - for item in backend.audio_extensions_list: - if not item in audio_list: - audio_list.append(item) - return audio_list - - def get_video_extensions_list(self): - video_list = [] - for backend in self.backends.values(): - for item in backend.video_extensions_list: - if not item in video_list: - video_list.append(item) - return video_list diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index 3465e570e..8b48c343c 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -137,7 +137,7 @@ class MediaMediaItem(MediaManagerItem): ItemCapabilities.AllowsVariableStartTime) service_item.title = unicode(self.plugin.nameStrings[u'singular']) service_item.add_capability(ItemCapabilities.RequiresMedia) - #Receiver.send_message(u'media_video', [self.parent.liveController, filename, 0, False]) + #Receiver.send_message(u'media_video', [self.parent.liveController, filename, False]) # force a non-existent theme service_item.theme = -1 frame = u':/media/image_clapperboard.png' diff --git a/openlp/plugins/media/lib/mediamanager.py b/openlp/plugins/media/lib/mediamanager.py new file mode 100644 index 000000000..175eaf6c8 --- /dev/null +++ b/openlp/plugins/media/lib/mediamanager.py @@ -0,0 +1,385 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2011 Raoul Snyman # +# Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael # +# Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, Armin Köhler, # +# Andreas Preikschat, Mattias Põldaru, Christian Richter, Philip Ridout, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### + +import logging + +import sys, os,time +from PyQt4 import QtCore, QtGui, QtWebKit + +from openlp.core.lib import OpenLPToolbar, Receiver, translate +from openlp.core.lib.ui import UiStrings, critical_error_message_box +from openlp.plugins.media.lib import MediaAPI, MediaState, MediaInfo +from webkitapi import WebkitAPI +from phononapi import PhononAPI +from vlcapi import VlcAPI + +log = logging.getLogger(__name__) + +class MediaManager(object): + """ + The implementation of a Media Manager + The idea is to separate the media related implementation + into the plugin files and unify the access from other parts of code + The media manager adds an own class for every API + Currently these are QtWebkit, Phonon and planed Vlc. + Manager + - different API classes with specialised Access functions + + Controller + - have general and API specific control Elements + - have one or more displays (Preview, Live, ...) with different settings + + Display + - have API-Specific Display Elements + - have media info for current media + """ + + def __init__(self, parent): + self.parent = parent + self.APIs = {} + self.controller = [] + self.curDisplayMediaAPI = {} + #Create API Controllers + if WebkitAPI.is_available(): + self.APIs[u'Webkit'] = WebkitAPI(self) + if PhononAPI.is_available(): + self.APIs[u'Phonon'] = PhononAPI(self) + if VlcAPI.is_available(): + self.APIs[u'Vlc'] = VlcAPI(self) + #Timer for video state + self.Timer = QtCore.QTimer() + self.Timer.setInterval(200) + self.withLivePreview = False + #Signals + QtCore.QObject.connect(self.Timer, + QtCore.SIGNAL("timeout()"), self.video_state) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'setup_display'), self.setup_display) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'media_video'), self.video) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'Media Start'), self.video_play) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'Media Pause'), self.video_pause) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'Media Stop'), self.video_stop) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'seekSlider'), self.video_seek) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'volumeSlider'), self.video_volume) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'media_reset'), self.video_reset) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'media_hide'), self.video_hide) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'media_blank'), self.video_blank) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'media_unblank'), self.video_unblank) + + def video_state(self): + """ + Check if there is an assigned media API and do some + updating stuff (e.g. update the UI) + """ + isAnyonePlaying = False + if len(self.curDisplayMediaAPI.keys()) == 0: + self.Timer.stop() + else: + for display in self.curDisplayMediaAPI.keys(): + self.curDisplayMediaAPI[display].update_ui(display) + if self.curDisplayMediaAPI[display] \ + .state == MediaState.Playing: + isAnyonePlaying = True + if not isAnyonePlaying: + self.Timer.stop() + + def addControllerItems(self, controller, control_panel): + self.controller.append(controller) + self.setup_generic_controls(controller, control_panel) + for api in self.APIs.values(): + api.setup_controls(controller, control_panel) + + def setup_generic_controls(self, controller, control_panel): + controller.media_info = MediaInfo() + # Build a Media ToolBar + controller.mediabar = OpenLPToolbar(controller) + controller.mediabar.addToolbarButton( + u'Media Start', u':/slides/media_playback_start.png', + translate('OpenLP.SlideController', 'Start playing media'), + controller.sendToPlugins) + controller.mediabar.addToolbarButton( + u'Media Pause', u':/slides/media_playback_pause.png', + translate('OpenLP.SlideController', 'Start playing media'), + controller.sendToPlugins) + controller.mediabar.addToolbarButton( + u'Media Stop', u':/slides/media_playback_stop.png', + translate('OpenLP.SlideController', 'Start playing media'), + controller.sendToPlugins) + # Build the seekSlider. + controller.seekSlider = QtGui.QSlider(QtCore.Qt.Horizontal) + controller.seekSlider.setMaximum(1000) + # Build the volumeSlider. + controller.volumeSlider = QtGui.QSlider(QtCore.Qt.Horizontal) + controller.volumeSlider.setTickInterval(10) + controller.volumeSlider.setTickPosition(QtGui.QSlider.TicksAbove) + controller.volumeSlider.setMinimum(0) + controller.volumeSlider.setMaximum(100) + controller.volumeSlider.setValue(controller.media_info.volume) + controller.seekSlider.setGeometry(QtCore.QRect(90, 260, 221, 24)) + controller.seekSlider.setObjectName(u'seekSlider') + controller.mediabar.addToolbarWidget(u'Seek Slider', controller.seekSlider) + controller.volumeSlider.setGeometry(QtCore.QRect(90, 160, 221, 24)) + controller.volumeSlider.setObjectName(u'volumeSlider') + controller.mediabar.addToolbarWidget(u'Audio Volume', controller.volumeSlider) + control_panel.addWidget(controller.mediabar) + controller.mediabar.setVisible(False) + #Signals + QtCore.QObject.connect(controller.seekSlider, + QtCore.SIGNAL(u'sliderMoved(int)'), controller.sendToPlugins) + QtCore.QObject.connect(controller.volumeSlider, + QtCore.SIGNAL(u'sliderMoved(int)'), controller.sendToPlugins) + + def setup_display(self, display): + """ + After a new display is configured, all media related widget + will be created too + """ + display.hasAudio = True + if not self.withLivePreview and \ + display == self.parent.liveController.previewDisplay: + return + if display == self.parent.previewController.previewDisplay or \ + display == self.parent.liveController.previewDisplay: + display.hasAudio = False + for api in self.APIs.values(): + api.setup(display) + + def set_controls_visible(self, controller, value): + # Generic controls + controller.mediabar.setVisible(value) + # Special controls +# for api in self.APIs.values(): +# api.setup_controls(controller, control_panel) + + def resize(self, display, api): + """ + After Mainwindow changes or Splitter moved all related media + widgets have to be resized + """ + if display == self.parent.previewController.previewDisplay or \ + display == self.parent.liveController.previewDisplay: + display.resize(display.parent.slidePreview.size()) + api.resize(display) + + def video(self, msg): + """ + Loads and starts a video to run with the option of sound + """ + log.debug(u'video') + controller = msg[0] + isValid = False + # stop running videos + self.video_reset(controller) + controller.media_info = MediaInfo() + controller.media_info.volume = controller.volumeSlider.value() + controller.media_info.file_info = QtCore.QFileInfo(msg[1]) + controller.media_info.is_background = msg[2] + if controller.isLive: + if self.withLivePreview: + display = controller.previewDisplay + isValid = self.check_file_type(display) + display = controller.display + isValid = self.check_file_type(display) + else: + display = controller.previewDisplay + isValid = self.check_file_type(display) + if not isValid: + #Media could not be loaded correctly + critical_error_message_box( + translate('MediaPlugin.MediaItem', 'Unsupported File'), + unicode(translate('MediaPlugin.MediaItem', + 'Unsupported File'))) + return + #now start playing + self.video_play([controller]) +# self.video_pause([controller]) + # self.video_seek([controller, 0]) + # self.video_play([controller]) + self.set_controls_visible(controller, True) + + def check_file_type(self, display): + """ + Used to choose the right media API type + from the prioritized API list + """ + controller = display.parent + apiSettings = str(QtCore.QSettings().value(u'media/apis', + QtCore.QVariant(u'Webkit')).toString()) + usedAPIs = apiSettings.split(u',') + if controller.media_info.file_info.isFile(): + suffix = u'*.%s' % controller.media_info.file_info.suffix() + for title in usedAPIs: + api = self.APIs[title] + if suffix in api.video_extensions_list: + if not controller.media_info.is_background or \ + controller.media_info.is_background and api.canBackground: + self.resize(display, api) + if api.load(display): + print api + self.curDisplayMediaAPI[display] = api + return True + # no valid api found + return False + + def video_play(self, msg): + """ + Responds to the request to play a loaded video + """ + log.debug(u'video_play') + controller = msg[0] + for display in self.curDisplayMediaAPI.keys(): + if display.parent == controller: + self.curDisplayMediaAPI[display].play(display) + # Start Timer for ui updates + if not self.Timer.isActive(): + self.Timer.start() + + def video_pause(self, msg): + """ + Responds to the request to pause a loaded video + """ + log.debug(u'videoPause') + controller = msg[0] + for display in self.curDisplayMediaAPI.keys(): + if display.parent == controller: + self.curDisplayMediaAPI[display].pause(display) + + def video_stop(self, msg): + """ + Responds to the request to stop a loaded video + """ + log.debug(u'video_stop') + controller = msg[0] + for display in self.curDisplayMediaAPI.keys(): + if display.parent == controller: + self.curDisplayMediaAPI[display].stop(display) + self.curDisplayMediaAPI[display].set_visible(display, False) + + def video_volume(self, msg): + """ + Changes the volume of a running video + """ + controller = msg[0] + vol = msg[1] + log.debug(u'video_volume %d' % vol) + for display in self.curDisplayMediaAPI.keys(): + if display.parent == controller: + self.curDisplayMediaAPI[display].volume(display, vol) + + def video_seek(self, msg): + """ + Responds to the request to change the seek Slider of a loaded video + """ + log.debug(u'video_seek') + controller = msg[0] + seekVal = msg[1] + for display in self.curDisplayMediaAPI.keys(): + if display.parent == controller: + self.curDisplayMediaAPI[display].seek(display, seekVal) + + def video_reset(self, controller): + """ + Responds to the request to reset a loaded video + """ + log.debug(u'video_reset') + for display in self.curDisplayMediaAPI.keys(): + if display.parent == controller: + self.curDisplayMediaAPI[display].reset(display) + del self.curDisplayMediaAPI[display] + self.set_controls_visible(controller, False) + + def video_hide(self, msg): + """ + Hide the related video Widget + """ + isLive = msg[1] + if isLive: + controller = self.parent.liveController + for display in self.curDisplayMediaAPI.keys(): + if display.parent == controller: + if self.curDisplayMediaAPI[display] \ + .state == MediaState.Playing: + self.curDisplayMediaAPI[display].pause(display) + self.curDisplayMediaAPI[display] \ + .set_visible(display, False) + + def video_blank(self, msg): + """ + Blank the related video Widget + """ + isLive = msg[1] + if isLive: + controller = self.parent.liveController + for display in self.curDisplayMediaAPI.keys(): + if display.parent == controller: + if self.curDisplayMediaAPI[display] \ + .state == MediaState.Playing: + self.curDisplayMediaAPI[display].pause(display) + self.curDisplayMediaAPI[display] \ + .set_visible(display, False) + + def video_unblank(self, msg): + """ + Unblank the related video Widget + """ + Receiver.send_message(u'maindisplay_show') + isLive = msg[1] + if isLive: + controller = self.parent.liveController + for display in self.curDisplayMediaAPI.keys(): + if display.parent == controller: + if self.curDisplayMediaAPI[display] \ + .state == MediaState.Paused: + self.curDisplayMediaAPI[display].play(display) + self.curDisplayMediaAPI[display] \ + .set_visible(display, True) + + def get_audio_extensions_list(self): + audio_list = [] + for api in self.APIs.values(): + for item in api.audio_extensions_list: + if not item in audio_list: + audio_list.append(item) + return audio_list + + def get_video_extensions_list(self): + video_list = [] + for api in self.APIs.values(): + for item in api.video_extensions_list: + if not item in video_list: + video_list.append(item) + return video_list diff --git a/openlp/plugins/media/lib/mediatab.py b/openlp/plugins/media/lib/mediatab.py index b54a2df6f..4c0bf4f47 100644 --- a/openlp/plugins/media/lib/mediatab.py +++ b/openlp/plugins/media/lib/mediatab.py @@ -38,52 +38,52 @@ class MediaTab(SettingsTab): def setupUi(self): self.setObjectName(u'MediaTab') SettingsTab.setupUi(self) - self.mediaBackendsGroupBox = QtGui.QGroupBox(self.leftColumn) - self.mediaBackendsGroupBox.setObjectName(u'mediaBackendsGroupBox') - self.mediaBackendLayout = QtGui.QVBoxLayout(self.mediaBackendsGroupBox) - self.mediaBackendLayout.setObjectName(u'mediaBackendLayout') - self.usePhononCheckBox = QtGui.QCheckBox(self.mediaBackendsGroupBox) + self.mediaAPIsGroupBox = QtGui.QGroupBox(self.leftColumn) + self.mediaAPIsGroupBox.setObjectName(u'mediaAPIsGroupBox') + self.mediaApiLayout = QtGui.QVBoxLayout(self.mediaAPIsGroupBox) + self.mediaApiLayout.setObjectName(u'mediaApiLayout') + self.usePhononCheckBox = QtGui.QCheckBox(self.mediaAPIsGroupBox) self.usePhononCheckBox.setObjectName(u'usePhononCheckBox') - self.mediaBackendLayout.addWidget(self.usePhononCheckBox) - self.useVlcCheckBox = QtGui.QCheckBox(self.mediaBackendsGroupBox) + self.mediaApiLayout.addWidget(self.usePhononCheckBox) + self.useVlcCheckBox = QtGui.QCheckBox(self.mediaAPIsGroupBox) self.useVlcCheckBox.setObjectName(u'useVlcCheckBox') - self.mediaBackendLayout.addWidget(self.useVlcCheckBox) - self.leftLayout.addWidget(self.mediaBackendsGroupBox) + self.mediaApiLayout.addWidget(self.useVlcCheckBox) + self.leftLayout.addWidget(self.mediaAPIsGroupBox) - self.backendOrderGroupBox = QtGui.QGroupBox(self.leftColumn) - self.backendOrderGroupBox.setObjectName(u'backendOrderGroupBox') - self.backendOrderLayout = QtGui.QVBoxLayout(self.backendOrderGroupBox) - self.backendOrderLayout.setObjectName(u'backendOrderLayout') - self.backendOrderlistWidget = QtGui.QListWidget( \ - self.backendOrderGroupBox) + self.apiOrderGroupBox = QtGui.QGroupBox(self.leftColumn) + self.apiOrderGroupBox.setObjectName(u'apiOrderGroupBox') + self.apiOrderLayout = QtGui.QVBoxLayout(self.apiOrderGroupBox) + self.apiOrderLayout.setObjectName(u'apiOrderLayout') + self.apiOrderlistWidget = QtGui.QListWidget( \ + self.apiOrderGroupBox) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.backendOrderlistWidget. \ + sizePolicy.setHeightForWidth(self.apiOrderlistWidget. \ sizePolicy().hasHeightForWidth()) - self.backendOrderlistWidget.setSizePolicy(sizePolicy) + self.apiOrderlistWidget.setSizePolicy(sizePolicy) - self.backendOrderlistWidget.setVerticalScrollBarPolicy( \ + self.apiOrderlistWidget.setVerticalScrollBarPolicy( \ QtCore.Qt.ScrollBarAsNeeded) - self.backendOrderlistWidget.setHorizontalScrollBarPolicy( \ + self.apiOrderlistWidget.setHorizontalScrollBarPolicy( \ QtCore.Qt.ScrollBarAlwaysOff) - self.backendOrderlistWidget.setEditTriggers( \ + self.apiOrderlistWidget.setEditTriggers( \ QtGui.QAbstractItemView.NoEditTriggers) - self.backendOrderlistWidget.setObjectName(u'backendOrderlistWidget') - self.backendOrderLayout.addWidget(self.backendOrderlistWidget) - self.orderingButtonsWidget = QtGui.QWidget(self.backendOrderGroupBox) + self.apiOrderlistWidget.setObjectName(u'apiOrderlistWidget') + self.apiOrderLayout.addWidget(self.apiOrderlistWidget) + self.orderingButtonsWidget = QtGui.QWidget(self.apiOrderGroupBox) self.orderingButtonsWidget.setObjectName(u'orderingButtonsWidget') self.orderingButtonLayout = QtGui.QHBoxLayout(self.orderingButtonsWidget) self.orderingButtonLayout.setObjectName(u'orderingButtonLayout') self.orderingDownButton = QtGui.QPushButton(self.orderingButtonsWidget) self.orderingDownButton.setObjectName(u'orderingDownButton') self.orderingButtonLayout.addWidget(self.orderingDownButton) - self.orderingUpButton = QtGui.QPushButton(self.backendOrderGroupBox) + self.orderingUpButton = QtGui.QPushButton(self.apiOrderGroupBox) self.orderingUpButton.setObjectName(u'orderingUpButton') self.orderingButtonLayout.addWidget(self.orderingUpButton) - self.backendOrderLayout.addWidget(self.orderingButtonsWidget) - self.leftLayout.addWidget(self.backendOrderGroupBox) + self.apiOrderLayout.addWidget(self.orderingButtonsWidget) + self.leftLayout.addWidget(self.apiOrderGroupBox) self.leftLayout.addStretch() self.rightLayout.addStretch() QtCore.QObject.connect(self.usePhononCheckBox, @@ -98,14 +98,14 @@ class MediaTab(SettingsTab): QtCore.SIGNAL(u'pressed()'), self.onOrderingDownButtonPressed) def retranslateUi(self): - self.mediaBackendsGroupBox.setTitle( - translate('MediaPlugin.MediaTab', 'Media Backends')) + self.mediaAPIsGroupBox.setTitle( + translate('MediaPlugin.MediaTab', 'Media APIs')) self.usePhononCheckBox.setText( translate('MediaPlugin.MediaTab', 'use Phonon')) self.useVlcCheckBox.setText( translate('MediaPlugin.MediaTab', 'use Vlc')) - self.backendOrderGroupBox.setTitle( - translate('MediaPlugin.MediaTab', 'Backends Order')) + self.apiOrderGroupBox.setTitle( + translate('MediaPlugin.MediaTab', 'API Order')) self.orderingDownButton.setText( translate('MediaPlugin.MediaTab', 'Down')) self.orderingUpButton.setText( @@ -114,61 +114,61 @@ class MediaTab(SettingsTab): def onUsePhononCheckBoxChanged(self, check_state): if check_state == QtCore.Qt.Checked: self.usePhonon = True - if u'Phonon' not in self.usedBackends: - self.usedBackends.append(u'Phonon') + if u'Phonon' not in self.usedAPIs: + self.usedAPIs.append(u'Phonon') else: self.usePhonon = False - self.usedBackends.takeAt(self.usedBackends.indexOf(u'Phonon')) - self.updateBackendList() + self.usedAPIs.takeAt(self.usedAPIs.indexOf(u'Phonon')) + self.updateApiList() def onUseVlcCheckBoxChanged(self, check_state): if check_state == QtCore.Qt.Checked: self.useVlc = True - if u'Vlc' not in self.usedBackends: - self.usedBackends.append(u'Vlc') + if u'Vlc' not in self.usedAPIs: + self.usedAPIs.append(u'Vlc') else: self.useVlc = False - self.usedBackends.takeAt(self.usedBackends.indexOf(u'Vlc')) - self.updateBackendList() + self.usedAPIs.takeAt(self.usedAPIs.indexOf(u'Vlc')) + self.updateApiList() - def updateBackendList(self): - self.backendOrderlistWidget.clear() - for backend in self.usedBackends: - self.backendOrderlistWidget.addItem(backend) + def updateApiList(self): + self.apiOrderlistWidget.clear() + for api in self.usedAPIs: + self.apiOrderlistWidget.addItem(api) def onOrderingUpButtonPressed(self): - currentRow = self.backendOrderlistWidget.currentRow() + currentRow = self.apiOrderlistWidget.currentRow() if currentRow > 0: - item = self.backendOrderlistWidget.takeItem(currentRow) - self.backendOrderlistWidget.insertItem(currentRow-1, item) - self.backendOrderlistWidget.setCurrentRow(currentRow-1) - self.usedBackends.move(currentRow, currentRow-1) + item = self.apiOrderlistWidget.takeItem(currentRow) + self.apiOrderlistWidget.insertItem(currentRow-1, item) + self.apiOrderlistWidget.setCurrentRow(currentRow-1) + self.usedAPIs.move(currentRow, currentRow-1) def onOrderingDownButtonPressed(self): - currentRow = self.backendOrderlistWidget.currentRow() - if currentRow < self.backendOrderlistWidget.count()-1: - item = self.backendOrderlistWidget.takeItem(currentRow) - self.backendOrderlistWidget.insertItem(currentRow+1, item) - self.backendOrderlistWidget.setCurrentRow(currentRow+1) - self.usedBackends.move(currentRow, currentRow+1) + currentRow = self.apiOrderlistWidget.currentRow() + if currentRow < self.apiOrderlistWidget.count()-1: + item = self.apiOrderlistWidget.takeItem(currentRow) + self.apiOrderlistWidget.insertItem(currentRow+1, item) + self.apiOrderlistWidget.setCurrentRow(currentRow+1) + self.usedAPIs.move(currentRow, currentRow+1) def load(self): - self.usedBackends = QtCore.QSettings().value( - self.settingsSection + u'/backends', + self.usedAPIs = QtCore.QSettings().value( + self.settingsSection + u'/apis', QtCore.QVariant(u'Webkit')).toString().split(u',') - self.useWebkit = u'Webkit' in self.usedBackends - self.usePhonon = u'Phonon' in self.usedBackends - self.useVlc = u'Vlc' in self.usedBackends + self.useWebkit = u'Webkit' in self.usedAPIs + self.usePhonon = u'Phonon' in self.usedAPIs + self.useVlc = u'Vlc' in self.usedAPIs self.usePhononCheckBox.setChecked(self.usePhonon) self.useVlcCheckBox.setChecked(self.useVlc) - self.updateBackendList() + self.updateApiList() def save(self): - oldBackendString = QtCore.QSettings().value( - self.settingsSection + u'/backends', + oldApiString = QtCore.QSettings().value( + self.settingsSection + u'/apis', QtCore.QVariant(u'Webkit')).toString() - newBackendString = self.usedBackends.join(u',') - if oldBackendString != newBackendString: - QtCore.QSettings().setValue(self.settingsSection + u'/backends', - QtCore.QVariant(newBackendString)) + newApiString = self.usedAPIs.join(u',') + if oldApiString != newApiString: + QtCore.QSettings().setValue(self.settingsSection + u'/apis', + QtCore.QVariant(newApiString)) Receiver.send_message(u'config_screen_changed') diff --git a/openlp/plugins/media/lib/phononcontroller.py b/openlp/plugins/media/lib/phononapi.py similarity index 85% rename from openlp/plugins/media/lib/phononcontroller.py rename to openlp/plugins/media/lib/phononapi.py index 3c0062464..fa7c25714 100644 --- a/openlp/plugins/media/lib/phononcontroller.py +++ b/openlp/plugins/media/lib/phononapi.py @@ -33,18 +33,18 @@ from PyQt4 import QtCore, QtGui from PyQt4.phonon import Phonon from openlp.core.lib import Receiver -from openlp.plugins.media.lib import MediaController, MediaState +from openlp.plugins.media.lib import MediaAPI, MediaState log = logging.getLogger(__name__) -class PhononController(MediaController): +class PhononAPI(MediaAPI): """ - Specialiced MediaController class - to reflect Features of the Phonon backend + Specialiced MediaAPI class + to reflect Features of the Phonon API """ def __init__(self, parent): - MediaController.__init__(self, parent) + MediaAPI.__init__(self, parent) self.parent = parent self.additional_extensions = { u'audio/ac3': [u'.ac3'], @@ -59,6 +59,7 @@ class PhononController(MediaController): u'video/x-flv': [u'.flv'], u'video/x-matroska': [u'.mpv', u'.mkv'], u'video/x-wmv': [u'.wmv'], + u'video/x-mpg': [u'.mpg'], u'video/x-ms-wmv': [u'.wmv']} mimetypes.init() for mimetype in Phonon.BackendCapabilities.availableMimeTypes(): @@ -90,7 +91,10 @@ class PhononController(MediaController): log.info(u'MediaPlugin: %s additional extensions: %s' % (mimetype, u' '.join(self.additional_extensions[mimetype]))) - def setup(self, display, hasAudio): + def setup_controls(self, controller, control_panel): + pass + + def setup(self, display): display.phononWidget = Phonon.VideoWidget(display) display.phononWidget.setVisible(False) display.phononWidget.resize(display.size()) @@ -126,13 +130,18 @@ class PhononController(MediaController): u'video/x-wmv': [u'.wmv'], u'video/x-ms-wmv': [u'.wmv']} - def load(self, display, path, volume, isBackground): + def load(self, display): log.debug(u'load vid in Phonon Controller') + controller = display.parent + volume = controller.media_info.volume + path = controller.media_info.file_info.absoluteFilePath() display.mediaObject.setCurrentSource(Phonon.MediaSource(path)) if not self.mediaStateWait(display, Phonon.StoppedState): return False vol = float(volume) / float(10) display.audio.setVolume(vol) + #self.info.start_time = 10000 + #self.info.end_time = 20000 return True def mediaStateWait(self, display, mediaState): @@ -149,12 +158,13 @@ class PhononController(MediaController): return False return True - def resize(self, display, controller): + def resize(self, display): display.phononWidget.resize(display.size()) def play(self, display): - self.set_visible(display, True) - vol = float(display.parent.volume) / float(10) + #self.set_visible(display, True) + controller = display.parent + vol = float(controller.media_info.volume) / float(10) display.audio.setVolume(vol) display.mediaObject.play() self.state = MediaState.Playing @@ -168,6 +178,8 @@ class PhononController(MediaController): self.state = MediaState.Stopped def volume(self, display, vol): + # 1.0 is the highest value + vol = float(vol) / float(100) display.audio.setVolume(vol) def seek(self, display, seekVal): @@ -183,16 +195,20 @@ class PhononController(MediaController): if self.hasOwnWidget: display.phononWidget.setVisible(status) - def update_ui(self, controller, display): - controller.seekSlider.setMaximum(display.mediaObject.totalTime()) - if display.serviceItem.end_time > 0: - if display.mediaObject.currentTime() > \ - display.serviceItem.end_time: - self.stop(display) - if display.serviceItem.start_time > 0: + def update_ui(self, display): + controller = display.parent + controller.media_info.length = display.mediaObject.totalTime() + controller.seekSlider.setMaximum(controller.media_info.length) + if controller.media_info.start_time > 0: if display.mediaObject.currentTime() < \ - display.serviceItem.start_time: - self.seek(display, self.serviceItem.start_time * 1000) + controller.media_info.start_time: + self.seek(display, controller.media_info.start_time) + self.set_visible(display, True) + if controller.media_info.end_time > 0: + if display.mediaObject.currentTime() > \ + controller.media_info.end_time: + self.stop(display) + self.set_visible(display, False) if not controller.seekSlider.isSliderDown(): controller.seekSlider.setSliderPosition( \ display.mediaObject.currentTime()) diff --git a/openlp/plugins/media/lib/vlc.py b/openlp/plugins/media/lib/vlc.py index 52526e953..1b6510993 100644 --- a/openlp/plugins/media/lib/vlc.py +++ b/openlp/plugins/media/lib/vlc.py @@ -39,6 +39,7 @@ C{get_instance} method of L{MediaPlayer} and L{MediaListPlayer}. """ import ctypes +from ctypes.util import find_library import os import sys @@ -46,20 +47,20 @@ import sys from inspect import getargspec __version__ = "N/A" -build_date = "Tue Mar 29 12:44:43 2011" +build_date = "Wed May 18 15:32:47 2011" # Used on win32 and MacOS in override.py plugin_path = None if sys.platform.startswith('linux'): + p = find_library('vlc') try: - dll = ctypes.CDLL('libvlc.so') + dll = ctypes.CDLL(p) except OSError: # may fail dll = ctypes.CDLL('libvlc.so.5') elif sys.platform.startswith('win'): - import ctypes.util as u - p = u.find_library('libvlc.dll') + p = find_library('libvlc.dll') if p is None: try: # some registry settings import _winreg as w # leaner than win32api, win32con @@ -94,7 +95,7 @@ elif sys.platform.startswith('win'): else: plugin_path = os.path.dirname(p) dll = ctypes.CDLL(p) - del p, u + del p#, u elif sys.platform.startswith('darwin'): # FIXME: should find a means to configure path @@ -122,16 +123,30 @@ try: except NameError: # no long in Python 3+ _Ints = int +# Default instance. It is used to instanciate classes directly in the +# OO-wrapper. +_default_instance = None + +def get_default_instance(): + """Return the default VLC.Instance. + """ + global _default_instance + if _default_instance is None: + _default_instance = Instance() + return _default_instance + _Seqs = (list, tuple) _Cfunctions = {} # from LibVLC __version__ -def _Cfunction(name, flags, *types): +def _Cfunction(name, flags, errcheck, *types): """(INTERNAL) New ctypes function binding. """ if hasattr(dll, name): p = ctypes.CFUNCTYPE(*types) f = p((name, dll), flags) + if errcheck is not None: + f.errcheck = errcheck _Cfunctions[name] = f return f raise NameError('no function %r' % (name,)) @@ -143,7 +158,7 @@ def _Cobject(cls, ctype): o._as_parameter_ = ctype return o -def _Constructor(cls, ptr): +def _Constructor(cls, ptr=None): """(INTERNAL) New wrapper from ctypes. """ if ptr is None: @@ -171,6 +186,27 @@ class ListPOINTER(object): if isinstance(param, _Seqs): return (self.etype * len(param))(*param) +# errcheck functions for some native functions. +def string_result(result, func, arguments): + """Errcheck function. Returns a string and frees the original pointer. + + It assumes the result is a char *. + """ + if result: + # make a python string copy + s = ctypes.string_at(result) + # free original string ptr + libvlc_free(result) + return s + return None + +def class_result(classname): + """Errcheck function. Returns a function that creates the specified class. + """ + def wrap_errcheck(result, func, arguments): + return classname(result) + return wrap_errcheck + # Generated enum types # class _Enum(ctypes.c_ulong): @@ -739,7 +775,7 @@ class EventManager(_Ctype): @note: Only a single notification can be registered for each event type in an EventManager instance. - + ''' _callback_handler = None @@ -750,7 +786,7 @@ class EventManager(_Ctype): raise VLCException("(INTERNAL) ctypes class.") if ptr == 0: return None - return _Cobject(cls, ptr) # ctypes.c_void_p(ptr) + return _Constructor(cls, ptr) def event_attach(self, eventtype, callback, *args, **kwds): """Register an event notification. @@ -809,7 +845,7 @@ class EventManager(_Ctype): k = eventtype.value if k in self._callbacks: del self._callbacks[k] # remove, regardless of libvlc return value - libvlc_event_detach(self, eventtype, self._callback_handler, k) + libvlc_event_detach(self, k, self._callback_handler, k) class Instance(_Ctype): '''Create a new Instance instance. @@ -818,7 +854,7 @@ class Instance(_Ctype): - a string - a list of strings as first parameters - the parameters given as the constructor parameters (must be strings) - + ''' def __new__(cls, *args): @@ -827,7 +863,7 @@ class Instance(_Ctype): if i == 0: return None if isinstance(i, _Ints): - return _Cobject(cls, ctypes.c_void_p(i)) + return _Constructor(cls, i) if len(args) == 1: if isinstance(i, basestring): args = i.strip().split() @@ -876,8 +912,22 @@ class Instance(_Ctype): m = libvlc_media_new_location(self, mrl) for o in options: libvlc_media_add_option(m, o) + m._instance = self return m + def media_list_new(self, mrls=None): + """Create a new MediaList instance. + @param mrls: optional list of MRL strings + """ + l = libvlc_media_list_new(self) + # We should take the lock, but since we did not leak the + # reference, nobody else can access it. + if mrls: + for m in mrls: + l.add_media(m) + l._instance = self + return l + def audio_output_enumerate_devices(self): """Enumerate the defined audio output devices. @@ -1030,12 +1080,6 @@ class Instance(_Ctype): ''' return libvlc_media_library_new(self) - def media_list_new(self): - '''Create an empty media list. - @return: empty media list, or NULL on error. - ''' - return libvlc_media_list_new(self) - def audio_output_list_get(self): '''Get the list of available audio outputs. @return: list of available audio outputs. It must be freed it with In case of error, NULL is returned. @@ -1277,7 +1321,7 @@ class Instance(_Ctype): class Log(_Ctype): '''Create a new VLC log instance. - + ''' def __new__(cls, ptr=None): @@ -1321,7 +1365,7 @@ class Log(_Ctype): class LogIterator(_Ctype): '''Create a new VLC log iterator. - + ''' def __new__(cls, ptr=None): @@ -1353,14 +1397,28 @@ class LogIterator(_Ctype): class Media(_Ctype): '''Create a new Media instance. - + + Usage: Media(MRL, *options) + + See vlc.Instance.media_new documentation for details. + ''' - def __new__(cls, ptr=None): - '''(INTERNAL) ctypes wrapper constructor. - ''' - return _Constructor(cls, ptr) + def __new__(cls, *args): + if args: + i = args[0] + if i == 0: + return None + if isinstance(i, _Ints): + return _Constructor(cls, i) + if isinstance(i, Instance): + return i.media_new(*args[1:]) + o = get_default_instance().media_new(*args) + return o + + def get_instance(self): + return getattr(self, '_instance', None) def add_options(self, *options): """Add a list of options to the media. @@ -1537,7 +1595,8 @@ class Media(_Ctype): Note, you need to call L{parse}() or play the media at least once before calling this function. Not doing this will result in an empty array. - @param tracks: address to store an allocated array of Elementary Streams descriptions (must be freed by the caller) [OUT] return the number of Elementary Streams. + @param tracks: address to store an allocated array of Elementary Streams descriptions (must be freed by the caller). + @return: the number of Elementary Streams. ''' return libvlc_media_get_tracks_info(self) @@ -1620,13 +1679,48 @@ class MediaLibrary(_Ctype): return libvlc_media_library_media_list(self) class MediaList(_Ctype): - '''N/A + '''Create a new MediaList instance. + + Usage: MediaList(list_of_MRLs) + + See vlc.Instance.media_list_new documentation for details. + ''' - def __new__(cls, ptr=None): - '''(INTERNAL) ctypes wrapper constructor. - ''' - return _Constructor(cls, ptr) + def __new__(cls, *args): + if args: + i = args[0] + if i == 0: + return None + if isinstance(i, _Ints): + return _Constructor(cls, i) + if isinstance(i, Instance): + return i.media_list_new(*args[1:]) + + o = get_default_instance().media_list_new(*args) + return o + + def get_instance(self): + return getattr(self, '_instance', None) + + def add_media(self, mrl): + """Add media instance to media list. + + The L{lock} should be held upon entering this function. + @param p_md: a media instance or a MRL. + @return: 0 on success, -1 if the media list is read-only. + """ + if isinstance(mrl, basestring): + mrl = (self.get_instance() or get_default_instance()).media_new(mrl) + return libvlc_media_list_add_media(self, mrl) + + def __len__(self): + return self.count() + + def __getitem__(self, i): + return self.item_at_index(i) + + def release(self): '''Release media list created with L{new}(). ''' @@ -1653,14 +1747,6 @@ class MediaList(_Ctype): ''' return libvlc_media_list_media(self) - def add_media(self, p_md): - '''Add media instance to media list - The L{lock} should be held upon entering this function. - @param p_md: a media instance. - @return: 0 on success, -1 if the media list is read-only. - ''' - return libvlc_media_list_add_media(self, p_md) - def insert_media(self, p_md, i_pos): '''Insert media instance in media list on a position The L{lock} should be held upon entering this function. @@ -1742,7 +1828,7 @@ class MediaListPlayer(_Ctype): It may take as parameter either: - a vlc.Instance - nothing - + ''' def __new__(cls, *args): @@ -1751,14 +1837,14 @@ class MediaListPlayer(_Ctype): if i == 0: return None if isinstance(i, _Ints): - return _Cobject(cls, ctypes.c_void_p(i)) + return _Constructor(cls, i) if isinstance(i, _Seqs): args = i if args and isinstance(args[0], Instance): i = args[0] else: - i = Instance() + i = get_default_instance() return i.media_list_player_new() def get_instance(self): @@ -1862,7 +1948,7 @@ class MediaPlayer(_Ctype): It may take as parameter either: - a string (media URI). In this case, a vlc.Instance will be created. - a vlc.Instance - + ''' def __new__(cls, *args): @@ -1871,11 +1957,11 @@ class MediaPlayer(_Ctype): if i == 0: return None if isinstance(i, _Ints): - return _Cobject(cls, ctypes.c_void_p(i)) + return _Constructor(cls, i) if isinstance(i, Instance): return i.media_player_new() - i = Instance() + i = get_default_instance() o = i.media_player_new() if args: o.set_media(i.media_new(*args)) # args[0] @@ -1935,6 +2021,19 @@ class MediaPlayer(_Ctype): else: raise VLCException('invalid video number (%s)' % (num,)) + def set_hwnd(self, drawable): + """Set a Win32/Win64 API window handle (HWND). + + Specify where the media player should render its video + output. If LibVLC was built without Win32/Win64 API output + support, then this has no effects. + + @param drawable: windows handle of the drawable. + """ + if not isinstance(drawable, ctypes.c_void_p): + drawable = ctypes.c_void_p(int(drawable)) + libvlc_media_player_set_hwnd(self, drawable) + def video_get_width(self, num=0): """Get the width of a video in pixels. @@ -2065,12 +2164,12 @@ class MediaPlayer(_Ctype): If you want to use it along with Qt4 see the QMacCocoaViewContainer. Then the following code should work: @begincode - + NSView *video = [[NSView alloc] init]; QMacCocoaViewContainer *container = new QMacCocoaViewContainer(video, parent); L{set_nsobject}(mp, video); [video release]; - + @endcode You can find a live example in VLCVideoView in VLCKit.framework. @param drawable: the drawable that is either an NSView or an object following the VLCOpenGLVideoViewEmbedding protocol. @@ -2117,14 +2216,6 @@ class MediaPlayer(_Ctype): ''' return libvlc_media_player_get_xwindow(self) - def set_hwnd(self, drawable): - '''Set a Win32/Win64 API window handle (HWND) where the media player should - render its video output. If LibVLC was built without Win32/Win64 API output - support, then this has no effects. - @param drawable: windows handle of the drawable. - ''' - return libvlc_media_player_set_hwnd(self, drawable) - def get_hwnd(self): '''Get the Windows API window handle (HWND) previously set with L{set_hwnd}(). The handle will be returned even if LibVLC @@ -2133,6 +2224,17 @@ class MediaPlayer(_Ctype): ''' return libvlc_media_player_get_hwnd(self) + def audio_set_format(self, format, rate, channels): + '''Set decoded audio format. + This only works in combination with libvlc_audio_set_callbacks(), + and is mutually exclusive with libvlc_audio_set_format_callbacks(). + @param fourcc: a four-characters string identifying the sample format (e.g. "S16N" or "FL32"). + @param rate: sample rate (expressed in Hz). + @param channels: channels count. + @version: LibVLC 1.2.0 or later. + ''' + return libvlc_audio_set_format(self, format, rate, channels) + def get_length(self): '''Get the current movie length (in ms). @return: the movie length (in ms), or -1 if there is no media. @@ -2652,7 +2754,7 @@ def libvlc_errmsg(): This will be NULL if there was no error. ''' f = _Cfunctions.get('libvlc_errmsg', None) or \ - _Cfunction('libvlc_errmsg', (), + _Cfunction('libvlc_errmsg', (), None, ctypes.c_char_p) if not __debug__: # i.e. python -O or -OO global libvlc_errmsg @@ -2665,7 +2767,7 @@ def libvlc_clearerr(): occurs, and destroyed when the thread exits. ''' f = _Cfunctions.get('libvlc_clearerr', None) or \ - _Cfunction('libvlc_clearerr', (), + _Cfunction('libvlc_clearerr', (), None, None) if not __debug__: # i.e. python -O or -OO global libvlc_clearerr @@ -2682,35 +2784,20 @@ def libvlc_new(argc, argv): @version Arguments are meant to be passed from the command line to LibVLC, just like VLC media player does. The list of valid arguments depends on the LibVLC version, the operating system and platform, and set of available LibVLC plugins. Invalid or unsupported arguments will cause the function to fail (i.e. return NULL). Also, some arguments may alter the behaviour or otherwise interfere with other LibVLC functions. @warning There is absolutely no warranty or promise of forward, backward and cross-platform compatibility with regards to L{libvlc_new}() arguments. We recommend that you do not use them, other than when debugging. ''' f = _Cfunctions.get('libvlc_new', None) or \ - _Cfunction('libvlc_new', ((1,), (1,),), - Instance, ctypes.c_int, ListPOINTER(ctypes.c_char_p)) + _Cfunction('libvlc_new', ((1,), (1,),), class_result(Instance), + ctypes.c_void_p, ctypes.c_int, ListPOINTER(ctypes.c_char_p)) if not __debug__: # i.e. python -O or -OO global libvlc_new libvlc_new = f return f(argc, argv) -def libvlc_new_with_builtins(argc, argv, builtins): - '''Create and initialize a libvlc instance. - @param argc: the number of arguments. - @param argv: command-line-type arguments. - @param builtins: a NULL terminated array of See vlc_plugin. - @return: the libvlc instance or NULL in case of error @begincode vlc_declare_plugin(mp4); vlc_declare_plugin(dummy); const void **builtins = vlc_plugin(mp4), vlc_plugin(dummy), NULL ; L{Instance} *vlc = L{libvlc_new_with_builtins}(argc, argv, builtins); @endcode. - ''' - f = _Cfunctions.get('libvlc_new_with_builtins', None) or \ - _Cfunction('libvlc_new_with_builtins', ((1,), (1,), (1,),), - Instance, ctypes.c_int, ListPOINTER(ctypes.c_char_p), ListPOINTER(ctypes.c_void_p)) - if not __debug__: # i.e. python -O or -OO - global libvlc_new_with_builtins - libvlc_new_with_builtins = f - return f(argc, argv, builtins) - def libvlc_release(p_instance): '''Decrement the reference count of a libvlc instance, and destroy it if it reaches zero. @param p_instance: the instance to destroy. ''' f = _Cfunctions.get('libvlc_release', None) or \ - _Cfunction('libvlc_release', ((1,),), + _Cfunction('libvlc_release', ((1,),), None, None, Instance) if not __debug__: # i.e. python -O or -OO global libvlc_release @@ -2723,7 +2810,7 @@ def libvlc_retain(p_instance): @param p_instance: the instance to reference. ''' f = _Cfunctions.get('libvlc_retain', None) or \ - _Cfunction('libvlc_retain', ((1,),), + _Cfunction('libvlc_retain', ((1,),), None, None, Instance) if not __debug__: # i.e. python -O or -OO global libvlc_retain @@ -2737,7 +2824,7 @@ def libvlc_add_intf(p_instance, name): @return: 0 on success, -1 on error. ''' f = _Cfunctions.get('libvlc_add_intf', None) or \ - _Cfunction('libvlc_add_intf', ((1,), (1,),), + _Cfunction('libvlc_add_intf', ((1,), (1,),), None, ctypes.c_int, Instance, ctypes.c_char_p) if not __debug__: # i.e. python -O or -OO global libvlc_add_intf @@ -2750,7 +2837,7 @@ def libvlc_wait(p_instance): @param p_instance: the instance. ''' f = _Cfunctions.get('libvlc_wait', None) or \ - _Cfunction('libvlc_wait', ((1,),), + _Cfunction('libvlc_wait', ((1,),), None, None, Instance) if not __debug__: # i.e. python -O or -OO global libvlc_wait @@ -2766,7 +2853,7 @@ def libvlc_set_user_agent(p_instance, name, http): @version: LibVLC 1.1.1 or later. ''' f = _Cfunctions.get('libvlc_set_user_agent', None) or \ - _Cfunction('libvlc_set_user_agent', ((1,), (1,), (1,),), + _Cfunction('libvlc_set_user_agent', ((1,), (1,), (1,),), None, None, Instance, ctypes.c_char_p, ctypes.c_char_p) if not __debug__: # i.e. python -O or -OO global libvlc_set_user_agent @@ -2779,7 +2866,7 @@ def libvlc_get_version(): @return: a string containing the libvlc version. ''' f = _Cfunctions.get('libvlc_get_version', None) or \ - _Cfunction('libvlc_get_version', (), + _Cfunction('libvlc_get_version', (), None, ctypes.c_char_p) if not __debug__: # i.e. python -O or -OO global libvlc_get_version @@ -2792,7 +2879,7 @@ def libvlc_get_compiler(): @return: a string containing the libvlc compiler version. ''' f = _Cfunctions.get('libvlc_get_compiler', None) or \ - _Cfunction('libvlc_get_compiler', (), + _Cfunction('libvlc_get_compiler', (), None, ctypes.c_char_p) if not __debug__: # i.e. python -O or -OO global libvlc_get_compiler @@ -2805,7 +2892,7 @@ def libvlc_get_changeset(): @return: a string containing the libvlc changeset. ''' f = _Cfunctions.get('libvlc_get_changeset', None) or \ - _Cfunction('libvlc_get_changeset', (), + _Cfunction('libvlc_get_changeset', (), None, ctypes.c_char_p) if not __debug__: # i.e. python -O or -OO global libvlc_get_changeset @@ -2819,7 +2906,7 @@ def libvlc_free(ptr): @param ptr: the pointer. ''' f = _Cfunctions.get('libvlc_free', None) or \ - _Cfunction('libvlc_free', ((1,),), + _Cfunction('libvlc_free', ((1,),), None, None, ctypes.c_void_p) if not __debug__: # i.e. python -O or -OO global libvlc_free @@ -2835,7 +2922,7 @@ def libvlc_event_attach(p_event_manager, i_event_type, f_callback, user_data): @return: 0 on success, ENOMEM on error. ''' f = _Cfunctions.get('libvlc_event_attach', None) or \ - _Cfunction('libvlc_event_attach', ((1,), (1,), (1,), (1,),), + _Cfunction('libvlc_event_attach', ((1,), (1,), (1,), (1,),), None, ctypes.c_int, EventManager, ctypes.c_uint, ctypes.c_void_p, ctypes.c_void_p) if not __debug__: # i.e. python -O or -OO global libvlc_event_attach @@ -2850,7 +2937,7 @@ def libvlc_event_detach(p_event_manager, i_event_type, f_callback, p_user_data): @param p_user_data: user provided data to carry with the event. ''' f = _Cfunctions.get('libvlc_event_detach', None) or \ - _Cfunction('libvlc_event_detach', ((1,), (1,), (1,), (1,),), + _Cfunction('libvlc_event_detach', ((1,), (1,), (1,), (1,),), None, None, EventManager, ctypes.c_uint, ctypes.c_void_p, ctypes.c_void_p) if not __debug__: # i.e. python -O or -OO global libvlc_event_detach @@ -2862,7 +2949,7 @@ def libvlc_event_type_name(event_type): @param event_type: the desired event. ''' f = _Cfunctions.get('libvlc_event_type_name', None) or \ - _Cfunction('libvlc_event_type_name', ((1,),), + _Cfunction('libvlc_event_type_name', ((1,),), None, ctypes.c_char_p, ctypes.c_uint) if not __debug__: # i.e. python -O or -OO global libvlc_event_type_name @@ -2875,7 +2962,7 @@ def libvlc_get_log_verbosity(p_instance): @return: verbosity level for messages. ''' f = _Cfunctions.get('libvlc_get_log_verbosity', None) or \ - _Cfunction('libvlc_get_log_verbosity', ((1,),), + _Cfunction('libvlc_get_log_verbosity', ((1,),), None, ctypes.c_uint, Instance) if not __debug__: # i.e. python -O or -OO global libvlc_get_log_verbosity @@ -2888,7 +2975,7 @@ def libvlc_set_log_verbosity(p_instance, level): @param level: log level. ''' f = _Cfunctions.get('libvlc_set_log_verbosity', None) or \ - _Cfunction('libvlc_set_log_verbosity', ((1,), (1,),), + _Cfunction('libvlc_set_log_verbosity', ((1,), (1,),), None, None, Instance, ctypes.c_uint) if not __debug__: # i.e. python -O or -OO global libvlc_set_log_verbosity @@ -2901,8 +2988,8 @@ def libvlc_log_open(p_instance): @return: log message instance or NULL on error. ''' f = _Cfunctions.get('libvlc_log_open', None) or \ - _Cfunction('libvlc_log_open', ((1,),), - Log, Instance) + _Cfunction('libvlc_log_open', ((1,),), class_result(Log), + ctypes.c_void_p, Instance) if not __debug__: # i.e. python -O or -OO global libvlc_log_open libvlc_log_open = f @@ -2913,7 +3000,7 @@ def libvlc_log_close(p_log): @param p_log: libvlc log instance or NULL. ''' f = _Cfunctions.get('libvlc_log_close', None) or \ - _Cfunction('libvlc_log_close', ((1,),), + _Cfunction('libvlc_log_close', ((1,),), None, None, Log) if not __debug__: # i.e. python -O or -OO global libvlc_log_close @@ -2926,7 +3013,7 @@ def libvlc_log_count(p_log): @return: number of log messages, 0 if p_log is NULL. ''' f = _Cfunctions.get('libvlc_log_count', None) or \ - _Cfunction('libvlc_log_count', ((1,),), + _Cfunction('libvlc_log_count', ((1,),), None, ctypes.c_uint, Log) if not __debug__: # i.e. python -O or -OO global libvlc_log_count @@ -2940,7 +3027,7 @@ def libvlc_log_clear(p_log): @param p_log: libvlc log instance or NULL. ''' f = _Cfunctions.get('libvlc_log_clear', None) or \ - _Cfunction('libvlc_log_clear', ((1,),), + _Cfunction('libvlc_log_clear', ((1,),), None, None, Log) if not __debug__: # i.e. python -O or -OO global libvlc_log_clear @@ -2953,8 +3040,8 @@ def libvlc_log_get_iterator(p_log): @return: log iterator object or NULL on error. ''' f = _Cfunctions.get('libvlc_log_get_iterator', None) or \ - _Cfunction('libvlc_log_get_iterator', ((1,),), - LogIterator, Log) + _Cfunction('libvlc_log_get_iterator', ((1,),), class_result(LogIterator), + ctypes.c_void_p, Log) if not __debug__: # i.e. python -O or -OO global libvlc_log_get_iterator libvlc_log_get_iterator = f @@ -2965,7 +3052,7 @@ def libvlc_log_iterator_free(p_iter): @param p_iter: libvlc log iterator or NULL. ''' f = _Cfunctions.get('libvlc_log_iterator_free', None) or \ - _Cfunction('libvlc_log_iterator_free', ((1,),), + _Cfunction('libvlc_log_iterator_free', ((1,),), None, None, LogIterator) if not __debug__: # i.e. python -O or -OO global libvlc_log_iterator_free @@ -2978,7 +3065,7 @@ def libvlc_log_iterator_has_next(p_iter): @return: true if iterator has more message objects, else false. ''' f = _Cfunctions.get('libvlc_log_iterator_has_next', None) or \ - _Cfunction('libvlc_log_iterator_has_next', ((1,),), + _Cfunction('libvlc_log_iterator_has_next', ((1,),), None, ctypes.c_int, LogIterator) if not __debug__: # i.e. python -O or -OO global libvlc_log_iterator_has_next @@ -2993,7 +3080,7 @@ def libvlc_log_iterator_next(p_iter, p_buffer): @return: log message object or NULL if none left. ''' f = _Cfunctions.get('libvlc_log_iterator_next', None) or \ - _Cfunction('libvlc_log_iterator_next', ((1,), (1,),), + _Cfunction('libvlc_log_iterator_next', ((1,), (1,),), None, ctypes.POINTER(LogMessage), LogIterator, ctypes.POINTER(LogMessage)) if not __debug__: # i.e. python -O or -OO global libvlc_log_iterator_next @@ -3005,7 +3092,7 @@ def libvlc_module_description_list_release(p_list): @param p_list: the list to be released. ''' f = _Cfunctions.get('libvlc_module_description_list_release', None) or \ - _Cfunction('libvlc_module_description_list_release', ((1,),), + _Cfunction('libvlc_module_description_list_release', ((1,),), None, None, ctypes.POINTER(ModuleDescription)) if not __debug__: # i.e. python -O or -OO global libvlc_module_description_list_release @@ -3018,7 +3105,7 @@ def libvlc_audio_filter_list_get(p_instance): @return: a list of module descriptions. It should be freed with L{libvlc_module_description_list_release}(). In case of an error, NULL is returned. See L{ModuleDescription} See L{libvlc_module_description_list_release}. ''' f = _Cfunctions.get('libvlc_audio_filter_list_get', None) or \ - _Cfunction('libvlc_audio_filter_list_get', ((1,),), + _Cfunction('libvlc_audio_filter_list_get', ((1,),), None, ctypes.POINTER(ModuleDescription), Instance) if not __debug__: # i.e. python -O or -OO global libvlc_audio_filter_list_get @@ -3031,13 +3118,29 @@ def libvlc_video_filter_list_get(p_instance): @return: a list of module descriptions. It should be freed with L{libvlc_module_description_list_release}(). In case of an error, NULL is returned. See L{ModuleDescription} See L{libvlc_module_description_list_release}. ''' f = _Cfunctions.get('libvlc_video_filter_list_get', None) or \ - _Cfunction('libvlc_video_filter_list_get', ((1,),), + _Cfunction('libvlc_video_filter_list_get', ((1,),), None, ctypes.POINTER(ModuleDescription), Instance) if not __debug__: # i.e. python -O or -OO global libvlc_video_filter_list_get libvlc_video_filter_list_get = f return f(p_instance) +def libvlc_clock(): + '''Return the current time as defined by LibVLC. The unit is the microsecond. + Time increases monotonically (regardless of time zone changes and RTC + adjustements). + The origin is arbitrary but consistent across the whole system + (e.g. the system uptim, the time since the system was booted). + @note: On systems that support it, the POSIX monotonic clock is used. + ''' + f = _Cfunctions.get('libvlc_clock', None) or \ + _Cfunction('libvlc_clock', (), None, + ctypes.c_int64) + if not __debug__: # i.e. python -O or -OO + global libvlc_clock + libvlc_clock = f + return f() + def libvlc_media_new_location(p_instance, psz_mrl): '''Create a media with a certain given media resource location, for instance a valid URL. @@ -3051,8 +3154,8 @@ def libvlc_media_new_location(p_instance, psz_mrl): @return: the newly created media or NULL on error. ''' f = _Cfunctions.get('libvlc_media_new_location', None) or \ - _Cfunction('libvlc_media_new_location', ((1,), (1,),), - Media, Instance, ctypes.c_char_p) + _Cfunction('libvlc_media_new_location', ((1,), (1,),), class_result(Media), + ctypes.c_void_p, Instance, ctypes.c_char_p) if not __debug__: # i.e. python -O or -OO global libvlc_media_new_location libvlc_media_new_location = f @@ -3066,8 +3169,8 @@ def libvlc_media_new_path(p_instance, path): @return: the newly created media or NULL on error. ''' f = _Cfunctions.get('libvlc_media_new_path', None) or \ - _Cfunction('libvlc_media_new_path', ((1,), (1,),), - Media, Instance, ctypes.c_char_p) + _Cfunction('libvlc_media_new_path', ((1,), (1,),), class_result(Media), + ctypes.c_void_p, Instance, ctypes.c_char_p) if not __debug__: # i.e. python -O or -OO global libvlc_media_new_path libvlc_media_new_path = f @@ -3093,8 +3196,8 @@ def libvlc_media_new_fd(p_instance, fd): @version: LibVLC 1.1.5 and later. ''' f = _Cfunctions.get('libvlc_media_new_fd', None) or \ - _Cfunction('libvlc_media_new_fd', ((1,), (1,),), - Media, Instance, ctypes.c_int) + _Cfunction('libvlc_media_new_fd', ((1,), (1,),), class_result(Media), + ctypes.c_void_p, Instance, ctypes.c_int) if not __debug__: # i.e. python -O or -OO global libvlc_media_new_fd libvlc_media_new_fd = f @@ -3108,8 +3211,8 @@ def libvlc_media_new_as_node(p_instance, psz_name): @return: the new empty media or NULL on error. ''' f = _Cfunctions.get('libvlc_media_new_as_node', None) or \ - _Cfunction('libvlc_media_new_as_node', ((1,), (1,),), - Media, Instance, ctypes.c_char_p) + _Cfunction('libvlc_media_new_as_node', ((1,), (1,),), class_result(Media), + ctypes.c_void_p, Instance, ctypes.c_char_p) if not __debug__: # i.e. python -O or -OO global libvlc_media_new_as_node libvlc_media_new_as_node = f @@ -3125,7 +3228,7 @@ def libvlc_media_add_option(p_md, ppsz_options): @param ppsz_options: the options (as a string). ''' f = _Cfunctions.get('libvlc_media_add_option', None) or \ - _Cfunction('libvlc_media_add_option', ((1,), (1,),), + _Cfunction('libvlc_media_add_option', ((1,), (1,),), None, None, Media, ctypes.c_char_p) if not __debug__: # i.e. python -O or -OO global libvlc_media_add_option @@ -3143,7 +3246,7 @@ def libvlc_media_add_option_flag(p_md, ppsz_options, i_flags): @param i_flags: the flags for this option. ''' f = _Cfunctions.get('libvlc_media_add_option_flag', None) or \ - _Cfunction('libvlc_media_add_option_flag', ((1,), (1,), (1,),), + _Cfunction('libvlc_media_add_option_flag', ((1,), (1,), (1,),), None, None, Media, ctypes.c_char_p, ctypes.c_uint) if not __debug__: # i.e. python -O or -OO global libvlc_media_add_option_flag @@ -3157,7 +3260,7 @@ def libvlc_media_retain(p_md): @param p_md: the media descriptor. ''' f = _Cfunctions.get('libvlc_media_retain', None) or \ - _Cfunction('libvlc_media_retain', ((1,),), + _Cfunction('libvlc_media_retain', ((1,),), None, None, Media) if not __debug__: # i.e. python -O or -OO global libvlc_media_retain @@ -3173,7 +3276,7 @@ def libvlc_media_release(p_md): @param p_md: the media descriptor. ''' f = _Cfunctions.get('libvlc_media_release', None) or \ - _Cfunction('libvlc_media_release', ((1,),), + _Cfunction('libvlc_media_release', ((1,),), None, None, Media) if not __debug__: # i.e. python -O or -OO global libvlc_media_release @@ -3186,8 +3289,8 @@ def libvlc_media_get_mrl(p_md): @return: string with mrl of media descriptor object. ''' f = _Cfunctions.get('libvlc_media_get_mrl', None) or \ - _Cfunction('libvlc_media_get_mrl', ((1,),), - ctypes.c_char_p, Media) + _Cfunction('libvlc_media_get_mrl', ((1,),), string_result, + ctypes.c_void_p, Media) if not __debug__: # i.e. python -O or -OO global libvlc_media_get_mrl libvlc_media_get_mrl = f @@ -3198,8 +3301,8 @@ def libvlc_media_duplicate(p_md): @param p_md: a media descriptor object. ''' f = _Cfunctions.get('libvlc_media_duplicate', None) or \ - _Cfunction('libvlc_media_duplicate', ((1,),), - Media, Media) + _Cfunction('libvlc_media_duplicate', ((1,),), class_result(Media), + ctypes.c_void_p, Media) if not __debug__: # i.e. python -O or -OO global libvlc_media_duplicate libvlc_media_duplicate = f @@ -3219,8 +3322,8 @@ def libvlc_media_get_meta(p_md, e_meta): @return: the media's meta. ''' f = _Cfunctions.get('libvlc_media_get_meta', None) or \ - _Cfunction('libvlc_media_get_meta', ((1,), (1,),), - ctypes.c_char_p, Media, Meta) + _Cfunction('libvlc_media_get_meta', ((1,), (1,),), string_result, + ctypes.c_void_p, Media, Meta) if not __debug__: # i.e. python -O or -OO global libvlc_media_get_meta libvlc_media_get_meta = f @@ -3234,7 +3337,7 @@ def libvlc_media_set_meta(p_md, e_meta, psz_value): @param psz_value: the media's meta. ''' f = _Cfunctions.get('libvlc_media_set_meta', None) or \ - _Cfunction('libvlc_media_set_meta', ((1,), (1,), (1,),), + _Cfunction('libvlc_media_set_meta', ((1,), (1,), (1,),), None, None, Media, Meta, ctypes.c_char_p) if not __debug__: # i.e. python -O or -OO global libvlc_media_set_meta @@ -3247,7 +3350,7 @@ def libvlc_media_save_meta(p_md): @return: true if the write operation was successfull. ''' f = _Cfunctions.get('libvlc_media_save_meta', None) or \ - _Cfunction('libvlc_media_save_meta', ((1,),), + _Cfunction('libvlc_media_save_meta', ((1,),), None, ctypes.c_int, Media) if not __debug__: # i.e. python -O or -OO global libvlc_media_save_meta @@ -3265,7 +3368,7 @@ def libvlc_media_get_state(p_md): @return: state of media descriptor object. ''' f = _Cfunctions.get('libvlc_media_get_state', None) or \ - _Cfunction('libvlc_media_get_state', ((1,),), + _Cfunction('libvlc_media_get_state', ((1,),), None, State, Media) if not __debug__: # i.e. python -O or -OO global libvlc_media_get_state @@ -3279,7 +3382,7 @@ def libvlc_media_get_stats(p_md, p_stats): @return: true if the statistics are available, false otherwise. ''' f = _Cfunctions.get('libvlc_media_get_stats', None) or \ - _Cfunction('libvlc_media_get_stats', ((1,), (1,),), + _Cfunction('libvlc_media_get_stats', ((1,), (1,),), None, ctypes.c_int, Media, ctypes.POINTER(MediaStats)) if not __debug__: # i.e. python -O or -OO global libvlc_media_get_stats @@ -3293,8 +3396,8 @@ def libvlc_media_event_manager(p_md): @return: event manager object. ''' f = _Cfunctions.get('libvlc_media_event_manager', None) or \ - _Cfunction('libvlc_media_event_manager', ((1,),), - EventManager, Media) + _Cfunction('libvlc_media_event_manager', ((1,),), class_result(EventManager), + ctypes.c_void_p, Media) if not __debug__: # i.e. python -O or -OO global libvlc_media_event_manager libvlc_media_event_manager = f @@ -3306,7 +3409,7 @@ def libvlc_media_get_duration(p_md): @return: duration of media item or -1 on error. ''' f = _Cfunctions.get('libvlc_media_get_duration', None) or \ - _Cfunction('libvlc_media_get_duration', ((1,),), + _Cfunction('libvlc_media_get_duration', ((1,),), None, ctypes.c_longlong, Media) if not __debug__: # i.e. python -O or -OO global libvlc_media_get_duration @@ -3323,7 +3426,7 @@ def libvlc_media_parse(p_md): @param p_md: media descriptor object. ''' f = _Cfunctions.get('libvlc_media_parse', None) or \ - _Cfunction('libvlc_media_parse', ((1,),), + _Cfunction('libvlc_media_parse', ((1,),), None, None, Media) if not __debug__: # i.e. python -O or -OO global libvlc_media_parse @@ -3344,7 +3447,7 @@ def libvlc_media_parse_async(p_md): @param p_md: media descriptor object. ''' f = _Cfunctions.get('libvlc_media_parse_async', None) or \ - _Cfunction('libvlc_media_parse_async', ((1,),), + _Cfunction('libvlc_media_parse_async', ((1,),), None, None, Media) if not __debug__: # i.e. python -O or -OO global libvlc_media_parse_async @@ -3358,7 +3461,7 @@ def libvlc_media_is_parsed(p_md): @return: true if media object has been parsed otherwise it returns false. ''' f = _Cfunctions.get('libvlc_media_is_parsed', None) or \ - _Cfunction('libvlc_media_is_parsed', ((1,),), + _Cfunction('libvlc_media_is_parsed', ((1,),), None, ctypes.c_int, Media) if not __debug__: # i.e. python -O or -OO global libvlc_media_is_parsed @@ -3373,7 +3476,7 @@ def libvlc_media_set_user_data(p_md, p_new_user_data): @param p_new_user_data: pointer to user data. ''' f = _Cfunctions.get('libvlc_media_set_user_data', None) or \ - _Cfunction('libvlc_media_set_user_data', ((1,), (1,),), + _Cfunction('libvlc_media_set_user_data', ((1,), (1,),), None, None, Media, ctypes.c_void_p) if not __debug__: # i.e. python -O or -OO global libvlc_media_set_user_data @@ -3387,7 +3490,7 @@ def libvlc_media_get_user_data(p_md): @param p_md: media descriptor object. ''' f = _Cfunctions.get('libvlc_media_get_user_data', None) or \ - _Cfunction('libvlc_media_get_user_data', ((1,),), + _Cfunction('libvlc_media_get_user_data', ((1,),), None, ctypes.c_void_p, Media) if not __debug__: # i.e. python -O or -OO global libvlc_media_get_user_data @@ -3400,10 +3503,11 @@ def libvlc_media_get_tracks_info(p_md): before calling this function. Not doing this will result in an empty array. @param p_md: media descriptor object. - @param tracks: address to store an allocated array of Elementary Streams descriptions (must be freed by the caller) [OUT] return the number of Elementary Streams. + @param tracks: address to store an allocated array of Elementary Streams descriptions (must be freed by the caller). + @return: the number of Elementary Streams. ''' f = _Cfunctions.get('libvlc_media_get_tracks_info', None) or \ - _Cfunction('libvlc_media_get_tracks_info', ((1,), (2,),), + _Cfunction('libvlc_media_get_tracks_info', ((1,), (2,),), None, ctypes.c_int, Media, ctypes.POINTER(ctypes.c_void_p)) if not __debug__: # i.e. python -O or -OO global libvlc_media_get_tracks_info @@ -3417,8 +3521,8 @@ def libvlc_media_discoverer_new_from_name(p_inst, psz_name): @return: media discover object or NULL in case of error. ''' f = _Cfunctions.get('libvlc_media_discoverer_new_from_name', None) or \ - _Cfunction('libvlc_media_discoverer_new_from_name', ((1,), (1,),), - MediaDiscoverer, Instance, ctypes.c_char_p) + _Cfunction('libvlc_media_discoverer_new_from_name', ((1,), (1,),), class_result(MediaDiscoverer), + ctypes.c_void_p, Instance, ctypes.c_char_p) if not __debug__: # i.e. python -O or -OO global libvlc_media_discoverer_new_from_name libvlc_media_discoverer_new_from_name = f @@ -3430,7 +3534,7 @@ def libvlc_media_discoverer_release(p_mdis): @param p_mdis: media service discover object. ''' f = _Cfunctions.get('libvlc_media_discoverer_release', None) or \ - _Cfunction('libvlc_media_discoverer_release', ((1,),), + _Cfunction('libvlc_media_discoverer_release', ((1,),), None, None, MediaDiscoverer) if not __debug__: # i.e. python -O or -OO global libvlc_media_discoverer_release @@ -3443,8 +3547,8 @@ def libvlc_media_discoverer_localized_name(p_mdis): @return: localized name. ''' f = _Cfunctions.get('libvlc_media_discoverer_localized_name', None) or \ - _Cfunction('libvlc_media_discoverer_localized_name', ((1,),), - ctypes.c_char_p, MediaDiscoverer) + _Cfunction('libvlc_media_discoverer_localized_name', ((1,),), string_result, + ctypes.c_void_p, MediaDiscoverer) if not __debug__: # i.e. python -O or -OO global libvlc_media_discoverer_localized_name libvlc_media_discoverer_localized_name = f @@ -3456,8 +3560,8 @@ def libvlc_media_discoverer_media_list(p_mdis): @return: list of media items. ''' f = _Cfunctions.get('libvlc_media_discoverer_media_list', None) or \ - _Cfunction('libvlc_media_discoverer_media_list', ((1,),), - MediaList, MediaDiscoverer) + _Cfunction('libvlc_media_discoverer_media_list', ((1,),), class_result(MediaList), + ctypes.c_void_p, MediaDiscoverer) if not __debug__: # i.e. python -O or -OO global libvlc_media_discoverer_media_list libvlc_media_discoverer_media_list = f @@ -3469,8 +3573,8 @@ def libvlc_media_discoverer_event_manager(p_mdis): @return: event manager object. ''' f = _Cfunctions.get('libvlc_media_discoverer_event_manager', None) or \ - _Cfunction('libvlc_media_discoverer_event_manager', ((1,),), - EventManager, MediaDiscoverer) + _Cfunction('libvlc_media_discoverer_event_manager', ((1,),), class_result(EventManager), + ctypes.c_void_p, MediaDiscoverer) if not __debug__: # i.e. python -O or -OO global libvlc_media_discoverer_event_manager libvlc_media_discoverer_event_manager = f @@ -3482,7 +3586,7 @@ def libvlc_media_discoverer_is_running(p_mdis): @return: true if running, false if not. ''' f = _Cfunctions.get('libvlc_media_discoverer_is_running', None) or \ - _Cfunction('libvlc_media_discoverer_is_running', ((1,),), + _Cfunction('libvlc_media_discoverer_is_running', ((1,),), None, ctypes.c_int, MediaDiscoverer) if not __debug__: # i.e. python -O or -OO global libvlc_media_discoverer_is_running @@ -3495,8 +3599,8 @@ def libvlc_media_library_new(p_instance): @return: a new object or NULL on error. ''' f = _Cfunctions.get('libvlc_media_library_new', None) or \ - _Cfunction('libvlc_media_library_new', ((1,),), - MediaLibrary, Instance) + _Cfunction('libvlc_media_library_new', ((1,),), class_result(MediaLibrary), + ctypes.c_void_p, Instance) if not __debug__: # i.e. python -O or -OO global libvlc_media_library_new libvlc_media_library_new = f @@ -3509,7 +3613,7 @@ def libvlc_media_library_release(p_mlib): @param p_mlib: media library object. ''' f = _Cfunctions.get('libvlc_media_library_release', None) or \ - _Cfunction('libvlc_media_library_release', ((1,),), + _Cfunction('libvlc_media_library_release', ((1,),), None, None, MediaLibrary) if not __debug__: # i.e. python -O or -OO global libvlc_media_library_release @@ -3523,7 +3627,7 @@ def libvlc_media_library_retain(p_mlib): @param p_mlib: media library object. ''' f = _Cfunctions.get('libvlc_media_library_retain', None) or \ - _Cfunction('libvlc_media_library_retain', ((1,),), + _Cfunction('libvlc_media_library_retain', ((1,),), None, None, MediaLibrary) if not __debug__: # i.e. python -O or -OO global libvlc_media_library_retain @@ -3536,7 +3640,7 @@ def libvlc_media_library_load(p_mlib): @return: 0 on success, -1 on error. ''' f = _Cfunctions.get('libvlc_media_library_load', None) or \ - _Cfunction('libvlc_media_library_load', ((1,),), + _Cfunction('libvlc_media_library_load', ((1,),), None, ctypes.c_int, MediaLibrary) if not __debug__: # i.e. python -O or -OO global libvlc_media_library_load @@ -3549,8 +3653,8 @@ def libvlc_media_library_media_list(p_mlib): @return: media list subitems. ''' f = _Cfunctions.get('libvlc_media_library_media_list', None) or \ - _Cfunction('libvlc_media_library_media_list', ((1,),), - MediaList, MediaLibrary) + _Cfunction('libvlc_media_library_media_list', ((1,),), class_result(MediaList), + ctypes.c_void_p, MediaLibrary) if not __debug__: # i.e. python -O or -OO global libvlc_media_library_media_list libvlc_media_library_media_list = f @@ -3562,8 +3666,8 @@ def libvlc_media_list_new(p_instance): @return: empty media list, or NULL on error. ''' f = _Cfunctions.get('libvlc_media_list_new', None) or \ - _Cfunction('libvlc_media_list_new', ((1,),), - MediaList, Instance) + _Cfunction('libvlc_media_list_new', ((1,),), class_result(MediaList), + ctypes.c_void_p, Instance) if not __debug__: # i.e. python -O or -OO global libvlc_media_list_new libvlc_media_list_new = f @@ -3574,7 +3678,7 @@ def libvlc_media_list_release(p_ml): @param p_ml: a media list created with L{libvlc_media_list_new}(). ''' f = _Cfunctions.get('libvlc_media_list_release', None) or \ - _Cfunction('libvlc_media_list_release', ((1,),), + _Cfunction('libvlc_media_list_release', ((1,),), None, None, MediaList) if not __debug__: # i.e. python -O or -OO global libvlc_media_list_release @@ -3586,7 +3690,7 @@ def libvlc_media_list_retain(p_ml): @param p_ml: a media list created with L{libvlc_media_list_new}(). ''' f = _Cfunctions.get('libvlc_media_list_retain', None) or \ - _Cfunction('libvlc_media_list_retain', ((1,),), + _Cfunction('libvlc_media_list_retain', ((1,),), None, None, MediaList) if not __debug__: # i.e. python -O or -OO global libvlc_media_list_retain @@ -3601,7 +3705,7 @@ def libvlc_media_list_set_media(p_ml, p_md): @param p_md: media instance to add. ''' f = _Cfunctions.get('libvlc_media_list_set_media', None) or \ - _Cfunction('libvlc_media_list_set_media', ((1,), (1,),), + _Cfunction('libvlc_media_list_set_media', ((1,), (1,),), None, None, MediaList, Media) if not __debug__: # i.e. python -O or -OO global libvlc_media_list_set_media @@ -3616,8 +3720,8 @@ def libvlc_media_list_media(p_ml): @return: media instance. ''' f = _Cfunctions.get('libvlc_media_list_media', None) or \ - _Cfunction('libvlc_media_list_media', ((1,),), - Media, MediaList) + _Cfunction('libvlc_media_list_media', ((1,),), class_result(Media), + ctypes.c_void_p, MediaList) if not __debug__: # i.e. python -O or -OO global libvlc_media_list_media libvlc_media_list_media = f @@ -3631,7 +3735,7 @@ def libvlc_media_list_add_media(p_ml, p_md): @return: 0 on success, -1 if the media list is read-only. ''' f = _Cfunctions.get('libvlc_media_list_add_media', None) or \ - _Cfunction('libvlc_media_list_add_media', ((1,), (1,),), + _Cfunction('libvlc_media_list_add_media', ((1,), (1,),), None, ctypes.c_int, MediaList, Media) if not __debug__: # i.e. python -O or -OO global libvlc_media_list_add_media @@ -3647,7 +3751,7 @@ def libvlc_media_list_insert_media(p_ml, p_md, i_pos): @return: 0 on success, -1 if the media list si read-only. ''' f = _Cfunctions.get('libvlc_media_list_insert_media', None) or \ - _Cfunction('libvlc_media_list_insert_media', ((1,), (1,), (1,),), + _Cfunction('libvlc_media_list_insert_media', ((1,), (1,), (1,),), None, ctypes.c_int, MediaList, Media, ctypes.c_int) if not __debug__: # i.e. python -O or -OO global libvlc_media_list_insert_media @@ -3662,7 +3766,7 @@ def libvlc_media_list_remove_index(p_ml, i_pos): @return: 0 on success, -1 if the list is read-only or the item was not found. ''' f = _Cfunctions.get('libvlc_media_list_remove_index', None) or \ - _Cfunction('libvlc_media_list_remove_index', ((1,), (1,),), + _Cfunction('libvlc_media_list_remove_index', ((1,), (1,),), None, ctypes.c_int, MediaList, ctypes.c_int) if not __debug__: # i.e. python -O or -OO global libvlc_media_list_remove_index @@ -3676,7 +3780,7 @@ def libvlc_media_list_count(p_ml): @return: number of items in media list. ''' f = _Cfunctions.get('libvlc_media_list_count', None) or \ - _Cfunction('libvlc_media_list_count', ((1,),), + _Cfunction('libvlc_media_list_count', ((1,),), None, ctypes.c_int, MediaList) if not __debug__: # i.e. python -O or -OO global libvlc_media_list_count @@ -3691,8 +3795,8 @@ def libvlc_media_list_item_at_index(p_ml, i_pos): @return: media instance at position i_pos, or NULL if not found. In case of success, L{libvlc_media_retain}() is called to increase the refcount on the media. ''' f = _Cfunctions.get('libvlc_media_list_item_at_index', None) or \ - _Cfunction('libvlc_media_list_item_at_index', ((1,), (1,),), - Media, MediaList, ctypes.c_int) + _Cfunction('libvlc_media_list_item_at_index', ((1,), (1,),), class_result(Media), + ctypes.c_void_p, MediaList, ctypes.c_int) if not __debug__: # i.e. python -O or -OO global libvlc_media_list_item_at_index libvlc_media_list_item_at_index = f @@ -3707,7 +3811,7 @@ def libvlc_media_list_index_of_item(p_ml, p_md): @return: position of media instance. ''' f = _Cfunctions.get('libvlc_media_list_index_of_item', None) or \ - _Cfunction('libvlc_media_list_index_of_item', ((1,), (1,),), + _Cfunction('libvlc_media_list_index_of_item', ((1,), (1,),), None, ctypes.c_int, MediaList, Media) if not __debug__: # i.e. python -O or -OO global libvlc_media_list_index_of_item @@ -3720,7 +3824,7 @@ def libvlc_media_list_is_readonly(p_ml): @return: 0 on readonly, 1 on readwrite. ''' f = _Cfunctions.get('libvlc_media_list_is_readonly', None) or \ - _Cfunction('libvlc_media_list_is_readonly', ((1,),), + _Cfunction('libvlc_media_list_is_readonly', ((1,),), None, ctypes.c_int, MediaList) if not __debug__: # i.e. python -O or -OO global libvlc_media_list_is_readonly @@ -3732,7 +3836,7 @@ def libvlc_media_list_lock(p_ml): @param p_ml: a media list instance. ''' f = _Cfunctions.get('libvlc_media_list_lock', None) or \ - _Cfunction('libvlc_media_list_lock', ((1,),), + _Cfunction('libvlc_media_list_lock', ((1,),), None, None, MediaList) if not __debug__: # i.e. python -O or -OO global libvlc_media_list_lock @@ -3745,7 +3849,7 @@ def libvlc_media_list_unlock(p_ml): @param p_ml: a media list instance. ''' f = _Cfunctions.get('libvlc_media_list_unlock', None) or \ - _Cfunction('libvlc_media_list_unlock', ((1,),), + _Cfunction('libvlc_media_list_unlock', ((1,),), None, None, MediaList) if not __debug__: # i.e. python -O or -OO global libvlc_media_list_unlock @@ -3759,8 +3863,8 @@ def libvlc_media_list_event_manager(p_ml): @return: libvlc_event_manager. ''' f = _Cfunctions.get('libvlc_media_list_event_manager', None) or \ - _Cfunction('libvlc_media_list_event_manager', ((1,),), - EventManager, MediaList) + _Cfunction('libvlc_media_list_event_manager', ((1,),), class_result(EventManager), + ctypes.c_void_p, MediaList) if not __debug__: # i.e. python -O or -OO global libvlc_media_list_event_manager libvlc_media_list_event_manager = f @@ -3772,8 +3876,8 @@ def libvlc_media_list_player_new(p_instance): @return: media list player instance or NULL on error. ''' f = _Cfunctions.get('libvlc_media_list_player_new', None) or \ - _Cfunction('libvlc_media_list_player_new', ((1,),), - MediaListPlayer, Instance) + _Cfunction('libvlc_media_list_player_new', ((1,),), class_result(MediaListPlayer), + ctypes.c_void_p, Instance) if not __debug__: # i.e. python -O or -OO global libvlc_media_list_player_new libvlc_media_list_player_new = f @@ -3784,7 +3888,7 @@ def libvlc_media_list_player_release(p_mlp): @param p_mlp: media list player instance. ''' f = _Cfunctions.get('libvlc_media_list_player_release', None) or \ - _Cfunction('libvlc_media_list_player_release', ((1,),), + _Cfunction('libvlc_media_list_player_release', ((1,),), None, None, MediaListPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_media_list_player_release @@ -3797,8 +3901,8 @@ def libvlc_media_list_player_event_manager(p_mlp): @return: the event manager. ''' f = _Cfunctions.get('libvlc_media_list_player_event_manager', None) or \ - _Cfunction('libvlc_media_list_player_event_manager', ((1,),), - EventManager, MediaListPlayer) + _Cfunction('libvlc_media_list_player_event_manager', ((1,),), class_result(EventManager), + ctypes.c_void_p, MediaListPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_media_list_player_event_manager libvlc_media_list_player_event_manager = f @@ -3810,7 +3914,7 @@ def libvlc_media_list_player_set_media_player(p_mlp, p_mi): @param p_mi: media player instance. ''' f = _Cfunctions.get('libvlc_media_list_player_set_media_player', None) or \ - _Cfunction('libvlc_media_list_player_set_media_player', ((1,), (1,),), + _Cfunction('libvlc_media_list_player_set_media_player', ((1,), (1,),), None, None, MediaListPlayer, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_media_list_player_set_media_player @@ -3823,7 +3927,7 @@ def libvlc_media_list_player_set_media_list(p_mlp, p_mlist): @param p_mlist: list of media. ''' f = _Cfunctions.get('libvlc_media_list_player_set_media_list', None) or \ - _Cfunction('libvlc_media_list_player_set_media_list', ((1,), (1,),), + _Cfunction('libvlc_media_list_player_set_media_list', ((1,), (1,),), None, None, MediaListPlayer, MediaList) if not __debug__: # i.e. python -O or -OO global libvlc_media_list_player_set_media_list @@ -3835,7 +3939,7 @@ def libvlc_media_list_player_play(p_mlp): @param p_mlp: media list player instance. ''' f = _Cfunctions.get('libvlc_media_list_player_play', None) or \ - _Cfunction('libvlc_media_list_player_play', ((1,),), + _Cfunction('libvlc_media_list_player_play', ((1,),), None, None, MediaListPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_media_list_player_play @@ -3847,7 +3951,7 @@ def libvlc_media_list_player_pause(p_mlp): @param p_mlp: media list player instance. ''' f = _Cfunctions.get('libvlc_media_list_player_pause', None) or \ - _Cfunction('libvlc_media_list_player_pause', ((1,),), + _Cfunction('libvlc_media_list_player_pause', ((1,),), None, None, MediaListPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_media_list_player_pause @@ -3860,7 +3964,7 @@ def libvlc_media_list_player_is_playing(p_mlp): @return: true for playing and false for not playing. ''' f = _Cfunctions.get('libvlc_media_list_player_is_playing', None) or \ - _Cfunction('libvlc_media_list_player_is_playing', ((1,),), + _Cfunction('libvlc_media_list_player_is_playing', ((1,),), None, ctypes.c_int, MediaListPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_media_list_player_is_playing @@ -3873,7 +3977,7 @@ def libvlc_media_list_player_get_state(p_mlp): @return: libvlc_state_t for media list player. ''' f = _Cfunctions.get('libvlc_media_list_player_get_state', None) or \ - _Cfunction('libvlc_media_list_player_get_state', ((1,),), + _Cfunction('libvlc_media_list_player_get_state', ((1,),), None, State, MediaListPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_media_list_player_get_state @@ -3887,7 +3991,7 @@ def libvlc_media_list_player_play_item_at_index(p_mlp, i_index): @return: 0 upon success -1 if the item wasn't found. ''' f = _Cfunctions.get('libvlc_media_list_player_play_item_at_index', None) or \ - _Cfunction('libvlc_media_list_player_play_item_at_index', ((1,), (1,),), + _Cfunction('libvlc_media_list_player_play_item_at_index', ((1,), (1,),), None, ctypes.c_int, MediaListPlayer, ctypes.c_int) if not __debug__: # i.e. python -O or -OO global libvlc_media_list_player_play_item_at_index @@ -3901,7 +4005,7 @@ def libvlc_media_list_player_play_item(p_mlp, p_md): @return: 0 upon success, -1 if the media is not part of the media list. ''' f = _Cfunctions.get('libvlc_media_list_player_play_item', None) or \ - _Cfunction('libvlc_media_list_player_play_item', ((1,), (1,),), + _Cfunction('libvlc_media_list_player_play_item', ((1,), (1,),), None, ctypes.c_int, MediaListPlayer, Media) if not __debug__: # i.e. python -O or -OO global libvlc_media_list_player_play_item @@ -3913,7 +4017,7 @@ def libvlc_media_list_player_stop(p_mlp): @param p_mlp: media list player instance. ''' f = _Cfunctions.get('libvlc_media_list_player_stop', None) or \ - _Cfunction('libvlc_media_list_player_stop', ((1,),), + _Cfunction('libvlc_media_list_player_stop', ((1,),), None, None, MediaListPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_media_list_player_stop @@ -3926,7 +4030,7 @@ def libvlc_media_list_player_next(p_mlp): @return: 0 upon success -1 if there is no next item. ''' f = _Cfunctions.get('libvlc_media_list_player_next', None) or \ - _Cfunction('libvlc_media_list_player_next', ((1,),), + _Cfunction('libvlc_media_list_player_next', ((1,),), None, ctypes.c_int, MediaListPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_media_list_player_next @@ -3939,7 +4043,7 @@ def libvlc_media_list_player_previous(p_mlp): @return: 0 upon success -1 if there is no previous item. ''' f = _Cfunctions.get('libvlc_media_list_player_previous', None) or \ - _Cfunction('libvlc_media_list_player_previous', ((1,),), + _Cfunction('libvlc_media_list_player_previous', ((1,),), None, ctypes.c_int, MediaListPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_media_list_player_previous @@ -3952,7 +4056,7 @@ def libvlc_media_list_player_set_playback_mode(p_mlp, e_mode): @param e_mode: playback mode specification. ''' f = _Cfunctions.get('libvlc_media_list_player_set_playback_mode', None) or \ - _Cfunction('libvlc_media_list_player_set_playback_mode', ((1,), (1,),), + _Cfunction('libvlc_media_list_player_set_playback_mode', ((1,), (1,),), None, None, MediaListPlayer, PlaybackMode) if not __debug__: # i.e. python -O or -OO global libvlc_media_list_player_set_playback_mode @@ -3965,8 +4069,8 @@ def libvlc_media_player_new(p_libvlc_instance): @return: a new media player object, or NULL on error. ''' f = _Cfunctions.get('libvlc_media_player_new', None) or \ - _Cfunction('libvlc_media_player_new', ((1,),), - MediaPlayer, Instance) + _Cfunction('libvlc_media_player_new', ((1,),), class_result(MediaPlayer), + ctypes.c_void_p, Instance) if not __debug__: # i.e. python -O or -OO global libvlc_media_player_new libvlc_media_player_new = f @@ -3978,8 +4082,8 @@ def libvlc_media_player_new_from_media(p_md): @return: a new media player object, or NULL on error. ''' f = _Cfunctions.get('libvlc_media_player_new_from_media', None) or \ - _Cfunction('libvlc_media_player_new_from_media', ((1,),), - MediaPlayer, Media) + _Cfunction('libvlc_media_player_new_from_media', ((1,),), class_result(MediaPlayer), + ctypes.c_void_p, Media) if not __debug__: # i.e. python -O or -OO global libvlc_media_player_new_from_media libvlc_media_player_new_from_media = f @@ -3994,7 +4098,7 @@ def libvlc_media_player_release(p_mi): @param p_mi: the Media Player to free. ''' f = _Cfunctions.get('libvlc_media_player_release', None) or \ - _Cfunction('libvlc_media_player_release', ((1,),), + _Cfunction('libvlc_media_player_release', ((1,),), None, None, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_media_player_release @@ -4007,7 +4111,7 @@ def libvlc_media_player_retain(p_mi): @param p_mi: media player object. ''' f = _Cfunctions.get('libvlc_media_player_retain', None) or \ - _Cfunction('libvlc_media_player_retain', ((1,),), + _Cfunction('libvlc_media_player_retain', ((1,),), None, None, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_media_player_retain @@ -4021,7 +4125,7 @@ def libvlc_media_player_set_media(p_mi, p_md): @param p_md: the Media. Afterwards the p_md can be safely destroyed. ''' f = _Cfunctions.get('libvlc_media_player_set_media', None) or \ - _Cfunction('libvlc_media_player_set_media', ((1,), (1,),), + _Cfunction('libvlc_media_player_set_media', ((1,), (1,),), None, None, MediaPlayer, Media) if not __debug__: # i.e. python -O or -OO global libvlc_media_player_set_media @@ -4034,8 +4138,8 @@ def libvlc_media_player_get_media(p_mi): @return: the media associated with p_mi, or NULL if no media is associated. ''' f = _Cfunctions.get('libvlc_media_player_get_media', None) or \ - _Cfunction('libvlc_media_player_get_media', ((1,),), - Media, MediaPlayer) + _Cfunction('libvlc_media_player_get_media', ((1,),), class_result(Media), + ctypes.c_void_p, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_media_player_get_media libvlc_media_player_get_media = f @@ -4047,8 +4151,8 @@ def libvlc_media_player_event_manager(p_mi): @return: the event manager associated with p_mi. ''' f = _Cfunctions.get('libvlc_media_player_event_manager', None) or \ - _Cfunction('libvlc_media_player_event_manager', ((1,),), - EventManager, MediaPlayer) + _Cfunction('libvlc_media_player_event_manager', ((1,),), class_result(EventManager), + ctypes.c_void_p, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_media_player_event_manager libvlc_media_player_event_manager = f @@ -4060,7 +4164,7 @@ def libvlc_media_player_is_playing(p_mi): @return: 1 if the media player is playing, 0 otherwise. ''' f = _Cfunctions.get('libvlc_media_player_is_playing', None) or \ - _Cfunction('libvlc_media_player_is_playing', ((1,),), + _Cfunction('libvlc_media_player_is_playing', ((1,),), None, ctypes.c_int, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_media_player_is_playing @@ -4073,7 +4177,7 @@ def libvlc_media_player_play(p_mi): @return: 0 if playback started (and was already started), or -1 on error. ''' f = _Cfunctions.get('libvlc_media_player_play', None) or \ - _Cfunction('libvlc_media_player_play', ((1,),), + _Cfunction('libvlc_media_player_play', ((1,),), None, ctypes.c_int, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_media_player_play @@ -4087,7 +4191,7 @@ def libvlc_media_player_set_pause(mp, do_pause): @version: LibVLC 1.1.1 or later. ''' f = _Cfunctions.get('libvlc_media_player_set_pause', None) or \ - _Cfunction('libvlc_media_player_set_pause', ((1,), (1,),), + _Cfunction('libvlc_media_player_set_pause', ((1,), (1,),), None, None, MediaPlayer, ctypes.c_int) if not __debug__: # i.e. python -O or -OO global libvlc_media_player_set_pause @@ -4099,7 +4203,7 @@ def libvlc_media_player_pause(p_mi): @param p_mi: the Media Player. ''' f = _Cfunctions.get('libvlc_media_player_pause', None) or \ - _Cfunction('libvlc_media_player_pause', ((1,),), + _Cfunction('libvlc_media_player_pause', ((1,),), None, None, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_media_player_pause @@ -4111,7 +4215,7 @@ def libvlc_media_player_stop(p_mi): @param p_mi: the Media Player. ''' f = _Cfunctions.get('libvlc_media_player_stop', None) or \ - _Cfunction('libvlc_media_player_stop', ((1,),), + _Cfunction('libvlc_media_player_stop', ((1,),), None, None, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_media_player_stop @@ -4131,7 +4235,7 @@ def libvlc_video_set_format(mp, chroma, width, height, pitch): @bug: All pixel planes are expected to have the same pitch. To use the YCbCr color space with chrominance subsampling, consider using libvlc_video_set_format_callbacks() instead. ''' f = _Cfunctions.get('libvlc_video_set_format', None) or \ - _Cfunction('libvlc_video_set_format', ((1,), (1,), (1,), (1,), (1,),), + _Cfunction('libvlc_video_set_format', ((1,), (1,), (1,), (1,), (1,),), None, None, MediaPlayer, ctypes.c_char_p, ctypes.c_uint, ctypes.c_uint, ctypes.c_uint) if not __debug__: # i.e. python -O or -OO global libvlc_video_set_format @@ -4153,19 +4257,19 @@ def libvlc_media_player_set_nsobject(p_mi, drawable): If you want to use it along with Qt4 see the QMacCocoaViewContainer. Then the following code should work: @begincode - + NSView *video = [[NSView alloc] init]; QMacCocoaViewContainer *container = new QMacCocoaViewContainer(video, parent); L{libvlc_media_player_set_nsobject}(mp, video); [video release]; - + @endcode You can find a live example in VLCVideoView in VLCKit.framework. @param p_mi: the Media Player. @param drawable: the drawable that is either an NSView or an object following the VLCOpenGLVideoViewEmbedding protocol. ''' f = _Cfunctions.get('libvlc_media_player_set_nsobject', None) or \ - _Cfunction('libvlc_media_player_set_nsobject', ((1,), (1,),), + _Cfunction('libvlc_media_player_set_nsobject', ((1,), (1,),), None, None, MediaPlayer, ctypes.c_void_p) if not __debug__: # i.e. python -O or -OO global libvlc_media_player_set_nsobject @@ -4178,7 +4282,7 @@ def libvlc_media_player_get_nsobject(p_mi): @return: the NSView handler or 0 if none where set. ''' f = _Cfunctions.get('libvlc_media_player_get_nsobject', None) or \ - _Cfunction('libvlc_media_player_get_nsobject', ((1,),), + _Cfunction('libvlc_media_player_get_nsobject', ((1,),), None, ctypes.c_void_p, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_media_player_get_nsobject @@ -4191,7 +4295,7 @@ def libvlc_media_player_set_agl(p_mi, drawable): @param drawable: the agl handler. ''' f = _Cfunctions.get('libvlc_media_player_set_agl', None) or \ - _Cfunction('libvlc_media_player_set_agl', ((1,), (1,),), + _Cfunction('libvlc_media_player_set_agl', ((1,), (1,),), None, None, MediaPlayer, ctypes.c_uint32) if not __debug__: # i.e. python -O or -OO global libvlc_media_player_set_agl @@ -4204,7 +4308,7 @@ def libvlc_media_player_get_agl(p_mi): @return: the agl handler or 0 if none where set. ''' f = _Cfunctions.get('libvlc_media_player_get_agl', None) or \ - _Cfunction('libvlc_media_player_get_agl', ((1,),), + _Cfunction('libvlc_media_player_get_agl', ((1,),), None, ctypes.c_uint32, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_media_player_get_agl @@ -4224,7 +4328,7 @@ def libvlc_media_player_set_xwindow(p_mi, drawable): @param drawable: the ID of the X window. ''' f = _Cfunctions.get('libvlc_media_player_set_xwindow', None) or \ - _Cfunction('libvlc_media_player_set_xwindow', ((1,), (1,),), + _Cfunction('libvlc_media_player_set_xwindow', ((1,), (1,),), None, None, MediaPlayer, ctypes.c_uint32) if not __debug__: # i.e. python -O or -OO global libvlc_media_player_set_xwindow @@ -4240,7 +4344,7 @@ def libvlc_media_player_get_xwindow(p_mi): @return: an X window ID, or 0 if none where set. ''' f = _Cfunctions.get('libvlc_media_player_get_xwindow', None) or \ - _Cfunction('libvlc_media_player_get_xwindow', ((1,),), + _Cfunction('libvlc_media_player_get_xwindow', ((1,),), None, ctypes.c_uint32, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_media_player_get_xwindow @@ -4255,7 +4359,7 @@ def libvlc_media_player_set_hwnd(p_mi, drawable): @param drawable: windows handle of the drawable. ''' f = _Cfunctions.get('libvlc_media_player_set_hwnd', None) or \ - _Cfunction('libvlc_media_player_set_hwnd', ((1,), (1,),), + _Cfunction('libvlc_media_player_set_hwnd', ((1,), (1,),), None, None, MediaPlayer, ctypes.c_void_p) if not __debug__: # i.e. python -O or -OO global libvlc_media_player_set_hwnd @@ -4270,20 +4374,38 @@ def libvlc_media_player_get_hwnd(p_mi): @return: a window handle or NULL if there are none. ''' f = _Cfunctions.get('libvlc_media_player_get_hwnd', None) or \ - _Cfunction('libvlc_media_player_get_hwnd', ((1,),), + _Cfunction('libvlc_media_player_get_hwnd', ((1,),), None, ctypes.c_void_p, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_media_player_get_hwnd libvlc_media_player_get_hwnd = f return f(p_mi) +def libvlc_audio_set_format(mp, format, rate, channels): + '''Set decoded audio format. + This only works in combination with libvlc_audio_set_callbacks(), + and is mutually exclusive with libvlc_audio_set_format_callbacks(). + @param mp: the media player. + @param fourcc: a four-characters string identifying the sample format (e.g. "S16N" or "FL32"). + @param rate: sample rate (expressed in Hz). + @param channels: channels count. + @version: LibVLC 1.2.0 or later. + ''' + f = _Cfunctions.get('libvlc_audio_set_format', None) or \ + _Cfunction('libvlc_audio_set_format', ((1,), (1,), (1,), (1,),), None, + None, MediaPlayer, ctypes.c_char_p, ctypes.c_uint, ctypes.c_uint) + if not __debug__: # i.e. python -O or -OO + global libvlc_audio_set_format + libvlc_audio_set_format = f + return f(mp, format, rate, channels) + def libvlc_media_player_get_length(p_mi): '''Get the current movie length (in ms). @param p_mi: the Media Player. @return: the movie length (in ms), or -1 if there is no media. ''' f = _Cfunctions.get('libvlc_media_player_get_length', None) or \ - _Cfunction('libvlc_media_player_get_length', ((1,),), + _Cfunction('libvlc_media_player_get_length', ((1,),), None, ctypes.c_longlong, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_media_player_get_length @@ -4296,7 +4418,7 @@ def libvlc_media_player_get_time(p_mi): @return: the movie time (in ms), or -1 if there is no media. ''' f = _Cfunctions.get('libvlc_media_player_get_time', None) or \ - _Cfunction('libvlc_media_player_get_time', ((1,),), + _Cfunction('libvlc_media_player_get_time', ((1,),), None, ctypes.c_longlong, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_media_player_get_time @@ -4310,7 +4432,7 @@ def libvlc_media_player_set_time(p_mi, i_time): @param i_time: the movie time (in ms). ''' f = _Cfunctions.get('libvlc_media_player_set_time', None) or \ - _Cfunction('libvlc_media_player_set_time', ((1,), (1,),), + _Cfunction('libvlc_media_player_set_time', ((1,), (1,),), None, None, MediaPlayer, ctypes.c_longlong) if not __debug__: # i.e. python -O or -OO global libvlc_media_player_set_time @@ -4323,7 +4445,7 @@ def libvlc_media_player_get_position(p_mi): @return: movie position, or -1. in case of error. ''' f = _Cfunctions.get('libvlc_media_player_get_position', None) or \ - _Cfunction('libvlc_media_player_get_position', ((1,),), + _Cfunction('libvlc_media_player_get_position', ((1,),), None, ctypes.c_float, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_media_player_get_position @@ -4337,7 +4459,7 @@ def libvlc_media_player_set_position(p_mi, f_pos): @param f_pos: the position. ''' f = _Cfunctions.get('libvlc_media_player_set_position', None) or \ - _Cfunction('libvlc_media_player_set_position', ((1,), (1,),), + _Cfunction('libvlc_media_player_set_position', ((1,), (1,),), None, None, MediaPlayer, ctypes.c_float) if not __debug__: # i.e. python -O or -OO global libvlc_media_player_set_position @@ -4350,7 +4472,7 @@ def libvlc_media_player_set_chapter(p_mi, i_chapter): @param i_chapter: chapter number to play. ''' f = _Cfunctions.get('libvlc_media_player_set_chapter', None) or \ - _Cfunction('libvlc_media_player_set_chapter', ((1,), (1,),), + _Cfunction('libvlc_media_player_set_chapter', ((1,), (1,),), None, None, MediaPlayer, ctypes.c_int) if not __debug__: # i.e. python -O or -OO global libvlc_media_player_set_chapter @@ -4363,7 +4485,7 @@ def libvlc_media_player_get_chapter(p_mi): @return: chapter number currently playing, or -1 if there is no media. ''' f = _Cfunctions.get('libvlc_media_player_get_chapter', None) or \ - _Cfunction('libvlc_media_player_get_chapter', ((1,),), + _Cfunction('libvlc_media_player_get_chapter', ((1,),), None, ctypes.c_int, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_media_player_get_chapter @@ -4376,7 +4498,7 @@ def libvlc_media_player_get_chapter_count(p_mi): @return: number of chapters in movie, or -1. ''' f = _Cfunctions.get('libvlc_media_player_get_chapter_count', None) or \ - _Cfunction('libvlc_media_player_get_chapter_count', ((1,),), + _Cfunction('libvlc_media_player_get_chapter_count', ((1,),), None, ctypes.c_int, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_media_player_get_chapter_count @@ -4389,7 +4511,7 @@ def libvlc_media_player_will_play(p_mi): @return: boolean. ''' f = _Cfunctions.get('libvlc_media_player_will_play', None) or \ - _Cfunction('libvlc_media_player_will_play', ((1,),), + _Cfunction('libvlc_media_player_will_play', ((1,),), None, ctypes.c_int, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_media_player_will_play @@ -4403,7 +4525,7 @@ def libvlc_media_player_get_chapter_count_for_title(p_mi, i_title): @return: number of chapters in title, or -1. ''' f = _Cfunctions.get('libvlc_media_player_get_chapter_count_for_title', None) or \ - _Cfunction('libvlc_media_player_get_chapter_count_for_title', ((1,), (1,),), + _Cfunction('libvlc_media_player_get_chapter_count_for_title', ((1,), (1,),), None, ctypes.c_int, MediaPlayer, ctypes.c_int) if not __debug__: # i.e. python -O or -OO global libvlc_media_player_get_chapter_count_for_title @@ -4416,7 +4538,7 @@ def libvlc_media_player_set_title(p_mi, i_title): @param i_title: title number to play. ''' f = _Cfunctions.get('libvlc_media_player_set_title', None) or \ - _Cfunction('libvlc_media_player_set_title', ((1,), (1,),), + _Cfunction('libvlc_media_player_set_title', ((1,), (1,),), None, None, MediaPlayer, ctypes.c_int) if not __debug__: # i.e. python -O or -OO global libvlc_media_player_set_title @@ -4429,7 +4551,7 @@ def libvlc_media_player_get_title(p_mi): @return: title number currently playing, or -1. ''' f = _Cfunctions.get('libvlc_media_player_get_title', None) or \ - _Cfunction('libvlc_media_player_get_title', ((1,),), + _Cfunction('libvlc_media_player_get_title', ((1,),), None, ctypes.c_int, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_media_player_get_title @@ -4442,7 +4564,7 @@ def libvlc_media_player_get_title_count(p_mi): @return: title number count, or -1. ''' f = _Cfunctions.get('libvlc_media_player_get_title_count', None) or \ - _Cfunction('libvlc_media_player_get_title_count', ((1,),), + _Cfunction('libvlc_media_player_get_title_count', ((1,),), None, ctypes.c_int, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_media_player_get_title_count @@ -4454,7 +4576,7 @@ def libvlc_media_player_previous_chapter(p_mi): @param p_mi: the Media Player. ''' f = _Cfunctions.get('libvlc_media_player_previous_chapter', None) or \ - _Cfunction('libvlc_media_player_previous_chapter', ((1,),), + _Cfunction('libvlc_media_player_previous_chapter', ((1,),), None, None, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_media_player_previous_chapter @@ -4466,7 +4588,7 @@ def libvlc_media_player_next_chapter(p_mi): @param p_mi: the Media Player. ''' f = _Cfunctions.get('libvlc_media_player_next_chapter', None) or \ - _Cfunction('libvlc_media_player_next_chapter', ((1,),), + _Cfunction('libvlc_media_player_next_chapter', ((1,),), None, None, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_media_player_next_chapter @@ -4481,7 +4603,7 @@ def libvlc_media_player_get_rate(p_mi): @return: movie play rate. ''' f = _Cfunctions.get('libvlc_media_player_get_rate', None) or \ - _Cfunction('libvlc_media_player_get_rate', ((1,),), + _Cfunction('libvlc_media_player_get_rate', ((1,),), None, ctypes.c_float, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_media_player_get_rate @@ -4495,7 +4617,7 @@ def libvlc_media_player_set_rate(p_mi, rate): @return: -1 if an error was detected, 0 otherwise (but even then, it might not actually work depending on the underlying media protocol). ''' f = _Cfunctions.get('libvlc_media_player_set_rate', None) or \ - _Cfunction('libvlc_media_player_set_rate', ((1,), (1,),), + _Cfunction('libvlc_media_player_set_rate', ((1,), (1,),), None, ctypes.c_int, MediaPlayer, ctypes.c_float) if not __debug__: # i.e. python -O or -OO global libvlc_media_player_set_rate @@ -4508,7 +4630,7 @@ def libvlc_media_player_get_state(p_mi): @return: the current state of the media player (playing, paused, ...) See libvlc_state_t. ''' f = _Cfunctions.get('libvlc_media_player_get_state', None) or \ - _Cfunction('libvlc_media_player_get_state', ((1,),), + _Cfunction('libvlc_media_player_get_state', ((1,),), None, State, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_media_player_get_state @@ -4521,7 +4643,7 @@ def libvlc_media_player_get_fps(p_mi): @return: frames per second (fps) for this playing movie, or 0 if unspecified. ''' f = _Cfunctions.get('libvlc_media_player_get_fps', None) or \ - _Cfunction('libvlc_media_player_get_fps', ((1,),), + _Cfunction('libvlc_media_player_get_fps', ((1,),), None, ctypes.c_float, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_media_player_get_fps @@ -4534,7 +4656,7 @@ def libvlc_media_player_has_vout(p_mi): @return: the number of video outputs. ''' f = _Cfunctions.get('libvlc_media_player_has_vout', None) or \ - _Cfunction('libvlc_media_player_has_vout', ((1,),), + _Cfunction('libvlc_media_player_has_vout', ((1,),), None, ctypes.c_uint, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_media_player_has_vout @@ -4547,7 +4669,7 @@ def libvlc_media_player_is_seekable(p_mi): @return: true if the media player can seek. ''' f = _Cfunctions.get('libvlc_media_player_is_seekable', None) or \ - _Cfunction('libvlc_media_player_is_seekable', ((1,),), + _Cfunction('libvlc_media_player_is_seekable', ((1,),), None, ctypes.c_int, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_media_player_is_seekable @@ -4560,7 +4682,7 @@ def libvlc_media_player_can_pause(p_mi): @return: true if the media player can pause. ''' f = _Cfunctions.get('libvlc_media_player_can_pause', None) or \ - _Cfunction('libvlc_media_player_can_pause', ((1,),), + _Cfunction('libvlc_media_player_can_pause', ((1,),), None, ctypes.c_int, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_media_player_can_pause @@ -4572,7 +4694,7 @@ def libvlc_media_player_next_frame(p_mi): @param p_mi: the media player. ''' f = _Cfunctions.get('libvlc_media_player_next_frame', None) or \ - _Cfunction('libvlc_media_player_next_frame', ((1,),), + _Cfunction('libvlc_media_player_next_frame', ((1,),), None, None, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_media_player_next_frame @@ -4586,7 +4708,7 @@ def libvlc_media_player_navigate(p_mi, navigate): @version: libVLC 1.2.0 or later. ''' f = _Cfunctions.get('libvlc_media_player_navigate', None) or \ - _Cfunction('libvlc_media_player_navigate', ((1,), (1,),), + _Cfunction('libvlc_media_player_navigate', ((1,), (1,),), None, None, MediaPlayer, ctypes.c_uint) if not __debug__: # i.e. python -O or -OO global libvlc_media_player_navigate @@ -4598,7 +4720,7 @@ def libvlc_track_description_release(p_track_description): @param p_track_description: the structure to release. ''' f = _Cfunctions.get('libvlc_track_description_release', None) or \ - _Cfunction('libvlc_track_description_release', ((1,),), + _Cfunction('libvlc_track_description_release', ((1,),), None, None, ctypes.POINTER(TrackDescription)) if not __debug__: # i.e. python -O or -OO global libvlc_track_description_release @@ -4612,7 +4734,7 @@ def libvlc_toggle_fullscreen(p_mi): @param p_mi: the media player. ''' f = _Cfunctions.get('libvlc_toggle_fullscreen', None) or \ - _Cfunction('libvlc_toggle_fullscreen', ((1,),), + _Cfunction('libvlc_toggle_fullscreen', ((1,),), None, None, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_toggle_fullscreen @@ -4631,7 +4753,7 @@ def libvlc_set_fullscreen(p_mi, b_fullscreen): @param b_fullscreen: boolean for fullscreen status. ''' f = _Cfunctions.get('libvlc_set_fullscreen', None) or \ - _Cfunction('libvlc_set_fullscreen', ((1,), (1,),), + _Cfunction('libvlc_set_fullscreen', ((1,), (1,),), None, None, MediaPlayer, ctypes.c_int) if not __debug__: # i.e. python -O or -OO global libvlc_set_fullscreen @@ -4644,7 +4766,7 @@ def libvlc_get_fullscreen(p_mi): @return: the fullscreen status (boolean). ''' f = _Cfunctions.get('libvlc_get_fullscreen', None) or \ - _Cfunction('libvlc_get_fullscreen', ((1,),), + _Cfunction('libvlc_get_fullscreen', ((1,),), None, ctypes.c_int, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_get_fullscreen @@ -4664,7 +4786,7 @@ def libvlc_video_set_key_input(p_mi, on): @param on: true to handle key press events, false to ignore them. ''' f = _Cfunctions.get('libvlc_video_set_key_input', None) or \ - _Cfunction('libvlc_video_set_key_input', ((1,), (1,),), + _Cfunction('libvlc_video_set_key_input', ((1,), (1,),), None, None, MediaPlayer, ctypes.c_uint) if not __debug__: # i.e. python -O or -OO global libvlc_video_set_key_input @@ -4681,7 +4803,7 @@ def libvlc_video_set_mouse_input(p_mi, on): @param on: true to handle mouse click events, false to ignore them. ''' f = _Cfunctions.get('libvlc_video_set_mouse_input', None) or \ - _Cfunction('libvlc_video_set_mouse_input', ((1,), (1,),), + _Cfunction('libvlc_video_set_mouse_input', ((1,), (1,),), None, None, MediaPlayer, ctypes.c_uint) if not __debug__: # i.e. python -O or -OO global libvlc_video_set_mouse_input @@ -4695,7 +4817,7 @@ def libvlc_video_get_size(p_mi, num): @return: px pixel width, py pixel height. ''' f = _Cfunctions.get('libvlc_video_get_size', None) or \ - _Cfunction('libvlc_video_get_size', ((1,), (1,), (2,), (2,),), + _Cfunction('libvlc_video_get_size', ((1,), (1,), (2,), (2,),), None, ctypes.c_int, MediaPlayer, ctypes.c_uint, ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint)) if not __debug__: # i.e. python -O or -OO global libvlc_video_get_size @@ -4719,7 +4841,7 @@ def libvlc_video_get_cursor(p_mi, num): @return: px abscissa, py ordinate. ''' f = _Cfunctions.get('libvlc_video_get_cursor', None) or \ - _Cfunction('libvlc_video_get_cursor', ((1,), (1,), (2,), (2,),), + _Cfunction('libvlc_video_get_cursor', ((1,), (1,), (2,), (2,),), None, ctypes.c_int, MediaPlayer, ctypes.c_uint, ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_int)) if not __debug__: # i.e. python -O or -OO global libvlc_video_get_cursor @@ -4733,7 +4855,7 @@ def libvlc_video_get_scale(p_mi): @return: the currently configured zoom factor, or 0. if the video is set to fit to the output window/drawable automatically. ''' f = _Cfunctions.get('libvlc_video_get_scale', None) or \ - _Cfunction('libvlc_video_get_scale', ((1,),), + _Cfunction('libvlc_video_get_scale', ((1,),), None, ctypes.c_float, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_video_get_scale @@ -4750,7 +4872,7 @@ def libvlc_video_set_scale(p_mi, f_factor): @param f_factor: the scaling factor, or zero. ''' f = _Cfunctions.get('libvlc_video_set_scale', None) or \ - _Cfunction('libvlc_video_set_scale', ((1,), (1,),), + _Cfunction('libvlc_video_set_scale', ((1,), (1,),), None, None, MediaPlayer, ctypes.c_float) if not __debug__: # i.e. python -O or -OO global libvlc_video_set_scale @@ -4763,8 +4885,8 @@ def libvlc_video_get_aspect_ratio(p_mi): @return: the video aspect ratio or NULL if unspecified (the result must be released with free() or L{libvlc_free}()). ''' f = _Cfunctions.get('libvlc_video_get_aspect_ratio', None) or \ - _Cfunction('libvlc_video_get_aspect_ratio', ((1,),), - ctypes.c_char_p, MediaPlayer) + _Cfunction('libvlc_video_get_aspect_ratio', ((1,),), string_result, + ctypes.c_void_p, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_video_get_aspect_ratio libvlc_video_get_aspect_ratio = f @@ -4776,7 +4898,7 @@ def libvlc_video_set_aspect_ratio(p_mi, psz_aspect): @param psz_aspect: new video aspect-ratio or NULL to reset to default @note Invalid aspect ratios are ignored. ''' f = _Cfunctions.get('libvlc_video_set_aspect_ratio', None) or \ - _Cfunction('libvlc_video_set_aspect_ratio', ((1,), (1,),), + _Cfunction('libvlc_video_set_aspect_ratio', ((1,), (1,),), None, None, MediaPlayer, ctypes.c_char_p) if not __debug__: # i.e. python -O or -OO global libvlc_video_set_aspect_ratio @@ -4789,7 +4911,7 @@ def libvlc_video_get_spu(p_mi): @return: the video subtitle selected, or -1 if none. ''' f = _Cfunctions.get('libvlc_video_get_spu', None) or \ - _Cfunction('libvlc_video_get_spu', ((1,),), + _Cfunction('libvlc_video_get_spu', ((1,),), None, ctypes.c_int, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_video_get_spu @@ -4802,7 +4924,7 @@ def libvlc_video_get_spu_count(p_mi): @return: the number of available video subtitles. ''' f = _Cfunctions.get('libvlc_video_get_spu_count', None) or \ - _Cfunction('libvlc_video_get_spu_count', ((1,),), + _Cfunction('libvlc_video_get_spu_count', ((1,),), None, ctypes.c_int, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_video_get_spu_count @@ -4815,7 +4937,7 @@ def libvlc_video_get_spu_description(p_mi): @return: list containing description of available video subtitles. ''' f = _Cfunctions.get('libvlc_video_get_spu_description', None) or \ - _Cfunction('libvlc_video_get_spu_description', ((1,),), + _Cfunction('libvlc_video_get_spu_description', ((1,),), None, ctypes.POINTER(TrackDescription), MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_video_get_spu_description @@ -4829,7 +4951,7 @@ def libvlc_video_set_spu(p_mi, i_spu): @return: 0 on success, -1 if out of range. ''' f = _Cfunctions.get('libvlc_video_set_spu', None) or \ - _Cfunction('libvlc_video_set_spu', ((1,), (1,),), + _Cfunction('libvlc_video_set_spu', ((1,), (1,),), None, ctypes.c_int, MediaPlayer, ctypes.c_uint) if not __debug__: # i.e. python -O or -OO global libvlc_video_set_spu @@ -4843,7 +4965,7 @@ def libvlc_video_set_subtitle_file(p_mi, psz_subtitle): @return: the success status (boolean). ''' f = _Cfunctions.get('libvlc_video_set_subtitle_file', None) or \ - _Cfunction('libvlc_video_set_subtitle_file', ((1,), (1,),), + _Cfunction('libvlc_video_set_subtitle_file', ((1,), (1,),), None, ctypes.c_int, MediaPlayer, ctypes.c_char_p) if not __debug__: # i.e. python -O or -OO global libvlc_video_set_subtitle_file @@ -4856,7 +4978,7 @@ def libvlc_video_get_title_description(p_mi): @return: list containing description of available titles. ''' f = _Cfunctions.get('libvlc_video_get_title_description', None) or \ - _Cfunction('libvlc_video_get_title_description', ((1,),), + _Cfunction('libvlc_video_get_title_description', ((1,),), None, ctypes.POINTER(TrackDescription), MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_video_get_title_description @@ -4870,7 +4992,7 @@ def libvlc_video_get_chapter_description(p_mi, i_title): @return: list containing description of available chapter for title i_title. ''' f = _Cfunctions.get('libvlc_video_get_chapter_description', None) or \ - _Cfunction('libvlc_video_get_chapter_description', ((1,), (1,),), + _Cfunction('libvlc_video_get_chapter_description', ((1,), (1,),), None, ctypes.POINTER(TrackDescription), MediaPlayer, ctypes.c_int) if not __debug__: # i.e. python -O or -OO global libvlc_video_get_chapter_description @@ -4883,8 +5005,8 @@ def libvlc_video_get_crop_geometry(p_mi): @return: the crop filter geometry or NULL if unset. ''' f = _Cfunctions.get('libvlc_video_get_crop_geometry', None) or \ - _Cfunction('libvlc_video_get_crop_geometry', ((1,),), - ctypes.c_char_p, MediaPlayer) + _Cfunction('libvlc_video_get_crop_geometry', ((1,),), string_result, + ctypes.c_void_p, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_video_get_crop_geometry libvlc_video_get_crop_geometry = f @@ -4896,7 +5018,7 @@ def libvlc_video_set_crop_geometry(p_mi, psz_geometry): @param psz_geometry: new crop filter geometry (NULL to unset). ''' f = _Cfunctions.get('libvlc_video_set_crop_geometry', None) or \ - _Cfunction('libvlc_video_set_crop_geometry', ((1,), (1,),), + _Cfunction('libvlc_video_set_crop_geometry', ((1,), (1,),), None, None, MediaPlayer, ctypes.c_char_p) if not __debug__: # i.e. python -O or -OO global libvlc_video_set_crop_geometry @@ -4909,7 +5031,7 @@ def libvlc_video_get_teletext(p_mi): @return: the current teletext page requested. ''' f = _Cfunctions.get('libvlc_video_get_teletext', None) or \ - _Cfunction('libvlc_video_get_teletext', ((1,),), + _Cfunction('libvlc_video_get_teletext', ((1,),), None, ctypes.c_int, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_video_get_teletext @@ -4922,7 +5044,7 @@ def libvlc_video_set_teletext(p_mi, i_page): @param i_page: teletex page number requested. ''' f = _Cfunctions.get('libvlc_video_set_teletext', None) or \ - _Cfunction('libvlc_video_set_teletext', ((1,), (1,),), + _Cfunction('libvlc_video_set_teletext', ((1,), (1,),), None, None, MediaPlayer, ctypes.c_int) if not __debug__: # i.e. python -O or -OO global libvlc_video_set_teletext @@ -4934,7 +5056,7 @@ def libvlc_toggle_teletext(p_mi): @param p_mi: the media player. ''' f = _Cfunctions.get('libvlc_toggle_teletext', None) or \ - _Cfunction('libvlc_toggle_teletext', ((1,),), + _Cfunction('libvlc_toggle_teletext', ((1,),), None, None, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_toggle_teletext @@ -4947,7 +5069,7 @@ def libvlc_video_get_track_count(p_mi): @return: the number of available video tracks (int). ''' f = _Cfunctions.get('libvlc_video_get_track_count', None) or \ - _Cfunction('libvlc_video_get_track_count', ((1,),), + _Cfunction('libvlc_video_get_track_count', ((1,),), None, ctypes.c_int, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_video_get_track_count @@ -4960,7 +5082,7 @@ def libvlc_video_get_track_description(p_mi): @return: list with description of available video tracks, or NULL on error. ''' f = _Cfunctions.get('libvlc_video_get_track_description', None) or \ - _Cfunction('libvlc_video_get_track_description', ((1,),), + _Cfunction('libvlc_video_get_track_description', ((1,),), None, ctypes.POINTER(TrackDescription), MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_video_get_track_description @@ -4973,7 +5095,7 @@ def libvlc_video_get_track(p_mi): @return: the video track (int) or -1 if none. ''' f = _Cfunctions.get('libvlc_video_get_track', None) or \ - _Cfunction('libvlc_video_get_track', ((1,),), + _Cfunction('libvlc_video_get_track', ((1,),), None, ctypes.c_int, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_video_get_track @@ -4987,7 +5109,7 @@ def libvlc_video_set_track(p_mi, i_track): @return: 0 on success, -1 if out of range. ''' f = _Cfunctions.get('libvlc_video_set_track', None) or \ - _Cfunction('libvlc_video_set_track', ((1,), (1,),), + _Cfunction('libvlc_video_set_track', ((1,), (1,),), None, ctypes.c_int, MediaPlayer, ctypes.c_int) if not __debug__: # i.e. python -O or -OO global libvlc_video_set_track @@ -5006,7 +5128,7 @@ def libvlc_video_take_snapshot(p_mi, num, psz_filepath, i_width, i_height): @return: 0 on success, -1 if the video was not found. ''' f = _Cfunctions.get('libvlc_video_take_snapshot', None) or \ - _Cfunction('libvlc_video_take_snapshot', ((1,), (1,), (1,), (1,), (1,),), + _Cfunction('libvlc_video_take_snapshot', ((1,), (1,), (1,), (1,), (1,),), None, ctypes.c_int, MediaPlayer, ctypes.c_uint, ctypes.c_char_p, ctypes.c_int, ctypes.c_int) if not __debug__: # i.e. python -O or -OO global libvlc_video_take_snapshot @@ -5019,7 +5141,7 @@ def libvlc_video_set_deinterlace(p_mi, psz_mode): @param psz_mode: type of deinterlace filter, NULL to disable. ''' f = _Cfunctions.get('libvlc_video_set_deinterlace', None) or \ - _Cfunction('libvlc_video_set_deinterlace', ((1,), (1,),), + _Cfunction('libvlc_video_set_deinterlace', ((1,), (1,),), None, None, MediaPlayer, ctypes.c_char_p) if not __debug__: # i.e. python -O or -OO global libvlc_video_set_deinterlace @@ -5032,7 +5154,7 @@ def libvlc_video_get_marquee_int(p_mi, option): @param option: marq option to get See libvlc_video_marquee_int_option_t. ''' f = _Cfunctions.get('libvlc_video_get_marquee_int', None) or \ - _Cfunction('libvlc_video_get_marquee_int', ((1,), (1,),), + _Cfunction('libvlc_video_get_marquee_int', ((1,), (1,),), None, ctypes.c_int, MediaPlayer, ctypes.c_uint) if not __debug__: # i.e. python -O or -OO global libvlc_video_get_marquee_int @@ -5045,8 +5167,8 @@ def libvlc_video_get_marquee_string(p_mi, option): @param option: marq option to get See libvlc_video_marquee_string_option_t. ''' f = _Cfunctions.get('libvlc_video_get_marquee_string', None) or \ - _Cfunction('libvlc_video_get_marquee_string', ((1,), (1,),), - ctypes.c_char_p, MediaPlayer, ctypes.c_uint) + _Cfunction('libvlc_video_get_marquee_string', ((1,), (1,),), string_result, + ctypes.c_void_p, MediaPlayer, ctypes.c_uint) if not __debug__: # i.e. python -O or -OO global libvlc_video_get_marquee_string libvlc_video_get_marquee_string = f @@ -5061,7 +5183,7 @@ def libvlc_video_set_marquee_int(p_mi, option, i_val): @param i_val: marq option value. ''' f = _Cfunctions.get('libvlc_video_set_marquee_int', None) or \ - _Cfunction('libvlc_video_set_marquee_int', ((1,), (1,), (1,),), + _Cfunction('libvlc_video_set_marquee_int', ((1,), (1,), (1,),), None, None, MediaPlayer, ctypes.c_uint, ctypes.c_int) if not __debug__: # i.e. python -O or -OO global libvlc_video_set_marquee_int @@ -5075,7 +5197,7 @@ def libvlc_video_set_marquee_string(p_mi, option, psz_text): @param psz_text: marq option value. ''' f = _Cfunctions.get('libvlc_video_set_marquee_string', None) or \ - _Cfunction('libvlc_video_set_marquee_string', ((1,), (1,), (1,),), + _Cfunction('libvlc_video_set_marquee_string', ((1,), (1,), (1,),), None, None, MediaPlayer, ctypes.c_uint, ctypes.c_char_p) if not __debug__: # i.e. python -O or -OO global libvlc_video_set_marquee_string @@ -5088,7 +5210,7 @@ def libvlc_video_get_logo_int(p_mi, option): @param option: logo option to get, values of libvlc_video_logo_option_t. ''' f = _Cfunctions.get('libvlc_video_get_logo_int', None) or \ - _Cfunction('libvlc_video_get_logo_int', ((1,), (1,),), + _Cfunction('libvlc_video_get_logo_int', ((1,), (1,),), None, ctypes.c_int, MediaPlayer, ctypes.c_uint) if not __debug__: # i.e. python -O or -OO global libvlc_video_get_logo_int @@ -5105,7 +5227,7 @@ def libvlc_video_set_logo_int(p_mi, option, value): @param value: logo option value. ''' f = _Cfunctions.get('libvlc_video_set_logo_int', None) or \ - _Cfunction('libvlc_video_set_logo_int', ((1,), (1,), (1,),), + _Cfunction('libvlc_video_set_logo_int', ((1,), (1,), (1,),), None, None, MediaPlayer, ctypes.c_uint, ctypes.c_int) if not __debug__: # i.e. python -O or -OO global libvlc_video_set_logo_int @@ -5120,7 +5242,7 @@ def libvlc_video_set_logo_string(p_mi, option, psz_value): @param psz_value: logo option value. ''' f = _Cfunctions.get('libvlc_video_set_logo_string', None) or \ - _Cfunction('libvlc_video_set_logo_string', ((1,), (1,), (1,),), + _Cfunction('libvlc_video_set_logo_string', ((1,), (1,), (1,),), None, None, MediaPlayer, ctypes.c_uint, ctypes.c_char_p) if not __debug__: # i.e. python -O or -OO global libvlc_video_set_logo_string @@ -5134,7 +5256,7 @@ def libvlc_video_get_adjust_int(p_mi, option): @version: LibVLC 1.1.1 and later. ''' f = _Cfunctions.get('libvlc_video_get_adjust_int', None) or \ - _Cfunction('libvlc_video_get_adjust_int', ((1,), (1,),), + _Cfunction('libvlc_video_get_adjust_int', ((1,), (1,),), None, ctypes.c_int, MediaPlayer, ctypes.c_uint) if not __debug__: # i.e. python -O or -OO global libvlc_video_get_adjust_int @@ -5152,7 +5274,7 @@ def libvlc_video_set_adjust_int(p_mi, option, value): @version: LibVLC 1.1.1 and later. ''' f = _Cfunctions.get('libvlc_video_set_adjust_int', None) or \ - _Cfunction('libvlc_video_set_adjust_int', ((1,), (1,), (1,),), + _Cfunction('libvlc_video_set_adjust_int', ((1,), (1,), (1,),), None, None, MediaPlayer, ctypes.c_uint, ctypes.c_int) if not __debug__: # i.e. python -O or -OO global libvlc_video_set_adjust_int @@ -5166,7 +5288,7 @@ def libvlc_video_get_adjust_float(p_mi, option): @version: LibVLC 1.1.1 and later. ''' f = _Cfunctions.get('libvlc_video_get_adjust_float', None) or \ - _Cfunction('libvlc_video_get_adjust_float', ((1,), (1,),), + _Cfunction('libvlc_video_get_adjust_float', ((1,), (1,),), None, ctypes.c_float, MediaPlayer, ctypes.c_uint) if not __debug__: # i.e. python -O or -OO global libvlc_video_get_adjust_float @@ -5182,7 +5304,7 @@ def libvlc_video_set_adjust_float(p_mi, option, value): @version: LibVLC 1.1.1 and later. ''' f = _Cfunctions.get('libvlc_video_set_adjust_float', None) or \ - _Cfunction('libvlc_video_set_adjust_float', ((1,), (1,), (1,),), + _Cfunction('libvlc_video_set_adjust_float', ((1,), (1,), (1,),), None, None, MediaPlayer, ctypes.c_uint, ctypes.c_float) if not __debug__: # i.e. python -O or -OO global libvlc_video_set_adjust_float @@ -5195,7 +5317,7 @@ def libvlc_audio_output_list_get(p_instance): @return: list of available audio outputs. It must be freed it with In case of error, NULL is returned. ''' f = _Cfunctions.get('libvlc_audio_output_list_get', None) or \ - _Cfunction('libvlc_audio_output_list_get', ((1,),), + _Cfunction('libvlc_audio_output_list_get', ((1,),), None, ctypes.POINTER(AudioOutput), Instance) if not __debug__: # i.e. python -O or -OO global libvlc_audio_output_list_get @@ -5207,7 +5329,7 @@ def libvlc_audio_output_list_release(p_list): @param p_list: list with audio outputs for release. ''' f = _Cfunctions.get('libvlc_audio_output_list_release', None) or \ - _Cfunction('libvlc_audio_output_list_release', ((1,),), + _Cfunction('libvlc_audio_output_list_release', ((1,),), None, None, ctypes.POINTER(AudioOutput)) if not __debug__: # i.e. python -O or -OO global libvlc_audio_output_list_release @@ -5222,7 +5344,7 @@ def libvlc_audio_output_set(p_mi, psz_name): @return: true if function succeded. ''' f = _Cfunctions.get('libvlc_audio_output_set', None) or \ - _Cfunction('libvlc_audio_output_set', ((1,), (1,),), + _Cfunction('libvlc_audio_output_set', ((1,), (1,),), None, ctypes.c_int, MediaPlayer, ctypes.c_char_p) if not __debug__: # i.e. python -O or -OO global libvlc_audio_output_set @@ -5237,7 +5359,7 @@ def libvlc_audio_output_device_count(p_instance, psz_audio_output): @return: number of devices. ''' f = _Cfunctions.get('libvlc_audio_output_device_count', None) or \ - _Cfunction('libvlc_audio_output_device_count', ((1,), (1,),), + _Cfunction('libvlc_audio_output_device_count', ((1,), (1,),), None, ctypes.c_int, Instance, ctypes.c_char_p) if not __debug__: # i.e. python -O or -OO global libvlc_audio_output_device_count @@ -5252,8 +5374,8 @@ def libvlc_audio_output_device_longname(p_instance, psz_audio_output, i_device): @return: long name of device. ''' f = _Cfunctions.get('libvlc_audio_output_device_longname', None) or \ - _Cfunction('libvlc_audio_output_device_longname', ((1,), (1,), (1,),), - ctypes.c_char_p, Instance, ctypes.c_char_p, ctypes.c_int) + _Cfunction('libvlc_audio_output_device_longname', ((1,), (1,), (1,),), string_result, + ctypes.c_void_p, Instance, ctypes.c_char_p, ctypes.c_int) if not __debug__: # i.e. python -O or -OO global libvlc_audio_output_device_longname libvlc_audio_output_device_longname = f @@ -5267,8 +5389,8 @@ def libvlc_audio_output_device_id(p_instance, psz_audio_output, i_device): @return: id name of device, use for setting device, need to be free after use. ''' f = _Cfunctions.get('libvlc_audio_output_device_id', None) or \ - _Cfunction('libvlc_audio_output_device_id', ((1,), (1,), (1,),), - ctypes.c_char_p, Instance, ctypes.c_char_p, ctypes.c_int) + _Cfunction('libvlc_audio_output_device_id', ((1,), (1,), (1,),), string_result, + ctypes.c_void_p, Instance, ctypes.c_char_p, ctypes.c_int) if not __debug__: # i.e. python -O or -OO global libvlc_audio_output_device_id libvlc_audio_output_device_id = f @@ -5281,7 +5403,7 @@ def libvlc_audio_output_device_set(p_mi, psz_audio_output, psz_device_id): @param psz_device_id: device. ''' f = _Cfunctions.get('libvlc_audio_output_device_set', None) or \ - _Cfunction('libvlc_audio_output_device_set', ((1,), (1,), (1,),), + _Cfunction('libvlc_audio_output_device_set', ((1,), (1,), (1,),), None, None, MediaPlayer, ctypes.c_char_p, ctypes.c_char_p) if not __debug__: # i.e. python -O or -OO global libvlc_audio_output_device_set @@ -5295,7 +5417,7 @@ def libvlc_audio_output_get_device_type(p_mi): @return: the audio devices type See libvlc_audio_output_device_types_t. ''' f = _Cfunctions.get('libvlc_audio_output_get_device_type', None) or \ - _Cfunction('libvlc_audio_output_get_device_type', ((1,),), + _Cfunction('libvlc_audio_output_get_device_type', ((1,),), None, ctypes.c_int, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_audio_output_get_device_type @@ -5308,7 +5430,7 @@ def libvlc_audio_output_set_device_type(p_mi, device_type): @param device_type: the audio device type, ''' f = _Cfunctions.get('libvlc_audio_output_set_device_type', None) or \ - _Cfunction('libvlc_audio_output_set_device_type', ((1,), (1,),), + _Cfunction('libvlc_audio_output_set_device_type', ((1,), (1,),), None, None, MediaPlayer, ctypes.c_int) if not __debug__: # i.e. python -O or -OO global libvlc_audio_output_set_device_type @@ -5320,7 +5442,7 @@ def libvlc_audio_toggle_mute(p_mi): @param p_mi: media player. ''' f = _Cfunctions.get('libvlc_audio_toggle_mute', None) or \ - _Cfunction('libvlc_audio_toggle_mute', ((1,),), + _Cfunction('libvlc_audio_toggle_mute', ((1,),), None, None, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_audio_toggle_mute @@ -5333,7 +5455,7 @@ def libvlc_audio_get_mute(p_mi): @return: the mute status (boolean). ''' f = _Cfunctions.get('libvlc_audio_get_mute', None) or \ - _Cfunction('libvlc_audio_get_mute', ((1,),), + _Cfunction('libvlc_audio_get_mute', ((1,),), None, ctypes.c_int, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_audio_get_mute @@ -5346,7 +5468,7 @@ def libvlc_audio_set_mute(p_mi, status): @param status: If status is true then mute, otherwise unmute. ''' f = _Cfunctions.get('libvlc_audio_set_mute', None) or \ - _Cfunction('libvlc_audio_set_mute', ((1,), (1,),), + _Cfunction('libvlc_audio_set_mute', ((1,), (1,),), None, None, MediaPlayer, ctypes.c_int) if not __debug__: # i.e. python -O or -OO global libvlc_audio_set_mute @@ -5359,7 +5481,7 @@ def libvlc_audio_get_volume(p_mi): @return: the audio level (int). ''' f = _Cfunctions.get('libvlc_audio_get_volume', None) or \ - _Cfunction('libvlc_audio_get_volume', ((1,),), + _Cfunction('libvlc_audio_get_volume', ((1,),), None, ctypes.c_int, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_audio_get_volume @@ -5373,7 +5495,7 @@ def libvlc_audio_set_volume(p_mi, i_volume): @return: 0 if the volume was set, -1 if it was out of range. ''' f = _Cfunctions.get('libvlc_audio_set_volume', None) or \ - _Cfunction('libvlc_audio_set_volume', ((1,), (1,),), + _Cfunction('libvlc_audio_set_volume', ((1,), (1,),), None, ctypes.c_int, MediaPlayer, ctypes.c_int) if not __debug__: # i.e. python -O or -OO global libvlc_audio_set_volume @@ -5386,7 +5508,7 @@ def libvlc_audio_get_track_count(p_mi): @return: the number of available audio tracks (int), or -1 if unavailable. ''' f = _Cfunctions.get('libvlc_audio_get_track_count', None) or \ - _Cfunction('libvlc_audio_get_track_count', ((1,),), + _Cfunction('libvlc_audio_get_track_count', ((1,),), None, ctypes.c_int, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_audio_get_track_count @@ -5399,7 +5521,7 @@ def libvlc_audio_get_track_description(p_mi): @return: list with description of available audio tracks, or NULL. ''' f = _Cfunctions.get('libvlc_audio_get_track_description', None) or \ - _Cfunction('libvlc_audio_get_track_description', ((1,),), + _Cfunction('libvlc_audio_get_track_description', ((1,),), None, ctypes.POINTER(TrackDescription), MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_audio_get_track_description @@ -5412,7 +5534,7 @@ def libvlc_audio_get_track(p_mi): @return: the audio track (int), or -1 if none. ''' f = _Cfunctions.get('libvlc_audio_get_track', None) or \ - _Cfunction('libvlc_audio_get_track', ((1,),), + _Cfunction('libvlc_audio_get_track', ((1,),), None, ctypes.c_int, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_audio_get_track @@ -5426,7 +5548,7 @@ def libvlc_audio_set_track(p_mi, i_track): @return: 0 on success, -1 on error. ''' f = _Cfunctions.get('libvlc_audio_set_track', None) or \ - _Cfunction('libvlc_audio_set_track', ((1,), (1,),), + _Cfunction('libvlc_audio_set_track', ((1,), (1,),), None, ctypes.c_int, MediaPlayer, ctypes.c_int) if not __debug__: # i.e. python -O or -OO global libvlc_audio_set_track @@ -5439,7 +5561,7 @@ def libvlc_audio_get_channel(p_mi): @return: the audio channel See libvlc_audio_output_channel_t. ''' f = _Cfunctions.get('libvlc_audio_get_channel', None) or \ - _Cfunction('libvlc_audio_get_channel', ((1,),), + _Cfunction('libvlc_audio_get_channel', ((1,),), None, ctypes.c_int, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_audio_get_channel @@ -5453,7 +5575,7 @@ def libvlc_audio_set_channel(p_mi, channel): @return: 0 on success, -1 on error. ''' f = _Cfunctions.get('libvlc_audio_set_channel', None) or \ - _Cfunction('libvlc_audio_set_channel', ((1,), (1,),), + _Cfunction('libvlc_audio_set_channel', ((1,), (1,),), None, ctypes.c_int, MediaPlayer, ctypes.c_int) if not __debug__: # i.e. python -O or -OO global libvlc_audio_set_channel @@ -5467,7 +5589,7 @@ def libvlc_audio_get_delay(p_mi): @version: LibVLC 1.1.1 or later. ''' f = _Cfunctions.get('libvlc_audio_get_delay', None) or \ - _Cfunction('libvlc_audio_get_delay', ((1,),), + _Cfunction('libvlc_audio_get_delay', ((1,),), None, ctypes.c_int64, MediaPlayer) if not __debug__: # i.e. python -O or -OO global libvlc_audio_get_delay @@ -5482,7 +5604,7 @@ def libvlc_audio_set_delay(p_mi, i_delay): @version: LibVLC 1.1.1 or later. ''' f = _Cfunctions.get('libvlc_audio_set_delay', None) or \ - _Cfunction('libvlc_audio_set_delay', ((1,), (1,),), + _Cfunction('libvlc_audio_set_delay', ((1,), (1,),), None, ctypes.c_int, MediaPlayer, ctypes.c_int64) if not __debug__: # i.e. python -O or -OO global libvlc_audio_set_delay @@ -5494,7 +5616,7 @@ def libvlc_vlm_release(p_instance): @param p_instance: the instance. ''' f = _Cfunctions.get('libvlc_vlm_release', None) or \ - _Cfunction('libvlc_vlm_release', ((1,),), + _Cfunction('libvlc_vlm_release', ((1,),), None, None, Instance) if not __debug__: # i.e. python -O or -OO global libvlc_vlm_release @@ -5514,7 +5636,7 @@ def libvlc_vlm_add_broadcast(p_instance, psz_name, psz_input, psz_output, i_opti @return: 0 on success, -1 on error. ''' f = _Cfunctions.get('libvlc_vlm_add_broadcast', None) or \ - _Cfunction('libvlc_vlm_add_broadcast', ((1,), (1,), (1,), (1,), (1,), (1,), (1,), (1,),), + _Cfunction('libvlc_vlm_add_broadcast', ((1,), (1,), (1,), (1,), (1,), (1,), (1,), (1,),), None, 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) if not __debug__: # i.e. python -O or -OO global libvlc_vlm_add_broadcast @@ -5533,7 +5655,7 @@ def libvlc_vlm_add_vod(p_instance, psz_name, psz_input, i_options, ppsz_options, @return: 0 on success, -1 on error. ''' f = _Cfunctions.get('libvlc_vlm_add_vod', None) or \ - _Cfunction('libvlc_vlm_add_vod', ((1,), (1,), (1,), (1,), (1,), (1,), (1,),), + _Cfunction('libvlc_vlm_add_vod', ((1,), (1,), (1,), (1,), (1,), (1,), (1,),), None, 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) if not __debug__: # i.e. python -O or -OO global libvlc_vlm_add_vod @@ -5547,7 +5669,7 @@ def libvlc_vlm_del_media(p_instance, psz_name): @return: 0 on success, -1 on error. ''' f = _Cfunctions.get('libvlc_vlm_del_media', None) or \ - _Cfunction('libvlc_vlm_del_media', ((1,), (1,),), + _Cfunction('libvlc_vlm_del_media', ((1,), (1,),), None, ctypes.c_int, Instance, ctypes.c_char_p) if not __debug__: # i.e. python -O or -OO global libvlc_vlm_del_media @@ -5562,7 +5684,7 @@ def libvlc_vlm_set_enabled(p_instance, psz_name, b_enabled): @return: 0 on success, -1 on error. ''' f = _Cfunctions.get('libvlc_vlm_set_enabled', None) or \ - _Cfunction('libvlc_vlm_set_enabled', ((1,), (1,), (1,),), + _Cfunction('libvlc_vlm_set_enabled', ((1,), (1,), (1,),), None, ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_int) if not __debug__: # i.e. python -O or -OO global libvlc_vlm_set_enabled @@ -5577,7 +5699,7 @@ def libvlc_vlm_set_output(p_instance, psz_name, psz_output): @return: 0 on success, -1 on error. ''' f = _Cfunctions.get('libvlc_vlm_set_output', None) or \ - _Cfunction('libvlc_vlm_set_output', ((1,), (1,), (1,),), + _Cfunction('libvlc_vlm_set_output', ((1,), (1,), (1,),), None, ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_char_p) if not __debug__: # i.e. python -O or -OO global libvlc_vlm_set_output @@ -5593,7 +5715,7 @@ def libvlc_vlm_set_input(p_instance, psz_name, psz_input): @return: 0 on success, -1 on error. ''' f = _Cfunctions.get('libvlc_vlm_set_input', None) or \ - _Cfunction('libvlc_vlm_set_input', ((1,), (1,), (1,),), + _Cfunction('libvlc_vlm_set_input', ((1,), (1,), (1,),), None, ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_char_p) if not __debug__: # i.e. python -O or -OO global libvlc_vlm_set_input @@ -5608,7 +5730,7 @@ def libvlc_vlm_add_input(p_instance, psz_name, psz_input): @return: 0 on success, -1 on error. ''' f = _Cfunctions.get('libvlc_vlm_add_input', None) or \ - _Cfunction('libvlc_vlm_add_input', ((1,), (1,), (1,),), + _Cfunction('libvlc_vlm_add_input', ((1,), (1,), (1,),), None, ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_char_p) if not __debug__: # i.e. python -O or -OO global libvlc_vlm_add_input @@ -5623,7 +5745,7 @@ def libvlc_vlm_set_loop(p_instance, psz_name, b_loop): @return: 0 on success, -1 on error. ''' f = _Cfunctions.get('libvlc_vlm_set_loop', None) or \ - _Cfunction('libvlc_vlm_set_loop', ((1,), (1,), (1,),), + _Cfunction('libvlc_vlm_set_loop', ((1,), (1,), (1,),), None, ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_int) if not __debug__: # i.e. python -O or -OO global libvlc_vlm_set_loop @@ -5638,7 +5760,7 @@ def libvlc_vlm_set_mux(p_instance, psz_name, psz_mux): @return: 0 on success, -1 on error. ''' f = _Cfunctions.get('libvlc_vlm_set_mux', None) or \ - _Cfunction('libvlc_vlm_set_mux', ((1,), (1,), (1,),), + _Cfunction('libvlc_vlm_set_mux', ((1,), (1,), (1,),), None, ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_char_p) if not __debug__: # i.e. python -O or -OO global libvlc_vlm_set_mux @@ -5659,7 +5781,7 @@ def libvlc_vlm_change_media(p_instance, psz_name, psz_input, psz_output, i_optio @return: 0 on success, -1 on error. ''' f = _Cfunctions.get('libvlc_vlm_change_media', None) or \ - _Cfunction('libvlc_vlm_change_media', ((1,), (1,), (1,), (1,), (1,), (1,), (1,), (1,),), + _Cfunction('libvlc_vlm_change_media', ((1,), (1,), (1,), (1,), (1,), (1,), (1,), (1,),), None, 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) if not __debug__: # i.e. python -O or -OO global libvlc_vlm_change_media @@ -5673,7 +5795,7 @@ def libvlc_vlm_play_media(p_instance, psz_name): @return: 0 on success, -1 on error. ''' f = _Cfunctions.get('libvlc_vlm_play_media', None) or \ - _Cfunction('libvlc_vlm_play_media', ((1,), (1,),), + _Cfunction('libvlc_vlm_play_media', ((1,), (1,),), None, ctypes.c_int, Instance, ctypes.c_char_p) if not __debug__: # i.e. python -O or -OO global libvlc_vlm_play_media @@ -5687,7 +5809,7 @@ def libvlc_vlm_stop_media(p_instance, psz_name): @return: 0 on success, -1 on error. ''' f = _Cfunctions.get('libvlc_vlm_stop_media', None) or \ - _Cfunction('libvlc_vlm_stop_media', ((1,), (1,),), + _Cfunction('libvlc_vlm_stop_media', ((1,), (1,),), None, ctypes.c_int, Instance, ctypes.c_char_p) if not __debug__: # i.e. python -O or -OO global libvlc_vlm_stop_media @@ -5701,7 +5823,7 @@ def libvlc_vlm_pause_media(p_instance, psz_name): @return: 0 on success, -1 on error. ''' f = _Cfunctions.get('libvlc_vlm_pause_media', None) or \ - _Cfunction('libvlc_vlm_pause_media', ((1,), (1,),), + _Cfunction('libvlc_vlm_pause_media', ((1,), (1,),), None, ctypes.c_int, Instance, ctypes.c_char_p) if not __debug__: # i.e. python -O or -OO global libvlc_vlm_pause_media @@ -5716,7 +5838,7 @@ def libvlc_vlm_seek_media(p_instance, psz_name, f_percentage): @return: 0 on success, -1 on error. ''' f = _Cfunctions.get('libvlc_vlm_seek_media', None) or \ - _Cfunction('libvlc_vlm_seek_media', ((1,), (1,), (1,),), + _Cfunction('libvlc_vlm_seek_media', ((1,), (1,), (1,),), None, ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_float) if not __debug__: # i.e. python -O or -OO global libvlc_vlm_seek_media @@ -5737,8 +5859,8 @@ def libvlc_vlm_show_media(p_instance, psz_name): @return: string with information about named media, or NULL on error. ''' f = _Cfunctions.get('libvlc_vlm_show_media', None) or \ - _Cfunction('libvlc_vlm_show_media', ((1,), (1,),), - ctypes.c_char_p, Instance, ctypes.c_char_p) + _Cfunction('libvlc_vlm_show_media', ((1,), (1,),), string_result, + ctypes.c_void_p, Instance, ctypes.c_char_p) if not __debug__: # i.e. python -O or -OO global libvlc_vlm_show_media libvlc_vlm_show_media = f @@ -5752,7 +5874,7 @@ def libvlc_vlm_get_media_instance_position(p_instance, psz_name, i_instance): @return: position as float or -1. on error. ''' f = _Cfunctions.get('libvlc_vlm_get_media_instance_position', None) or \ - _Cfunction('libvlc_vlm_get_media_instance_position', ((1,), (1,), (1,),), + _Cfunction('libvlc_vlm_get_media_instance_position', ((1,), (1,), (1,),), None, ctypes.c_float, Instance, ctypes.c_char_p, ctypes.c_int) if not __debug__: # i.e. python -O or -OO global libvlc_vlm_get_media_instance_position @@ -5767,7 +5889,7 @@ def libvlc_vlm_get_media_instance_time(p_instance, psz_name, i_instance): @return: time as integer or -1 on error. ''' f = _Cfunctions.get('libvlc_vlm_get_media_instance_time', None) or \ - _Cfunction('libvlc_vlm_get_media_instance_time', ((1,), (1,), (1,),), + _Cfunction('libvlc_vlm_get_media_instance_time', ((1,), (1,), (1,),), None, ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_int) if not __debug__: # i.e. python -O or -OO global libvlc_vlm_get_media_instance_time @@ -5782,7 +5904,7 @@ def libvlc_vlm_get_media_instance_length(p_instance, psz_name, i_instance): @return: length of media item or -1 on error. ''' f = _Cfunctions.get('libvlc_vlm_get_media_instance_length', None) or \ - _Cfunction('libvlc_vlm_get_media_instance_length', ((1,), (1,), (1,),), + _Cfunction('libvlc_vlm_get_media_instance_length', ((1,), (1,), (1,),), None, ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_int) if not __debug__: # i.e. python -O or -OO global libvlc_vlm_get_media_instance_length @@ -5797,7 +5919,7 @@ def libvlc_vlm_get_media_instance_rate(p_instance, psz_name, i_instance): @return: playback rate or -1 on error. ''' f = _Cfunctions.get('libvlc_vlm_get_media_instance_rate', None) or \ - _Cfunction('libvlc_vlm_get_media_instance_rate', ((1,), (1,), (1,),), + _Cfunction('libvlc_vlm_get_media_instance_rate', ((1,), (1,), (1,),), None, ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_int) if not __debug__: # i.e. python -O or -OO global libvlc_vlm_get_media_instance_rate @@ -5813,7 +5935,7 @@ def libvlc_vlm_get_media_instance_title(p_instance, psz_name, i_instance): @bug: will always return 0. ''' f = _Cfunctions.get('libvlc_vlm_get_media_instance_title', None) or \ - _Cfunction('libvlc_vlm_get_media_instance_title', ((1,), (1,), (1,),), + _Cfunction('libvlc_vlm_get_media_instance_title', ((1,), (1,), (1,),), None, ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_int) if not __debug__: # i.e. python -O or -OO global libvlc_vlm_get_media_instance_title @@ -5829,7 +5951,7 @@ def libvlc_vlm_get_media_instance_chapter(p_instance, psz_name, i_instance): @bug: will always return 0. ''' f = _Cfunctions.get('libvlc_vlm_get_media_instance_chapter', None) or \ - _Cfunction('libvlc_vlm_get_media_instance_chapter', ((1,), (1,), (1,),), + _Cfunction('libvlc_vlm_get_media_instance_chapter', ((1,), (1,), (1,),), None, ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_int) if not __debug__: # i.e. python -O or -OO global libvlc_vlm_get_media_instance_chapter @@ -5845,7 +5967,7 @@ def libvlc_vlm_get_media_instance_seekable(p_instance, psz_name, i_instance): @bug: will always return 0. ''' f = _Cfunctions.get('libvlc_vlm_get_media_instance_seekable', None) or \ - _Cfunction('libvlc_vlm_get_media_instance_seekable', ((1,), (1,), (1,),), + _Cfunction('libvlc_vlm_get_media_instance_seekable', ((1,), (1,), (1,),), None, ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_int) if not __debug__: # i.e. python -O or -OO global libvlc_vlm_get_media_instance_seekable @@ -5859,15 +5981,17 @@ def libvlc_vlm_get_event_manager(p_instance): @return: libvlc_event_manager. ''' f = _Cfunctions.get('libvlc_vlm_get_event_manager', None) or \ - _Cfunction('libvlc_vlm_get_event_manager', ((1,),), - EventManager, Instance) + _Cfunction('libvlc_vlm_get_event_manager', ((1,),), class_result(EventManager), + ctypes.c_void_p, Instance) if not __debug__: # i.e. python -O or -OO global libvlc_vlm_get_event_manager libvlc_vlm_get_event_manager = f return f(p_instance) -# 3 function(s) blacklisted: +# 5 function(s) blacklisted: +# libvlc_audio_set_callbacks +# libvlc_audio_set_format_callbacks # libvlc_set_exit_handler # libvlc_video_set_callbacks # libvlc_video_set_format_callbacks @@ -5875,6 +5999,7 @@ def libvlc_vlm_get_event_manager(p_instance): # 12 function(s) not wrapped as methods: # libvlc_audio_output_list_release # libvlc_clearerr +# libvlc_clock # libvlc_errmsg # libvlc_event_type_name # libvlc_free @@ -5883,7 +6008,6 @@ def libvlc_vlm_get_event_manager(p_instance): # libvlc_get_version # libvlc_module_description_list_release # libvlc_new -# libvlc_new_with_builtins # libvlc_track_description_release # Start of footer.py # @@ -5893,6 +6017,27 @@ def callbackmethod(callback): """Now obsolete @callbackmethod decorator.""" return callback +# libvlc_free is not present in some versions of libvlc. If it is not +# in the library, then emulate it by calling libc.free +if not hasattr(dll, 'libvlc_free'): + # need to find the free function in the C runtime. This is + # platform specific. + # For Linux and MacOSX + libc_path = find_library('c') + if libc_path: + libc = ctypes.CDLL(libc_path) + libvlc_free = libc.free + else: + # On win32, it is impossible to guess the proper lib to call + # (msvcrt, mingw...). Just ignore the call: it will memleak, + # but not prevent to run the application. + def libvlc_free(p): + pass + + # ensure argtypes is right, because default type of int won't work + # on 64-bit systems + libvlc_free.argtypes = [ ctypes.c_void_p ] + # Version functions def _dot2int(v): '''(INTERNAL) Convert 'i.i.i[.i]' str to int. diff --git a/openlp/plugins/media/lib/vlccontroller.py b/openlp/plugins/media/lib/vlcapi.py similarity index 85% rename from openlp/plugins/media/lib/vlccontroller.py rename to openlp/plugins/media/lib/vlcapi.py index b1c267858..5d1ee272f 100644 --- a/openlp/plugins/media/lib/vlccontroller.py +++ b/openlp/plugins/media/lib/vlcapi.py @@ -26,7 +26,7 @@ ############################################################################### import logging -import sys +import sys, os from datetime import datetime try: import vlc @@ -34,17 +34,17 @@ except: pass from PyQt4 import QtCore, QtGui from openlp.core.lib import Receiver -from openlp.plugins.media.lib import MediaController, MediaState +from openlp.plugins.media.lib import MediaAPI, MediaState log = logging.getLogger(__name__) -class VlcController(MediaController): +class VlcAPI(MediaAPI): """ - Specialiced MediaController class - to reflect Features of the Vlc backend + Specialiced MediaAPI class + to reflect Features of the Vlc API """ def __init__(self, parent): - MediaController.__init__(self, parent) + MediaAPI.__init__(self, parent) self.parent = parent self.video_extensions_list = [ u'*.3gp' @@ -70,10 +70,13 @@ class VlcController(MediaController): , u'*.iso' ] - def setup(self, display, hasAudio): + def setup_controls(self, controller, control_panel): + pass + + def setup(self, display): display.vlcWidget = QtGui.QFrame(display) # creating a basic vlc instance - if hasAudio: + if display.hasAudio: display.vlcInstance = vlc.Instance() else: display.vlcInstance = vlc.Instance('--no-audio') @@ -121,26 +124,28 @@ class VlcController(MediaController): u'video/x-wmv': [u'.wmv'], u'video/x-ms-wmv': [u'.wmv']} - def load(self, display, path, volume, isBackground): + def load(self, display): log.debug(u'load vid in Vlc Controller') - vol = float(volume) / float(10) + controller = display.parent + volume = controller.media_info.volume + file_path = str( + controller.media_info.file_info.absoluteFilePath().toUtf8()) + path = os.path.normcase(file_path) # create the media - display.vlcMedia = display.vlcInstance.media_new_path(unicode(path)) + display.vlcMedia = display.vlcInstance.media_new_path(path) # put the media in the media player display.vlcMediaPlayer.set_media(display.vlcMedia) # parse the metadata of the file display.vlcMedia.parse() - if not self.mediaStateWait(display): - return False return True - def mediaStateWait(self, display): + def mediaStateWait(self, display, mediaState): """ Wait for the video to change its state Wait no longer than 5 seconds. """ start = datetime.now() - while not display.vlcMedia.is_parsed(): + while not mediaState == display.vlcMedia.get_state(): if display.vlcMedia.get_state() == vlc.State.Error: return False Receiver.send_message(u'openlp_process_events') @@ -148,24 +153,26 @@ class VlcController(MediaController): return False return True - def resize(self, display, controller): + def resize(self, display): display.vlcWidget.resize(display.size()) def play(self, display): self.set_visible(display, True) display.vlcMediaPlayer.play() - self.state = MediaState.Playing + if self.mediaStateWait(display, vlc.State.Playing): + self.state = MediaState.Playing def pause(self, display): display.vlcMediaPlayer.pause() - self.state = MediaState.Paused + if self.mediaStateWait(display, vlc.State.Paused): + self.state = MediaState.Paused def stop(self, display): display.vlcMediaPlayer.stop() self.state = MediaState.Stopped def volume(self, display, vol): - pass + display.vlcMediaPlayer.audio_set_volume(vol) def seek(self, display, seekVal): if display.vlcMediaPlayer.is_seekable(): @@ -180,7 +187,8 @@ class VlcController(MediaController): if self.hasOwnWidget: display.vlcWidget.setVisible(status) - def update_ui(self, controller, display): + def update_ui(self, display): + controller = display.parent controller.seekSlider.setMaximum(1000) if not controller.seekSlider.isSliderDown(): currentPos = display.vlcMediaPlayer.get_position() * 1000 diff --git a/openlp/plugins/media/lib/webkitcontroller.py b/openlp/plugins/media/lib/webkitapi.py similarity index 66% rename from openlp/plugins/media/lib/webkitcontroller.py rename to openlp/plugins/media/lib/webkitapi.py index 41f94ad36..f6e429418 100644 --- a/openlp/plugins/media/lib/webkitcontroller.py +++ b/openlp/plugins/media/lib/webkitapi.py @@ -28,20 +28,21 @@ import logging from PyQt4 import QtCore, QtGui, QtWebKit -from openlp.plugins.media.lib import MediaController, MediaState + +from openlp.core.lib import OpenLPToolbar, translate +from openlp.plugins.media.lib import MediaAPI, MediaState log = logging.getLogger(__name__) -class WebkitController(MediaController): +class WebkitAPI(MediaAPI): """ - Specialiced MediaController class - to reflect Features of the QtWebkit backend + Specialiced MediaAPI class + to reflect Features of the QtWebkit API """ def __init__(self, parent): - MediaController.__init__(self, parent) + MediaAPI.__init__(self, parent) self.parent = parent - self.isFlash = False self.canBackground = True self.video_extensions_list = [ u'*.3gp' @@ -68,7 +69,11 @@ class WebkitController(MediaController): , u'*.swf', u'*.mpg', u'*.wmv', u'*.mpeg', u'*.avi' ] - def setup(self, display, hasAudio): + def setup_controls(self, controller, control_panel): + # no special controls + pass + + def setup(self, display): display.webView.raise_() self.hasOwnWidget = False @@ -79,68 +84,83 @@ class WebkitController(MediaController): def get_supported_file_types(self): pass - def load(self, display, path, volume, isBackground): + def load(self, display): log.debug(u'load vid in Webkit Controller') - vol = float(volume) / float(10) - if isBackground: + controller = display.parent + volume = controller.media_info.volume + vol = float(volume) / float(100) + path = controller.media_info.file_info.absoluteFilePath() + if controller.media_info.is_background: loop = u'true' else: loop = u'false' display.webView.setVisible(True) - if path.endswith(u'.swf'): + if controller.media_info.file_info.suffix() == u'swf': + controller.media_info.isFlash = True js = u'show_flash("load","%s");' % \ (path.replace(u'\\', u'\\\\')) - self.isFlash = True else: js = u'show_video("init", "%s", %s, %s);' % \ (path.replace(u'\\', u'\\\\'), str(vol), loop) - self.isFlash = False display.frame.evaluateJavaScript(js) return True - def resize(self, display, controller): + def resize(self, display): + controller = display.parent if display == controller.previewDisplay: display.webView.resize(display.size()) def play(self, display): - display.override[u'theme'] = u'' - display.override[u'video'] = True + controller = display.parent + #display.override[u'theme'] = u'' + #display.override[u'video'] = True display.webLoaded = True self.set_visible(display, True) - if self.isFlash: - display.frame.evaluateJavaScript(u'show_flash("play","");') + if controller.media_info.isFlash: + display.frame.evaluateJavaScript(u'show_flash("play");') else: display.frame.evaluateJavaScript(u'show_video("play");') self.state = MediaState.Playing def pause(self, display): - if self.isFlash: - display.frame.evaluateJavaScript(u'show_flash("pause","");') + controller = display.parent + if controller.media_info.isFlash: + display.frame.evaluateJavaScript(u'show_flash("pause");') else: display.frame.evaluateJavaScript(u'show_video("pause");') self.state = MediaState.Paused def stop(self, display): - if self.isFlash: - display.frame.evaluateJavaScript(u'show_flash("stop","");') + controller = display.parent + if controller.media_info.isFlash: + display.frame.evaluateJavaScript(u'show_flash("stop");') else: display.frame.evaluateJavaScript(u'show_video("stop");') self.state = MediaState.Stopped def volume(self, display, vol): - if not self.isFlash: + controller = display.parent + # 1.0 is the highest value + vol = float(vol) / float(100) + if not controller.media_info.isFlash: display.frame.evaluateJavaScript(u'show_video(null, null, %s);' % str(vol)) def seek(self, display, seekVal): - if not self.isFlash: + controller = display.parent + if controller.media_info.isFlash: + seek = seekVal + display.frame.evaluateJavaScript( \ + u'show_flash("seek", null, null, "%s");' % (seek)) + else: seek = float(seekVal)/1000 display.frame.evaluateJavaScript( \ u'show_video("seek", null, null, null, "%f");' % (seek)) def reset(self, display): - if self.isFlash: - display.frame.evaluateJavaScript(u'show_flash("close","");') + controller = display.parent + if controller.media_info.isFlash: + display.frame.evaluateJavaScript(u'show_flash("close");') else: display.frame.evaluateJavaScript(u'show_video("close");') self.state = MediaState.Off @@ -149,16 +169,26 @@ class WebkitController(MediaController): if self.hasOwnWidget: display.webView.setVisible(status) - def update_ui(self, controller, display): - if not self.isFlash: + def update_ui(self, display): + controller = display.parent + if controller.media_info.isFlash: currentTime = display.frame.evaluateJavaScript( \ - u'show_video("currentTime");') - length = display.frame.evaluateJavaScript(u'show_video("length");') - if int(currentTime.toFloat()[0]*1000) > 0: - controller.seekSlider.setMaximum(int(length.toFloat()[0]*1000)) - if not controller.seekSlider.isSliderDown(): - controller.seekSlider.setSliderPosition( \ - int(currentTime.toFloat()[0]*1000)) + u'show_flash("currentTime");').toInt()[0] + length = display.frame.evaluateJavaScript( \ + u'show_flash("length");').toInt()[0] + else: + (currentTime, ok) = display.frame.evaluateJavaScript( \ + u'show_video("currentTime");').toFloat() + if ok: + currentTime = int(currentTime*1000) + (length, ok) = display.frame.evaluateJavaScript( \ + u'show_video("length");').toFloat() + if ok: + length = int(length*1000) + if currentTime > 0: + controller.seekSlider.setMaximum(length) + if not controller.seekSlider.isSliderDown(): + controller.seekSlider.setSliderPosition(currentTime) def get_supported_file_types(self): pass diff --git a/openlp/plugins/media/mediaplugin.py b/openlp/plugins/media/mediaplugin.py index 38aaedd70..2d495955d 100644 --- a/openlp/plugins/media/mediaplugin.py +++ b/openlp/plugins/media/mediaplugin.py @@ -53,6 +53,9 @@ class MediaPlugin(Plugin): '
The media plugin provides playback of audio and video.') return about_text + def addControllerItems(self, controller, control_panel): + self.mediaManager.addControllerItems(controller, control_panel) + def setPluginTextStrings(self): """ Called to define all translatable texts of the plugin