Package VisionEgg :: Module qtmovie |
[frames] | no frames]

# Source Code for Module VisionEgg.qtmovie

     1  """high level QuickTime Movie wrapper"""
     2  import qtlowlevel
     3  import ctypes
     4
     5  qtlowlevel.InitializeQTML(0)
     6  qtlowlevel.EnterMovies()
     7
     8 -def new_movie_from_filename(filename, MAX_PATH=255):
     9      """create a Movie from filename"""
    10      movieProps = (qtlowlevel.QTNewMoviePropertyElement * 5)()
    11      filename = unicode(filename)
    12
    13      movieFilePathRef = qtlowlevel.CFStringRef()
    14      movieFilePathRef.value = qtlowlevel.CFStringCreateWithCharacters(qtlowlevel.kCFAllocatorDefault,
    15                                                                       filename,
    16                                                                       len(filename))
    17
    18      moviePropCount = 0
    19
    20      movieProps[moviePropCount].propClass = qtlowlevel.kQTPropertyClass_DataLocation
    21      movieProps[moviePropCount].propID = qtlowlevel.kQTDataLocationPropertyID_CFStringWindowsPath
    22      movieProps[moviePropCount].propValueSize = ctypes.sizeof(ctypes.c_void_p)
    23      movieProps[moviePropCount].propValueAddress = ctypes.cast(ctypes.byref(movieFilePathRef),ctypes.c_void_p)
    24      movieProps[moviePropCount].propStatus = 0
    25
    26      moviePropCount += 1
    27
    28      boolTrue = ctypes.c_ubyte(1)
    29      movieProps[moviePropCount].propClass = qtlowlevel.kQTPropertyClass_MovieInstantiation
    30      movieProps[moviePropCount].propID = qtlowlevel.kQTMovieInstantiationPropertyID_DontAskUnresolvedDataRefs
    31      movieProps[moviePropCount].propValueSize = ctypes.sizeof(boolTrue)
    32      movieProps[moviePropCount].propValueAddress = ctypes.cast(ctypes.pointer(boolTrue),ctypes.c_void_p)
    33      movieProps[moviePropCount].propStatus = 0
    34
    35      moviePropCount += 1
    36
    37      movieProps[moviePropCount].propClass = qtlowlevel.kQTPropertyClass_NewMovieProperty
    38      movieProps[moviePropCount].propID = qtlowlevel.kQTNewMoviePropertyID_Active
    39      movieProps[moviePropCount].propValueSize = ctypes.sizeof(boolTrue)
    40      movieProps[moviePropCount].propValueAddress = ctypes.cast(ctypes.pointer(boolTrue),ctypes.c_void_p)
    41      movieProps[moviePropCount].propStatus = 0
    42
    43      moviePropCount += 1
    44
    45      movieProps[moviePropCount].propClass = qtlowlevel.kQTPropertyClass_NewMovieProperty
    46      movieProps[moviePropCount].propID = qtlowlevel.kQTNewMoviePropertyID_DontInteractWithUser
    47      movieProps[moviePropCount].propValueSize = ctypes.sizeof(boolTrue)
    48      movieProps[moviePropCount].propValueAddress = ctypes.cast(ctypes.pointer(boolTrue),ctypes.c_void_p)
    49      movieProps[moviePropCount].propStatus = 0
    50
    51      moviePropCount += 1
    52
    53      theMovie = qtlowlevel.Movie()
    54      qtlowlevel.NewMovieFromProperties( moviePropCount, movieProps, 0, None, ctypes.byref(theMovie))
    55      return Movie(theMovie)
    56
    57 -class Rect:
    58 -    def __init__(self,top=0,left=0,bottom=0,right=0):
    59          self.top = top
    60          self.left = left
    61          self.bottom = bottom
    62          self.right = right
    63
    64 -class Movie:
    65      """An encapsulated QuickTime Movie"""
    66 -    def __init__(self,theMovie):
    67          self.theMovie = theMovie
    68 -    def GetMovieBox(self):
    69          movieBounds = qtlowlevel.Rect()
    70          qtlowlevel.GetMovieBox(self.theMovie, ctypes.byref(movieBounds))
    71          return Rect(top=movieBounds.top,
    72                      left=movieBounds.left,
    73                      bottom=movieBounds.bottom,
    74                      right=movieBounds.right)
    75
    76 -    def SetMovieBox(self,bounds):
    77          if not isinstance(bounds,Rect):
    78              raise ValueError('bounds argument must be instance of VisionEgg.qtmovie.Rect')
    79          b = qtlowlevel.Rect()
    80          (b.top, b.left, b.bottom, b.right) = (bounds.top, bounds.left,
    81                                                bounds.bottom, bounds.right)
    82          qtlowlevel.SetMovieBox(self.theMovie, ctypes.byref(b))
    83 -    def StartMovie(self):
    84          qtlowlevel.StartMovie(self.theMovie)
    85
    86 -    def MoviesTask(self,value):
    87          qtlowlevel.MoviesTask(self.theMovie, value)
    88
    89 -    def IsMovieDone(self):
    90          return qtlowlevel.IsMovieDone(self.theMovie)
    91
    92 -    def GoToBeginningOfMovie(self):
    93          qtlowlevel.GoToBeginningOfMovie(self.theMovie)
    94