Note that there are some explanatory texts on larger screens.

plurals
  1. POFloat an NSView above a window being used by DVDPlayback framework
    text
    copied!<p>I am trying to write a simple DVD player using Mac OS X's <code>DVDPlayback.framework</code>. I can get the DVD to play within a window, but ultimately I want this to run as a full-screen app. </p> <p>I'm having difficulty adding a sub-view to display media controls whilst the DVD is playing (pause / play, progress slider to scroll through the movie, change chapter etc). </p> <p>It seems that if I create a sub-view (<code>NSView</code>) within the window being used by the DVD framework, it always seems to fall behind the DVD content, even if I tell the <code>NSView</code> to be at the top-most level.</p> <p>Here's the simplified code, which just tries to create a white sub-view within a region of the window:</p> <p>(I've tried the code on 10.6 and 10.7 with the same results).</p> <pre><code>const BOOL PLAY_DVD = YES; @interface ControlsView : NSView { } @end @implementation ControlsView - (void)drawRect:(NSRect)rect { [[NSColor whiteColor] set]; NSRectFill(rect); } @end @implementation AppDelegate @synthesize window = _window; - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { NSView *view = self.window.contentView; if (PLAY_DVD) { NSLog(@"%@ Playing DVD video", [self class]); // Register error handler OSStatus err; err = DVDInitialize(); if (err != noErr) { NSLog(@"DVDInitialise failed with error code %d", err); [NSApp terminate:self]; } // Set window to be the main window err = DVDSetVideoWindowID([self.window windowNumber]); // Set the display... CGDirectDisplayID display = (CGDirectDisplayID) [[[[self.window screen] deviceDescription] valueForKey:@"NSScreenNumber"] intValue]; Boolean isSupported; err = DVDSwitchToDisplay(display, &amp;isSupported); // Set video bounds NSRect frame = [self.window frame]; CGRect rect = CGRectMake(0, 0, frame.size.width, frame.size.height); err = DVDSetVideoCGBounds(&amp;rect); FSRef ref; DVDOpenMediaFileWithURL([NSURL URLWithString:@"file:///Path/to/my/TestDVD/VIDEO_TS"]); DVDOpenMediaFile(&amp;ref); DVDPlay(); } // Attempt to add a subview to show the controls... ControlsView *controls = [[ControlsView alloc] initWithFrame:NSMakeRect(20, 20, 100, 50)]; [view addSubview:controls positioned:NSWindowAbove relativeTo:nil]; } @end </code></pre> <p>If <code>PLAY_DVD</code> is <strong><code>NO</code></strong>, the subview is correctly rendered (and I can create other sub-views and show that the ordering is correct). </p> <p>If <code>PLAY_DVD</code> is <strong><code>YES</code></strong>, the media starts playing, but the sub-view is never visible because it always seems to fall behind the video.</p> <p>The only examples of DVD playback I've been able to find have had the controls in a second window, but for a full-screen application I'd like the controls to be part of the full-screen view and to fade in/out when required. </p> <p>Does anyone know how best to do this? Do my full-screen controls have to be in a separate window which floats above the full-screen window? I've not been able to find an example which has the controls and the DVD playback in the same window.</p> <p>Thanks in advance for your help!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload