From 84da06214daaa04876ca927f9bb0d05f67b12af3 Mon Sep 17 00:00:00 2001 From: jules Date: Thu, 9 Feb 2017 15:06:29 +0000 Subject: [PATCH] Fix for MovieComponent on older OSX SDKs. Updated video page in big demo app. --- examples/Demo/Source/Demos/VideoDemo.cpp | 25 ++++++++----------- .../native/juce_mac_MovieComponent.mm | 6 ++++- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/examples/Demo/Source/Demos/VideoDemo.cpp b/examples/Demo/Source/Demos/VideoDemo.cpp index 8ccc4a2c69..a34748cafe 100644 --- a/examples/Demo/Source/Demos/VideoDemo.cpp +++ b/examples/Demo/Source/Demos/VideoDemo.cpp @@ -24,7 +24,7 @@ #include "../JuceDemoHeader.h" -#if JUCE_QUICKTIME || JUCE_DIRECTSHOW +#if JUCE_MAC || JUCE_DIRECTSHOW //============================================================================== // so that we can easily have two video windows each with a file browser, wrap this up as a class.. @@ -50,7 +50,7 @@ public: fileChooser.setCurrentFile (file, true); } - void paintOverChildren (Graphics& g) + void paintOverChildren (Graphics& g) override { if (isDragOver) { @@ -59,28 +59,28 @@ public: } } - void resized() + void resized() override { videoComp.setBoundsWithCorrectAspectRatio (Rectangle (0, 0, getWidth(), getHeight() - 30), Justification::centred); fileChooser.setBounds (0, getHeight() - 24, getWidth(), 24); } - bool isInterestedInDragSource (const SourceDetails&) { return true; } + bool isInterestedInDragSource (const SourceDetails&) override { return true; } - void itemDragEnter (const SourceDetails&) + void itemDragEnter (const SourceDetails&) override { isDragOver = true; repaint(); } - void itemDragExit (const SourceDetails&) + void itemDragExit (const SourceDetails&) override { isDragOver = false; repaint(); } - void itemDropped (const SourceDetails& dragSourceDetails) + void itemDropped (const SourceDetails& dragSourceDetails) override { setFile (dragSourceDetails.description.toString()); isDragOver = false; @@ -88,8 +88,8 @@ public: } private: - #if JUCE_QUICKTIME - QuickTimeMovieComponent videoComp; + #if JUCE_MAC + MovieComponent videoComp; #elif JUCE_DIRECTSHOW DirectShowComponent videoComp; #endif @@ -100,11 +100,7 @@ private: void filenameComponentChanged (FilenameComponent*) override { // this is called when the user changes the filename in the file chooser box - #if JUCE_QUICKTIME - if (videoComp.loadMovie (fileChooser.getCurrentFile(), true)) - #elif JUCE_DIRECTSHOW if (videoComp.loadMovie (fileChooser.getCurrentFile())) - #endif { // loaded the file ok, so let's start it playing.. @@ -114,8 +110,7 @@ private: else { AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon, - "Couldn't load the file!", - r.getErrorMessage()); + "Couldn't load the file!", String()); } } diff --git a/modules/juce_video/native/juce_mac_MovieComponent.mm b/modules/juce_video/native/juce_mac_MovieComponent.mm index df5343d99e..0e999ce756 100644 --- a/modules/juce_video/native/juce_mac_MovieComponent.mm +++ b/modules/juce_video/native/juce_mac_MovieComponent.mm @@ -54,7 +54,11 @@ struct MovieComponent::Pimpl player = [[AVPlayer alloc] initWithURL: url]; player.actionAtItemEnd = AVPlayerActionAtItemEndPause; player.masterClock = CMClockGetHostTimeClock(); - player.automaticallyWaitsToMinimizeStalling = NO; + + if ([player respondsToSelector: @selector (setAutomaticallyWaitsToMinimizeStalling:)]) + [player performSelector: @selector (setAutomaticallyWaitsToMinimizeStalling:) + withObject: nil]; + [player pause]; playerLayer = [[AVPlayerLayer playerLayerWithPlayer: player] retain];