Hello,
I have a python script (see below) that uses PyObjC to play a movie
using the Quicktime framework.
I was hoping to adapt this to a pyglet context, but when I replace the
window used in the script with:
window = pyglet.window.Window(width=200, height=200)
I get:
File "test-qt-video.py", line 59, in <module>
view.setMovie_(movie)
objc.error: NSInternalInconsistencyException - CGSDisableUpdate returned
error 1002d
I am using the pyglet cocoa branch.
Does anyone have any ideas or experience integrating external video
decoders with a pyglet window?
Thank you,
-Charles.
"""
*2011.03.21 18:12:51
Minimal example to play a Quicktime movie with PyObjC
http://cocoawithlove.com/2010/09/minimalist-cocoa-programming.html
"""
from QTKit import QTMovie, QTMovieView
from Cocoa import *
import os, sys
NSApplication.sharedApplication()
# Create an autorelease pool for menu creation and finishLaunching
pool = NSAutoreleasePool.alloc().init()
menubar = NSMenu.alloc().init()
appMenuItem = NSMenuItem.alloc().init()
menubar.addItem_(appMenuItem)
NSApp().setMainMenu_(menubar)
appMenu = NSMenu.alloc().init()
processName = NSProcessInfo.processInfo().processName()
hideItem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_(
"Hide " + processName, "hide:", "h")
appMenu.addItem_(hideItem)
appMenu.addItem_(NSMenuItem.separatorItem())
quitItem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_(
"Quit " + processName, "terminate:", "q")
appMenu.addItem_(quitItem)
appMenuItem.setSubmenu_(appMenu)
screenRect = NSScreen.mainScreen().frame()
window =
NSWindow.alloc().initWithContentRect_styleMask_backing_defer_(screenRect, NSBorderlessWindowMask,
NSBackingStoreBuffered, "NO")
#window.cascadeTopLeftFromPoint_(NSMakePoint(20,20))
#window.setTitle_(processName)
window.makeKeyAndOrderFront_(None)
filename = sys.argv[1]
#filename = "sample.mov"
movie, error = QTMovie.movieWithFile_error_(filename, None)
if error or not movie:
print "Problem with movie", filename, ":", error.description()
sys.exit(0)
print movie.duration
view = QTMovieView.alloc().init()
view.setMovie_(movie)
view.setControllerVisible_(False)
view.setPreservesAspectRatio_(True)
window.setContentView_(view)
view.play_(window)
NSApp().activateIgnoringOtherApps_(True)
# Then get rid of the pool when we're done.
del pool
NSApp().run()
--
You received this message because you are subscribed to the Google Groups
"pyglet-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pyglet-users?hl=en.