def writenode(node, evallicense = 0, tostring = 0, silent = 0): if not hasattr(node, 'tmpfile') and not tostring: return import realsupport data = realsupport.writeRP(None, node.slideshow.rp, node, savecaptions=1, tostring = 1, silent = silent) if tostring: return data url = MMAttrdefs.getattr(node, 'file') url = node.GetContext().findurl(url) utype, host, path, params, query, tag = urlparse.urlparse(url) if (not utype or utype == 'file') and \ (not host or host == 'localhost'): try: localpathname = MMurl.url2pathname(path) f = open(localpathname, 'w') f.write(data) f.close() except: windowinterface.showmessage("cannot write `%s' for node `%s'" % (url, MMAttrdefs.getattr(node, 'name') or '<unnamed>')) else: if os.name == 'mac': import macfs import macostools fss = macfs.FSSpec(localpathname) fss.SetCreatorType('PNst', 'PNRA') macostools.touched(fss) del node.tmpfile else: windowinterface.showmessage("cannot write remote file for node `%s'" % (MMAttrdefs.getattr(node, 'name') or '<unnamed>'))
def gotoanchor(self, link, arg): anchor1 = link[Hlinks.ANCHOR1] show = MMAttrdefs.getattr(anchor1, 'show') sstate = MMAttrdefs.getattr(anchor1, 'sourcePlaystate') dstate = MMAttrdefs.getattr(anchor1, 'destinationPlaystate') if show == 'replace': # ignore sourcePlaystate ltype = Hlinks.TYPE_JUMP stype = Hlinks.A_SRC_PAUSE elif show == 'pause': # ignore sourcePlaystate ltype = Hlinks.TYPE_FORK stype = Hlinks.A_SRC_PAUSE elif show == 'new': ltype = Hlinks.TYPE_FORK if sstate == 'play': stype = Hlinks.A_SRC_PLAY elif sstate == 'pause': stype = Hlinks.A_SRC_PAUSE else: stype = Hlinks.A_SRC_STOP if dstate == 'play': dtype = Hlinks.A_DEST_PLAY else: dtype = Hlinks.A_DEST_PAUSE anchor2 = link[Hlinks.ANCHOR2] if MMAttrdefs.getattr(anchor1, 'external') or ltype != Hlinks.TYPE_JUMP or type(anchor2) is type(''): return self.toplevel.jumptoexternal(anchor1, anchor2, ltype, stype, dtype) return self.gotonode(anchor2, arg)
def makename(self, anchor): if type(anchor) is type(''): return anchor aname = MMAttrdefs.getattr(anchor, 'name') if anchor.GetType() == 'anchor': nname = MMAttrdefs.getattr(anchor.GetParent(), 'name') if nname and aname: return '%s in %s' % (aname, nname) if nname: return 'nameless anchor in %s' % nname if not aname: return 'nameless anchor in nameless node' if aname: return aname return 'nameless node'
def getattr(self): self.open() name = self.gettoken() if name[0] not in letters: raise MSyntaxError, (name, 'attr name') if not self.attrparsers.has_key(name): import MMAttrdefs if MMAttrdefs.attrdefs.has_key(name): self.attrparsers[name] = MMAttrdefs.usetypedef( MMAttrdefs.attrdefs[name][0], MMParser.basicparsers) else: print 'Warning: unrecognized attr', name if name[-4:] == 'dict': # Default syntax for dictionaries value = \ self.getnamedictvalue( \ (MMParser.getanyvalue, None)) elif name[-4:] == 'list': # Default syntax for lists value = self.getlistvalue( \ (MMParser.getanyvalue, None)) else: # Default syntax for other things # (returned as lists if more than one item, # else as single value) value = self.getlistvalue( \ (MMParser.getanyvalue, None)) if len(value) == 1: value = value[0] if self.attrparsers.has_key(name): func, arg = self.attrparsers[name] value = func(self, arg) self.close() return name, value
def prepare_player(self, node=None, window=None): self.release_armed_player() try: self.__armBuilder = win32dxm.GraphBuilder() except: self.__armBuilder = None if not self.__armBuilder: raise error, 'Cannot create GraphBuilder to render item.' url = self.__channel.getfileurl(node) if not url: raise error, 'No URL on node.' if MMurl.urlretrieved(url): url = MMurl.urlretrieve(url)[0] if not self.__armBuilder.RenderFile(url, self.__channel._exporter): self.__armFileHasBeenRendered = 0 raise error, 'Cannot render: ' + url self.__sync = node.GetSyncBehavior(), node.GetSyncTolerance( ), MMAttrdefs.getattr(node, 'syncMaster') if self.__sync[0] == 'locked' and self.__sync[1] < 0: self.__sync = 'canSlip', self.__sync[1], self.__sync[2] self.__armFileHasBeenRendered = 1 return 1
def showeditor(node, url=None): if len(channeleditors) == 0: InitEditors() if not url: if node.GetType() == 'imm': dummy = _Convert(node) return if node.GetType() <> 'ext': windowinterface.showmessage('Only external nodes can be edited.', mtype='error') return import MMAttrdefs url = MMAttrdefs.getattr(node, 'file') url = node.context.findurl(url) import MMurl, urlparse utype, host, path, params, query, fragment = urlparse.urlparse(url) if (utype and utype != 'file') or (host and host != 'localhost'): windowinterface.showmessage('Can only edit local files.', mtype='warning') return filename = MMurl.url2pathname(path) chtype = node.GetChannelType() import os if chtype == 'html' and not channeleditors.has_key('html'): chtype = 'text' if not channeleditors.has_key(chtype): windowinterface.showmessage('No editor for %s nodes.' % chtype, mtype='warning') return editor = channeleditors[chtype] if type(editor) is type(''): _do_edit(editor, filename) else: cmd = _showmenu(editor, filename)
def load_geometry(self): return name = self.geom_name posname = name + 'winpos' sizename = name + 'winsize' h, v = MMAttrdefs.getattr(self.root, posname) width, height = MMAttrdefs.getattr(self.root, sizename) self.last_geometry = h, v, width, height # Experimental code, currently mac-only if 1 or sys.platform == 'mac': if (h, v) == (-1, -1): # We got default values. Try to obtain previous applicationwide settings import settings if settings.has_key(posname) and settings.has_key(sizename): h, v = settings.get(posname) width, height = settings.get(sizename) self.last_geometry = h, v, width, height
def parsevalue(string, typedef, context): import MMAttrdefs fp = StringInput().init(string) parser = MMParser().init(fp, context) parserdef = MMAttrdefs.usetypedef(typedef, MMParser.basicparsers) value = parser.getgenericvalue(parserdef) if parser.peektoken() <> '': raise SyntaxError, 'excess input' return value
def findwholenodeanchor(self, node): for c in node.GetChildren(): if c.GetType() != 'anchor': continue if MMAttrdefs.getattr(c, 'ashape') != 'rect': # only rectangular anchors can be whole-node anchors continue if c.GetAttrDef('acoords', None) is not None: # no coordinates allowed on whole-node anchors continue if c.GetAttrDef('beginlist', None) or \ c.GetAttrDef('endlist', None): # no timing allowed on whole-node anchors continue if MMAttrdefs.getattr(c, 'actuate') != 'onRequest': # only user-clickable anchors count continue return c return None
def listattrnames(node): namelist = MMAttrdefs.getnames() if 'styledict' in namelist: namelist.remove('styledict') # Merge in any unknown attributes that the node might have for name in node.attrdict.keys(): if name not in namelist: namelist.append(name) namelist.sort() return namelist
def getchannelbynode(self, node): import MMTypes ntype = node.GetType() if ntype == 'anchor': node = node.GetParent() ntype = node.GetType() if ntype in MMTypes.mediatypes: return self.getRenderer(node) else: cname = MMAttrdefs.getattr(node, 'channel') return self.getchannelbyname(cname)
def commit(self, type=None): if not self.busy: raise MMExc.AssertError, 'invalid commit' import MMAttrdefs # test if the root node has changed if type is None: if self.structure_changed: type = 'STRUCTURE_CHANGED' elif self.attrs_changed: type = 'ATTRS_CHANGED' if not self.__newRoot: # the root node hasn't changed (the document hasn't been reloaded) # normal treatment MMAttrdefs.flushcache(self.root) self.context.changedtimes(self.root) self.root.clear_infoicon() self.root.ResetPlayability() for x in self.registry[:]: x.commit(type) else: # the root node has changed (the document has been reloaded) # special treatment self.toplevel.changeRoot(self.__newRoot) self.__newRoot = None # if the error state has changed, update also the views and commandlist if self.__errorstateChanged: self.toplevel.updateViewsOnErrors() self.toplevel.updateCommandlistOnErrors() self.__errorstateChanged = 0 self.busy = 0 del self.undostep # To frustrate invalid addstep calls self.structure_changed = 0 self.attrs_changed = 0 self.next_focus = []
def getclipboard(self): data = self.editmgr.getclip() rv = [] for n in data: className = n.getClassName() iconname = n.getIconName(wantmedia=1) if className == 'MMNode': name = MMAttrdefs.getattr(n, 'name') elif className in ('Region', 'Viewport'): name = n.name else: name = '' rv.append((None, iconname, name, iconname)) return rv
class VideoChannel(ChannelWindowThread): node_attrs = ChannelWindowThread.node_attrs + [ 'clipbegin', 'clipend', 'project_audiotype', 'project_videotype', 'project_targets', 'project_perfect', 'project_mobile' ] chan_attrs = ChannelWindowThread.chan_attrs + [ 'fit', 'project_videotype', 'project_targets' ] def threadstart(self): import mpegchannel return mpegchannel.init() def do_arm(self, node, same=0): if same and self.armed_display: return 1 if node.type != 'ext': self.errormsg(node, 'Node must be external.') return 1 url = self.getfileurl(node) if not url: self.errormsg(node, 'No URL set on node.') return 1 try: filename = MMurl.urlretrieve(url)[0] fp = open(filename, 'rb') except IOError, msg: self.errormsg(node, 'Cannot open: %s\n\n%s.' % (url, msg[1])) return 1 try: import MMAttrdefs fit = MMAttrdefs.getattr(node, 'fit') if fit == 'hidden': scale = 1.0 else: scale = 0.0 arminfo = { 'scale': scale, 'bgcolor': self.getbgcolor(node), } self.threads.arm(fp, 0, 0, arminfo, None, self.syncarm) except RuntimeError, msg: if type(msg) is type(self): msg = msg.args[0] print 'Bad mpeg file', ` url `, msg return 1
def showeditor(node, url=None): if len(channeleditors) == 0: InitEditors() if not url: if node.GetType() == 'imm': dummy = _Convert(node) return if node.GetType() <> 'ext': windowinterface.showmessage('Only extern nodes can be edited.', mtype='error') return import MMAttrdefs url = MMAttrdefs.getattr(node, 'file') url = node.context.findurl(url) xx = windowinterface.shell_execute(url, 'edit', showmsg=0) if xx != 0: windowinterface.shell_execute(url, 'open')
def __getSelfAnimations(self, parent, children): uid = self.getUID() for node in parent.GetChildren(): ntype = node.GetType() if ntype == 'animate': anim = None if node.targetnode == self._mmobj: anim = node elif node.GetParent() == self._mmobj: anim = node else: te = MMAttrdefs.getattr(node, 'targetElement') if te and te == uid: anim = node if anim is not None and anim not in children: children.append(anim) self.__getSelfAnimations(node, children)
class QtChannel: def __init__(self, channel): self.__channel = channel self.__qtplayer = None self.__playBegin = 0 self.__playEnd = 0 self.__playdone = 1 self.__fiber_id = None self.__qid = self.__dqid = None # video sig self.__window = None self.__rcMediaWnd = None def destroy(self): if self.__window: self.__window.removevideo() del self.__qtplayer def prepare_player(self, node, window=None): self.__qtplayer = winqt.QtPlayer() url = self.__channel.getfileurl(node) if not url: raise error, 'No URL on node.' try: fn = MMurl.urlretrieve(url)[0] except IOError, arg: if type(arg) == type(()): arg = arg[-1] raise error, 'Cannot open: %s\n\n%s.' % (url, arg) if not self.__qtplayer.open( fn, exporter=self.__channel._exporter, asaudio=window is None): raise error, 'Cannot render: %s' % url if window: ddobj = window._topwindow.getDirectDraw() self.__qtplayer.createVideoDDS(ddobj) self.__sync = node.GetSyncBehavior(), node.GetSyncTolerance( ), MMAttrdefs.getattr(node, 'syncMaster') return 1
def converttextfile(u, srcurl, dstdir, file, node): import MMAttrdefs, windowinterface import colors # ignore suggested extension and make our own file = os.path.splitext(file)[0] + '.rt' fullpath = os.path.join(dstdir, file) if identicalfiles(srcurl, fullpath): # src and dst files are the same, don't do anything u.close() if __debug__: print 'src and dst files are identical', fullpath return file data = u.read() u.close() f = open(fullpath, 'w') f.write('<window') if node is not None: dur = MMAttrdefs.getattr(node, 'duration') if dur: f.write(' duration="%g"' % dur) ch = node.GetChannel() color = ch.get('bgcolor') if color is not None: if colors.rcolors.has_key(color): color = colors.rcolors[color] else: color = '#%02x%02x%02x' % color f.write(' bgcolor="%s"' % color) geom = ch.get('base_winoff') units = ch.get('units', windowinterface.UNIT_SCREEN) if geom and units == windowinterface.UNIT_PXL: f.write(' width="%d" height="%d"' % (geom[2], geom[3])) f.write('>\n') f.write(data) f.write('</window>\n') f.close() if os.name == 'mac': import macfs import macostools fss = macfs.FSSpec(fullpath) fss.SetCreatorType('PNst', 'PNRA') macostools.touched(fss) return file
def prepare_anchors(self, node, window, coordinates): if not window: return # GetClientRect by def returns always: 0, 0, w, h w_left, w_top, w_width, w_height = window.GetClientRect() left, top, width, height = window._convert_coordinates( coordinates, units=windowinterface.UNIT_PXL) if width == 0 or height == 0: print 'warning: zero size media rect' width, height = w_width, w_height self.__rcMediaWnd = left, top, width, height # preset for animation window.setmediadisplayrect(self.__rcMediaWnd) window.setmediafit(MMAttrdefs.getattr(node, 'fit')) return (left / float(w_width), top / float(w_height), width / float(w_width), height / float(w_height))
def prepare_player(self, node, window): if not window: raise error, 'No window to render in.' ddobj = window._topwindow.getDirectDraw() self.__mmstream = win32dxm.MMStream(ddobj) url = self.__channel.getfileurl(node) if not url: raise error, 'No URL on node.' if MMurl.urlretrieved(url): url = MMurl.urlretrieve(url)[0] if not self.__mmstream.open(url, self.__channel._exporter): raise error, 'Cannot render: %s' % url self.__sync = node.GetSyncBehavior(), node.GetSyncTolerance( ), MMAttrdefs.getattr(node, 'syncMaster') return 1
def prep1(node): node.counter = [0, 0] node.deps = [], [] node.hasterm = 0 type = node.GetType() dur = node.GetAttrDef('duration', None) if dur is None and not node.GetChildren(): dur = node.GetAttrDef('empty_duration', None) if dur is not None and dur >= 0: adddep(node, HD, dur, node, TL, 'TERM') elif type in playabletypes: dur = getduration(node) if dur >= 0: adddep(node, HD, dur, node, TL, 'TERM') if type == 'seq': # XXX not right! xnode, xside = node, HD for c in node.GetSchedChildren(0): if not c.ShouldPlay(): continue prep1(c) adddep(xnode, xside, 0, c, HD) xnode, xside = c, TL adddep(xnode, xside, 0, node, TL) elif type in ('par', 'switch', 'excl') or (type in playabletypes and node.GetSchedChildren(0)): term = node.GetTerminator() for c in node.GetSchedChildren(0): if not c.ShouldPlay(): continue prep1(c) adddep(node, HD, 0, c, HD) if term == 'FIRST': adddep(c, TL, 0, node, TL, 'FIRST') elif term == MMAttrdefs.getattr(c, 'name'): node.hasterm = 1 adddep(c, TL, 0, node, TL, 'TERM') else: adddep(c, TL, 0, node, TL) else: adddep(node, HD, None, node, TL)
def gettemplateassets(self): assetlist = [] for node in self.context.getassets(): # XXX Logic is suboptimal: we consider all ext # nodes without ids and with URLs as pure media items, # all others as clippings. tp = node.GetType() if tp == 'ext': url = node.GetRawAttrDef('file', '') else: url = '' name = MMAttrdefs.getattr(node, 'name') icon = node.getIconName(wantmedia=1) if tp == 'ext' and url and not name: pathname = urlparse.urlparse(url)[2] name = posixpath.split(pathname)[1] name = MMurl.unquote(name) node = icon # XXXX dirty trick: string first elt flags url. else: pathname = '' assetlist.append((node, icon, name, icon, url)) return assetlist
def place_movie(self, node, movie): self.window._mac_setwin() grafport = self.window._mac_getoswindowport() movie.SetMovieGWorld(grafport, None) screenBox = self.window.qdrect() screenClip = self.window._mac_getclip() l, t, r, b = movie.GetMovieBox() if node: fit = MMAttrdefs.getattr(node, 'fit') else: # This happens during a resize: we don't know scale/center anymore. fit = 'hidden' if debug: print 'fit=', fit # Compute real scale for scale-to-fit sl, st, sr, sb = screenBox if debug: print 'movie', l, t, r, b if debug: print 'screen', sl, st, sr, sb if fit is not None and fit != 'hidden': if l == r: maxxscale = 1 # Empty window, so don't divide by 0 else: maxxscale = float(sr - sl) / (r - l) if t == b: maxyscale = 1 # Empty window, so don't divide by 0 else: maxyscale = float(sb - st) / (b - t) scale = min(maxxscale, maxyscale) if debug: print 'scale=', scale, maxxscale, maxyscale movieBox = sl, st, sl + int((r - l) * scale), sr + int( (b - t) * scale) nMovieBox = self._scalerect(screenBox, movieBox, 0) else: nMovieBox = sl, st, sl + (r - l), st + (b - t) movie.SetMovieBox(nMovieBox) movie.SetMovieDisplayClipRgn(screenClip) if debug: print 'placed movie'
def getstreamdata(node, target=0): ntype = node.GetType() if ntype not in ('ext', 'slide'): # Nodes that are not external consume no bandwidth return 0, 0, 0, 0 if ntype == 'slide': raise Error, 'Cannot compute bandwidth for slide.' context = node.GetContext() ctype = node.GetChannelType() if ntype == 'ext' and ctype == 'RealPix': # Get information from the attributes bitrate = MMAttrdefs.getattr(node, 'bitrate') # XXX Incorrect return 0, bitrate, bitrate, 0 url = MMAttrdefs.getattr(node, 'file') if not url or url == '#': # Special case for empty URLs return 0, 0, 0, 0 url = context.findurl(url) val = urlcache.urlcache[url].get('bandwidth') if val is not None: return val # We skip bandwidth retrieval for nonlocal urls (too expensive) type, rest = MMurl.splittype(url) if type and type != 'file': ## print "DBG: Bandwidth.get: skip nonlocal", url return None, None, None, None host, rest = MMurl.splithost(rest) if host and host != 'localhost': ## print "DBG: Bandwidth.get: skip nonlocal", url return None, None, None, None mtype = urlcache.mimetype(url) if not mtype: raise Error, 'Cannot open: %s' % url maintype, subtype = mtype.split('/') if string.find(subtype, 'real') >= 0: # For real channels we parse the header and such # XXXX If we want to do real-compatible calculations # we have to take preroll time and such into account. import realsupport info = realsupport.getinfo(url) bandwidth = 0 if info.has_key('bitrate'): bandwidth = info['bitrate'] if info.has_key('preroll'): prerolltime = info['preroll'] else: prerolltime = DEFAULT_STREAMING_MEDIA_PRELOAD prerollbits = prerolltime * bandwidth ## print "DBG: Bandwidth.get: real:", url, prearm, bandwidth urlcache.urlcache[url][ 'bandwidth'] = prerollbits, prerolltime, bandwidth, bandwidth return prerollbits, prerolltime, bandwidth, bandwidth if maintype == 'audio' or maintype == 'video': targets = MMAttrdefs.getattr(node, 'project_targets') bitrate = TARGET_BITRATES[0] # default: 28k8 modem for i in range(len(TARGET_BITRATES)): if targets & (1 << i): bitrate = TARGET_BITRATES[i] # don't cache since the result depends on project_targets prerollseconds = DEFAULT_STREAMING_MEDIA_PRELOAD prerollbits = prerollseconds * bitrate return prerollbits, prerollseconds, bitrate, bitrate # XXXX Need to pass more args (crop, etc) attrs = {'project_quality': MMAttrdefs.getattr(node, 'project_quality')} filesize = GetSize(url, target, attrs, MMAttrdefs.getattr(node, 'project_convert')) if filesize is None: return None, None, None, None ## print 'DBG: Bandwidth.get: discrete',filename, filesize, float(filesize)*8 bits = float(filesize) * 8 prerollbitrate = MMAttrdefs.getattr(node, 'strbitrate') ## Don't cache: user may change strbitrate property ## urlcache.urlcache[url]['bandwidth'] = bits, None, prerollbitrate, None return bits, None, prerollbitrate, None
class SVGChannel(Channel.ChannelWindow): def __init__(self, name, attrdict, scheduler, ui): Channel.ChannelWindow.__init__(self, name, attrdict, scheduler, ui) self.svgdstrect = None self.svgsrcrect = None self.svgorgsize = None self.svgdds = None self.svgrenderer = None self.svgplayer = None self.svgddcolor = 0 def __repr__(self): return '<SVGChannel instance, name=' + ` self._name ` + '>' def do_hide(self): Channel.ChannelWindow.do_hide(self) def destroy(self): del self.svgdds Channel.ChannelWindow.destroy(self) def do_arm(self, node, same=0): if node.type != 'ext': self.errormsg(node, 'Node must be external.') return 1 url = self.getfileurl(node) if not url: self.errormsg(node, 'No URL set on node.') return 1 from winversion import osversion if osversion.isWin9x(): self.errormsg( node, 'SVG preview is not supported on Windows 9x versions.') return 1 if svgdom.doccache.hasdoc(url): svgdoc = svgdom.doccache.getDoc(url) else: try: u = MMurl.urlopen(url) except IOError, arg: if type(arg) is type(self): arg = arg.strerror self.errormsg(node, 'Cannot open: %s\n\n%s.' % (url, arg)) return 1 source = u.read() u.close() svgdoc = svgdom.SvgDocument(source) svgdom.doccache.cache(url, svgdoc) # default to white bgcolor = self.getbgcolor(node) or (255, 255, 255) r, g, b = bgcolor if r + g + b == 0: bgcolor = 255, 255, 255 if self.window and svgdoc: coordinates = 0, 0, 1.0, 1.0 # self.getmediageom(node) self.svgdstrect = left, top, width, height = self.window._convert_coordinates( coordinates) self.svgorgsize = svgdoc.getSize() self.svgsrcrect = 0, 0, width, height # promise for svg scaling self.svgdds = self.window.createDDS(width, height) self.svgddcolor = self.svgdds.GetColorMatch(bgcolor) self.renderOn(self.svgdds, svgdoc, update=0) if svgdoc.hasTiming(): rendercb = (self.renderOn, (self.svgdds, svgdoc)) self.svgplayer = svgdom.SVGPlayer(svgdoc, windowinterface.toplevel, rendercb) fit = MMAttrdefs.getattr(node, 'fit') self.window.setmediadisplayrect(self.svgdstrect) self.window.setmediafit(fit) return 1
def playit(self, node, window=None, winpossize=None, url=None, windowless=0, start_time=0): self.__winpos = window, winpossize, windowless if not self.__createplayer(node): return 0 duration = self.__channel.getduration(node) self.__start_time = start_time if url is None: url = self.__channel.getfileurl(node) if not url: self.__channel.errormsg(node, 'No URL set on node.') return 0 url = MMurl.canonURL(url) mediarepeat = MMAttrdefs.getattr(node, 'mediaRepeat') if mediarepeat != 'preserve': # i.e. mediarepeat=='strip' if '?' in url: url = url + '&mediaRepeat=%s' % mediarepeat else: url = url + '?mediaRepeat=%s' % mediarepeat ## try: ## u = MMurl.urlopen(url) ## except: ## self.errormsg(node, 'Cannot open '+url) ## return 0 ## else: ## u.close() ## del u self.__url = url self.__rmaplayer.SetStatusListener(self) if windowless: self.__rmaplayer.SetPyVideoRenderer( self.__channel.getRealVideoRenderer()) if duration > 0: self.__qid = self.__channel._scheduler.enterabs( start_time + duration, 0, self.__stop, (start_time + duration, )) self.__playdone_called = 0 # WARNING: RealMedia player doesn't unquote, so we must do it url = MMurl.unquote(url) if realenginedebug: print 'RealChannel.playit', self, ` url ` self._playargs = (node, window, winpossize, url, windowless, start_time) try: self.__rmaplayer.OpenURL(url) except rma.error: raise error, "Cannot open: %s" % url t0 = self.__channel._scheduler.timefunc() if t0 > start_time: self.__spark = 1 else: self.__spark = 0 try: self.__rmaplayer.Begin() except rma.error: raise error, "Cannot open: %s" % url self.__engine.startusing() self.__using_engine = 1 return 1
def nodename(node): if node is None: return '<none>' str = MMAttrdefs.getattr(node, 'name') str = str + '#' + node.GetUID() return str
def get_geometry(self): h, v = self.root.GetRawAttrDef('player_winpos', (None, None)) winsize = MMAttrdefs.getattr(self.root, 'player_winsize') width, height = winsize or (640, 480) return h, v, width, height
'tuple': writetuple, \ 'list': writelist, \ 'dict': writedict, \ 'namedict': writenamedict, \ 'attrdict': writeattrdict, \ 'enclosed': writeenclosed, \ 'optenclosed':writeenclosed, \ 'type': writetype, \ 'any': writeany, \ } # Dictionary mapping attribute names to writing functions. # import MMAttrdefs attrwriters = MMAttrdefs.useattrdefs(basicwriters) # Interface to return a string representation of a value given a typedef. # def valuerepr(value, typedef): fp = StringOutputNoNL() writerdef = MMAttrdefs.usetypedef(typedef, basicwriters) writegeneric(value, writerdef, fp) return fp.get() class StringOutputNoNL: def __init__(self): self.buf = ''
def valuerepr(value, typedef): fp = StringOutputNoNL() writerdef = MMAttrdefs.usetypedef(typedef, basicwriters) writegeneric(value, writerdef, fp) return fp.get()