1 /*
2 * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
305 [blockSelf finish];
306 }];
307
308 [self registerForNotification:QTMovieLoadStateDidChangeNotification
309 object:qtMovie
310 withBlock:
311 ^(NSNotification *note) {
312 /*
313 * QTMovieLoadStateError - an error occurred while loading the movie
314 * QTMovieLoadStateLoading - the movie is loading
315 * QTMovieLoadStateLoaded - the movie atom has loaded; it's safe to query movie properties
316 * QTMovieLoadStatePlayable - the movie has loaded enough media data to begin playing
317 * QTMovieLoadStatePlaythroughOK - the movie has loaded enough media data to play through to the end
318 * QTMovieLoadStateComplete - the movie has loaded completely
319 */
320 long loadState = [(NSNumber*)[movie attributeForKey:QTMovieLoadStateAttribute] longValue];
321 NSError *loadError = (NSError*)[movie attributeForKey:QTMovieLoadStateErrorAttribute];
322 if (loadError) {
323 LOGGER_ERRORMSG(([[NSString stringWithFormat:@"Error loading QTMovie: %@\n", loadError] UTF8String]));
324 if (eventHandler) {
325 eventHandler->SendPlayerMediaErrorEvent(ERROR_OSX_INIT);
326 }
327 }
328
329 if (!movieReady) {
330 if (loadState > QTMovieLoadStateLoaded) {
331 [blockSelf setMovieReady];
332 }
333 } else if (requestedState == kPlaybackState_Play) {
334 // if state is QTMovieLoadStatePlayable then we've stalled
335 // if state is QTMovieLoadStatePlaythroughOK then we're playing
336 if (loadState == QTMovieLoadStatePlayable && previousPlayerState == kPlayerState_PLAYING) {
337 [blockSelf setPlayerState:kPlayerState_STALLED];
338 } else if (loadState == QTMovieLoadStatePlaythroughOK) {
339 [blockSelf setPlayerState:kPlayerState_PLAYING];
340 }
341 }
342 }];
343
344 [self registerForNotification:QTMovieTimeDidChangeNotification
345 object:qtMovie
|
1 /*
2 * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
305 [blockSelf finish];
306 }];
307
308 [self registerForNotification:QTMovieLoadStateDidChangeNotification
309 object:qtMovie
310 withBlock:
311 ^(NSNotification *note) {
312 /*
313 * QTMovieLoadStateError - an error occurred while loading the movie
314 * QTMovieLoadStateLoading - the movie is loading
315 * QTMovieLoadStateLoaded - the movie atom has loaded; it's safe to query movie properties
316 * QTMovieLoadStatePlayable - the movie has loaded enough media data to begin playing
317 * QTMovieLoadStatePlaythroughOK - the movie has loaded enough media data to play through to the end
318 * QTMovieLoadStateComplete - the movie has loaded completely
319 */
320 long loadState = [(NSNumber*)[movie attributeForKey:QTMovieLoadStateAttribute] longValue];
321 NSError *loadError = (NSError*)[movie attributeForKey:QTMovieLoadStateErrorAttribute];
322 if (loadError) {
323 LOGGER_ERRORMSG(([[NSString stringWithFormat:@"Error loading QTMovie: %@\n", loadError] UTF8String]));
324 if (eventHandler) {
325 if (loadError.domain == NSOSStatusErrorDomain) {
326 eventHandler->SendPlayerMediaErrorEvent(ERROR_LOCATOR_CONNECTION_LOST);
327 } else {
328 eventHandler->SendPlayerMediaErrorEvent(ERROR_OSX_INIT);
329 }
330 }
331 }
332
333 if (!movieReady) {
334 if (loadState > QTMovieLoadStateLoaded) {
335 [blockSelf setMovieReady];
336 }
337 } else if (requestedState == kPlaybackState_Play) {
338 // if state is QTMovieLoadStatePlayable then we've stalled
339 // if state is QTMovieLoadStatePlaythroughOK then we're playing
340 if (loadState == QTMovieLoadStatePlayable && previousPlayerState == kPlayerState_PLAYING) {
341 [blockSelf setPlayerState:kPlayerState_STALLED];
342 } else if (loadState == QTMovieLoadStatePlaythroughOK) {
343 [blockSelf setPlayerState:kPlayerState_PLAYING];
344 }
345 }
346 }];
347
348 [self registerForNotification:QTMovieTimeDidChangeNotification
349 object:qtMovie
|