commit/vlc: Javi Dominguez: VLC add-on 1.1-dev

  • From: commits-noreply@xxxxxxxxxxxxx
  • To: nvda-addons-commits@xxxxxxxxxxxxx
  • Date: Fri, 20 Nov 2015 02:11:11 -0000

1 new commit in vlc:

https://bitbucket.org/nvdaaddonteam/vlc/commits/bbf16bb6b556/
Changeset: bbf16bb6b556
Branch: master
User: Javi Dominguez
Date: 2015-11-20 02:10:38+00:00
Summary: VLC add-on 1.1-dev

Signed-off-by: Joseph Lee <joseph.lee22590@xxxxxxxxx>

Affected #: 1 file

diff --git a/addon/appModules/vlc.py b/addon/appModules/vlc.py
index e694680..25c2dd9 100755
--- a/addon/appModules/vlc.py
+++ b/addon/appModules/vlc.py
@@ -1,27 +1,18 @@
# -*- coding: UTF-8 -*-

# appModule for VLC Media Player
-# Tab and Shift+Tab moves between items in pane. Press left mouse button to
active them.
-# Elapsed time is said when moves forward and backward
-# Press I to read status bar information

-# sep 2015 by Javi Dominguez (Javichi)
-
-# 0.8 changes:
-# Improved: Added more controls to which the app module is able to reach
-# Improved: Now, It advertises when a control is unavailable
-# Improved: Controls are shown as they appear and hide when they become
invisible. Advertises when there are not controls available.
-
-# 0.7 changes:
-# Improved: control pane takes the focus when focused object becomes invisible.
-# Improved: in playback control pane, indicates the state of the checkboxes
-# Improved: reads value of spinButton when it's changed
+# V 1.1 dev
+# November 2015 by Javi Dominguez (Javichi)

import appModuleHandler
from NVDAObjects.IAccessible import IAccessible
import controlTypes
import api
+import winUser
import ui
+import tones
+from time import sleep

class AppModule(appModuleHandler.AppModule):

@@ -36,6 +27,8 @@ class AppModule(appModuleHandler.AppModule):
clsList.insert(0, VLC_spinButton)
elif obj.role == controlTypes.ROLE_WINDOW:
clsList.insert(0, VLC_mainWindow)
+ elif obj.windowStyle == -1764884480:
+ clsList.insert(0, VLC_mediaInfo)

def event_gainFocus(self, obj, nextHandler):
if controlTypes.STATE_INVISIBLE in obj.states:
@@ -43,11 +36,22 @@ class AppModule(appModuleHandler.AppModule):
obj.setFocus()
nextHandler()

+ def script_conrolPaneToForeground(self, gesture):
+ obj = api.getForegroundObject()
+ api.setFocusObject(obj)
+ tones.beep(1200, 30)
+
+ __gestures = {
+ "kb:NVDA+F5": "conrolPaneToForeground"
+ }
+
class VLC_mainWindow(IAccessible):
tpItemIndex = 100
+ playlist = []
+ playlistIndex = -1

def composeTime(self, t="00:00"):
- _("Convert time from hh:mm:ss to h hours m minutes s seconds")
+ "Convert time from hh:mm:ss to h hours m minutes s seconds"
t = t.split(":")
if len(t) == 3:
hours, minutes, seconds = t
@@ -79,12 +83,22 @@ class VLC_mainWindow(IAccessible):
return (cTime)

def isPlaying(self):
- _("looks in play/pause button to see if it's playing")
+ "looks in play/pause button to see if it's playing"
obj = api.getForegroundObject()
if "Pause" in
obj.children[2].children[3].children[5].description:
return(True)
return(False)

+ def isChecked(self, c):
+ ">Looks if is checked: c=1=Shuffle and c=2=Repeat"
+ obj = api.getForegroundObject()
+ try:
+ if controlTypes.STATE_CHECKED in
obj.children[2].children[3].children[3:][-c].states:
+ return(True)
+ except:
+ pass
+ return(False)
+
def sayElapsedTime(self):
obj = api.getForegroundObject()
elapsedTime = obj.children[1].children[3].name.split("/")[0]
@@ -94,8 +108,8 @@ class VLC_mainWindow(IAccessible):
obj = api.getForegroundObject()
toolPaneItems = []
# Playback controls
- for item in obj.children[2].children[3].children[3:-1]:
- if controlTypes.STATE_INVISIBLE not in item.states:
+ for item in obj.children[2].children[3].children[3:]:
+ if controlTypes.STATE_INVISIBLE not in item.states and
item.role != controlTypes.ROLE_GRIP:
toolPaneItems.append(item)
# Add advanced controls
for item in obj.children[2].children[3].children[0].children:
@@ -129,20 +143,27 @@ class VLC_mainWindow(IAccessible):
ui.message(_("unavailable"))
api.setNavigatorObject(toolPaneItems[index])
api.moveMouseToNVDAObject(toolPaneItems[index])
+ api.setMouseObject(toolPaneItems[index])
self.tpItemIndex = index

def script_moveToNextItem(self, gesture):
- self.moveToItem(self.tpItemIndex+1)
+ try:
+ self.moveToItem(self.tpItemIndex+1)
+ except:
+ gesture.send()

def script_moveToPreviousItem(self, gesture):
- self.moveToItem(self.tpItemIndex-1)
+ try:
+ self.moveToItem(self.tpItemIndex-1)
+ except:
+ gesture.send()

def script_backAndForward(self, gesture):
gesture.send()
self.sayElapsedTime()

def script_readStatusBar(self, gesture):
- _("Reads the status bar information")
+ "Reads the status bar information"
obj = api.getForegroundObject()
if obj.children[1].role == controlTypes.ROLE_STATUSBAR:
try:
@@ -153,18 +174,135 @@ class VLC_mainWindow(IAccessible):
ui.message(_("%s of %s" % (elapsedTime,
totalTime)))
if self.isPlaying():
ui.message(_(" playing"))
+ if self.isChecked(2):
+ ui.message(_("Repeat mode"))
+ if self.isChecked(1):
+ ui.message(_("Shuffle mode"))
return()
except:
pass

+ def getPlaylist(self):
+ "Make a list from anchored playlist if it's showed"
+ obj = api.getForegroundObject()
+ obj = obj.firstChild
+ while obj and obj.role != controlTypes.ROLE_SPLITBUTTON:
+ obj = obj.simpleNext
+ try:
+ playlist = []
+ for item in obj.simpleFirstChild.children:
+ if (item.role == controlTypes.ROLE_TREEVIEWITEM\
+ or item.role == controlTypes.ROLE_LISTITEM):
+ playlist.append(item)
+ return(playlist)
+ except:
+ return(None)
+
+ def moveToPlaylistItem(self, index):
+ if not self.playlist:
+ self.playlist = self.getPlaylist()
+ if not self.playlist:
+ return(False)
+ ui.message(_("%d items in playlist") %
len(self.playlist))
+ l = len(self.playlist)
+ if index < 0:
+ self.playlistIndex = 0
+ tones.beep(200, 50)
+ elif index >= l:
+ self.playlistIndex = l-1
+ tones.beep(200, 50)
+ else:
+ self.playlistIndex = index
+ api.moveMouseToNVDAObject(self.playlist[self.playlistIndex])
+ api.setNavigatorObject(self.playlist[self.playlistIndex])
+ api.setMouseObject(self.playlist[self.playlistIndex])
+ ui.message("%d %s" % (self.playlistIndex+1,
self.playlist[self.playlistIndex].name))
+ return(True)
+
+ def script_nextPlaylistItem(self, gesture):
+ if not self.moveToPlaylistItem(self.playlistIndex+1):
+ ui.message(_("Playlist is not visible"))
+
+ def script_previousPlaylistItem(self, gesture):
+ if not self.moveToPlaylistItem(self.playlistIndex-1):
+ ui.message(_("Playlist is not visible"))
+
+ def script_doAction(self, gesture):
+ obj = api.getNavigatorObject()
+ try:
+ obj.doAction()
+ sleep(0.2)
+ if obj.role == controlTypes.ROLE_CHECKBOX:
+ if controlTypes.STATE_CHECKED in obj.states:
+ ui.message(_("checked"))
+ else:
+ ui.message(_("not checked"))
+ ui.message(obj.description)
+ except:
+ if self.mouseClick():
+ types = (controlTypes.ROLE_LISTITEM,
controlTypes.ROLE_TREEVIEWITEM)
+ if obj.role in types:
+ self.mouseClick()
+ else:
+ ui.message(_("This item is outside the window"))
+
+ def mouseClick(self, button="left"):
+ if controlTypes.STATE_INVISIBLE in api.getMouseObject().states:
+ return(False)
+ if button == "left":
+
winUser.mouse_event(winUser.MOUSEEVENTF_LEFTDOWN,0,0,None,None)
+
winUser.mouse_event(winUser.MOUSEEVENTF_LEFTUP,0,0,None,None)
+ return(True)
+ if button == "right":
+
winUser.mouse_event(winUser.MOUSEEVENTF_RIGHTDOWN,0,0,None,None)
+
winUser.mouse_event(winUser.MOUSEEVENTF_RIGHTUP,0,0,None,None)
+ return(True)
+
+ def script_contextMenu(self, gesture):
+ types = (controlTypes.ROLE_LISTITEM,
controlTypes.ROLE_TREEVIEWITEM)
+ obj = api.getMouseObject()
+ if "VLC" in obj.windowText and obj.role in types:
+ if not self.mouseClick("right"):
+ ui.message(_("This item is outside the window"))
+ return()
+ gesture.send()
+
+ def script_repeat(self, gesture):
+ ui.message(_("Repeat mode"))
+ gesture.send()
+ sleep(0.1)
+ if self.isChecked(2):
+ ui.message(_("Checked"))
+ else:
+ ui.message(_("not checked"))
+
+ def script_shuffle(self, gesture):
+ ui.message(_("Shuffle mode"))
+ gesture.send()
+ sleep(0.1)
+ if self.isChecked(1):
+ ui.message(_("Checked"))
+ else:
+ ui.message(_("not checked"))
+
__gestures = {
"kb:I": "readStatusBar",
+ "kb:L": "repeat",
+ "kb:R": "shuffle",
"kb:Tab": "moveToNextItem",
"kb:Shift+Tab": "moveToPreviousItem",
"kb:Control+RightArrow": "backAndForward",
"kb:Control+LeftArrow": "backAndForward",
"kb:Shift+RightArrow": "backAndForward",
- "kb:Shift+LeftArrow": "backAndForward"
+ "kb:Shift+LeftArrow": "backAndForward",
+ "kb:Alt+RightArrow": "backAndForward",
+ "kb:Alt+LeftArrow": "backAndForward",
+ "kb:Alt+Control+RightArrow": "backAndForward",
+ "kb:Alt+Control+LeftArrow": "backAndForward",
+ "kb:enter": "doAction",
+ "kb:downArrow": "nextPlaylistItem",
+ "kb:upArrow": "previousPlaylistItem",
+ "kb:applications": "contextMenu"
}

class VLC_pane(IAccessible):
@@ -178,3 +316,43 @@ class VLC_spinButton(IAccessible):
def event_valueChange(self):
ui.message(self.value)

+class VLC_mediaInfo(IAccessible):
+
+ def event_gainFocus(self):
+ cTypes = {
+ 8: _("edit"),
+ 9: _("button"),
+ 23: _("tab control")
+ }
+ if self.simplePrevious.role == controlTypes.ROLE_STATICTEXT:
+ ui.message(self.simplePrevious.name)
+ if self.name:
+ ui.message(self.name)
+ if self.value:
+ ui.message(self.value)
+ if self.description:
+ ui.message(self.description)
+ if self.role in cTypes:
+ ui.message(cTypes[self.role])
+
+ def script_nextControl(self, gesture):
+ obj = api.getFocusObject()
+ if obj.role == controlTypes.ROLE_EDITABLETEXT\
+ and obj.simpleNext.role == controlTypes.ROLE_TABCONTROL:
+ obj.parent.children[1].setFocus()
+ else:
+ gesture.send()
+
+ def script_previousControl(self, gesture):
+ obj = api.getFocusObject()
+ if obj.role == controlTypes.ROLE_EDITABLETEXT\
+ and obj.simpleNext.role == controlTypes.ROLE_TABCONTROL:
+ obj.simplePrevious.simplePrevious.setFocus()
+ else:
+ gesture.send()
+
+ __gestures = {
+ "kb:Tab": "nextControl",
+ "kb:Shift+Tab": "previousControl"
+ }
+
\ No newline at end of file

Repository URL: https://bitbucket.org/nvdaaddonteam/vlc/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.

Other related posts:

  • » commit/vlc: Javi Dominguez: VLC add-on 1.1-dev - commits-noreply