Re: MPMoviePlayerController doesn't work with remoteControlReceivedWithEvent

2012-08-11 Thread Mr. Gecko
Apparently, MPMoviePlayerController isn't the way to go for this. What I ended 
up doing was using MPMoviePlayerViewController and overrode the 
remoteControlReceivedWithEvent to customize the controls.

Below is my current code which I am using.


@interface MGMMoviePlayerViewController : MPMoviePlayerViewController
- (void)remoteControlReceivedWithEvent:(UIEvent *)event;
@end

@implementation MGMMoviePlayerViewController
- (void)remoteControlReceivedWithEvent:(UIEvent *)theEvent {
if (theEvent.type==UIEventTypeRemoteControl) {
if (theEvent.subtype==UIEventSubtypeRemoteControlPlay) {
[[self moviePlayer] play];
} else if (theEvent.subtype==UIEventSubtypeRemoteControlPause) {
[[self moviePlayer] pause];
} else if 
(theEvent.subtype==UIEventSubtypeRemoteControlTogglePlayPause) {
if ([[self moviePlayer] 
playbackState]==MPMoviePlaybackStatePlaying) {
[[self moviePlayer] pause];
} else {
[[self moviePlayer] play];
}
} else if (theEvent.subtype==UIEventSubtypeRemoteControlStop) {
[[self moviePlayer] stop];
} else if (theEvent.subtype==UIEventSubtypeRemoteControlNextTrack) {
NSTimeInterval currentTime = [[self moviePlayer] 
currentPlaybackTime];
currentTime += 10;
if (currentTime[[self moviePlayer] duration])
currentTime = [[self moviePlayer] duration];
[[self moviePlayer] setCurrentPlaybackTime:currentTime];
} else if (theEvent.subtype==UIEventSubtypeRemoteControlPreviousTrack) {
NSTimeInterval currentTime = [[self moviePlayer] 
currentPlaybackTime];
currentTime -= 10;
if (currentTime0)
currentTime = 0;
[[self moviePlayer] setCurrentPlaybackTime:currentTime];
} else if 
(theEvent.subtype==UIEventSubtypeRemoteControlBeginSeekingBackward) {
[[self moviePlayer] beginSeekingBackward];
} else if 
(theEvent.subtype==UIEventSubtypeRemoteControlBeginSeekingForward) {
[[self moviePlayer] beginSeekingForward];
} else if 
(theEvent.subtype==UIEventSubtypeRemoteControlEndSeekingBackward || 
theEvent.subtype==UIEventSubtypeRemoteControlEndSeekingForward) {
[[self moviePlayer] endSeeking];
}
}
}
@end


- (void)tableView:(UITableView *)theTableView 
didSelectRowAtIndexPath:(NSIndexPath *)theIndexPath {
NSString *file = [[MGMFilesPath stringByExpandingTildeInPath] 
stringByAppendingPathComponent:[files objectAtIndex:[theIndexPath 
indexAtPosition:1]]];

moviePlayerView = [[MGMMoviePlayerViewController alloc] 
initWithContentURL:[NSURL fileURLWithPath:file]];

[self presentMoviePlayerViewControllerAnimated:moviePlayerView];
[[moviePlayerView moviePlayer] play];

[fileView deselectRowAtIndexPath:theIndexPath animated:NO];
}
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


MPMoviePlayerController doesn't work with remoteControlReceivedWithEvent

2012-08-10 Thread Mr. Gecko
I want to allow the controls from my keyboard to work in my app. The controls 
use Apple's Remote Control events (beginReceivingRemoteControlEvents, 
endReceivingRemoteControlEvents, and remoteControlReceivedWithEvent), however I 
cannot seem to get this to work with MPMoviePlayerController.

I do not see any events at the start of the program, even though 
beginReceivingRemoteControlEvents is called at the start.
I do not see any events during the playback of a video.
I do see events after I close the video.

From the above, it seems that the audio stream of MPMoviePlayerController 
disables the controls. However I do not know how to change this. I tried using 
[moviePlayer setUseApplicationAudioSession:NO]; to change the audio to use the 
system session, yet it does nothing.

Here is my setup. My app delegate is a UIViewController. I set the main 
window's root view controller to the app delegate, add views to the view 
controller and in the view controller for the parts which has to do with video.

- (BOOL)canBecomeFirstResponder {
return YES;
}
- (void)tableView:(UITableView *)theTableView 
didSelectRowAtIndexPath:(NSIndexPath *)theIndexPath {
NSString *file = [[MGMFilesPath stringByExpandingTildeInPath] 
stringByAppendingPathComponent:[files objectAtIndex:[theIndexPath 
indexAtPosition:1]]];
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
[audioSession setCategory:AVAudioSessionCategoryPlayback error:nil];
[audioSession setActive:YES error:nil];
NSLog(@%d, [self isFirstResponder]);

moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL 
fileURLWithPath:file]];

[[NSNotificationCenter defaultCenter] addObserver:self 
selector:@selector(exitedFullscreen:) 
name:MPMoviePlayerDidExitFullscreenNotification object:moviePlayer];
[[NSNotificationCenter defaultCenter] addObserver:self 
selector:@selector(playbackFinished:) 
name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer];

if ([moviePlayer respondsToSelector:@selector(setFullscreen:animated:)]) {
[[self view] addSubview:[moviePlayer view]];
[moviePlayer setFullscreen:YES animated:YES];
[moviePlayer play];
} else {
[moviePlayer play];
}
[fileView deselectRowAtIndexPath:theIndexPath animated:NO];
}

- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
[self becomeFirstResponder];
}

- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[[UIApplication sharedApplication] endReceivingRemoteControlEvents];
[self resignFirstResponder];
}

- (void)remoteControlReceivedWithEvent:(UIEvent *)event {
NSLog(@remoteControlReceivedWithEvent: %@, event);
if (event.type==UIEventTypeRemoteControl) {
if (event.subtype==UIEventSubtypeRemoteControlPlay) {
NSLog(@Play);
} else if (event.subtype==UIEventSubtypeRemoteControlPause) {
NSLog(@Pause);
} else if (event.subtype==UIEventSubtypeRemoteControlTogglePlayPause) {
NSLog(@Play Pause);
}
}
}

- (void)exitedFullscreen:(NSNotification *)notification {
[[moviePlayer view] removeFromSuperview];
[moviePlayer stop];
[moviePlayer release];
moviePlayer = nil;
[[AVAudioSession sharedInstance] setActive:NO error:nil];
}

- (void)playbackFinished:(NSNotification *)theNotification {
[[NSNotificationCenter defaultCenter] removeObserver:self 
name:MPMoviePlayerDidExitFullscreenNotification object:moviePlayer];
[[NSNotificationCenter defaultCenter] removeObserver:self 
name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer];
NSNumber *reason = [[theNotification userInfo] 
objectForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey];
if ([reason intValue]!=MPMovieFinishReasonUserExited) {
[moviePlayer setFullscreen:NO animated:YES];
[[moviePlayer view] removeFromSuperview];
[moviePlayer stop];
[moviePlayer release];
moviePlayer = nil;
[[AVAudioSession sharedInstance] setActive:NO error:nil];
}
NSLog(@%d, [self isFirstResponder]);
}

As you can see in the code above, I verified that it was first responder and it 
was, so I know it's not a first responder issue.

Can someone help me get this working?

Thanks
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


MPMoviePlayerController, full-screen, and rotation

2012-02-03 Thread Fritz Anderson
iOS 5 (iPad and Simulator), targeting iOS 5, Xcode 4.2.1.

I find that rotating an iPad while a full-screen MPMoviePlayerController is 
playing disrupts the layout of the UISplitView behind it.

I'm glad to add code to this thread, but I thought I'd see if a narrative 
triggered any thoughts right away.

The app is arranged in a split view. The user taps a button in the detail 
view's toolbar. The action method constructs a URL for a .mov in the 
application bundle, and points a new MPMoviePlayerController at it. The movie 
controller's view is made a subview of the detail view (I've also tried making 
it a subview of the split view). I attach a notification-observer for all 
player events to tear the movie controller down upon exit-full-screen or 
playback-finished.

The .controlStyle doesn't seem to matter.

I send -setFullscreen: YES animated: NO to the player, and then -play.

The player plays the movie as expected. The problem comes when I rotate the 
device repeatedly. The movie continues to play, but when it stops, the split 
view has been resized (not stretched, not shifted) so its top edge is under the 
status bar. Rotating the device corrects the layout.

Further, the bar button that split-view detail views must put up in portrait 
orientation is shifted right (apparently proportionally to the number of 
rotations). Opening the master-view popover in landscape orientation blacks-out 
the master view. This cannot be corrected without killing and restarting the 
app.

During rotation, my detail view receives 
splitViewController:willHideViewController:… as expected. It never receives 
splitViewController:willShowViewController:….

This smells like an OS bug to me, but if anyone knows a workaround (or a 
correction), I'd really like to hear it.


Cross-references:
rdar://10796962

https://devforums.apple.com/message/611704#611704
(me)

https://devforums.apple.com/message/587887#587887
(Has the same view-rescaling problems. 12/2/2011)

— F


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: MPMoviePlayerController, full-screen, and rotation

2012-02-03 Thread Fritz Anderson

On 3 Feb 2012, at 11:21 AM, Fritz Anderson wrote:

 Further, the bar button that split-view detail views must put up in portrait 
 orientation is shifted right (apparently proportionally to the number of 
 rotations). Opening the master-view popover in landscape orientation 
 blacks-out the master view.


 This cannot be corrected without killing and restarting the app.

This refers to the misplaced and unremovable detail-popover button. The 
blackout is corrected with a couple of rotations.

— F


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: MPMoviePlayerController, full-screen, and rotation

2012-02-03 Thread Fritz Anderson
Thanks for the suggestion.

Following your lead, I called +attemptRotationToDeviceOrientation after 
installing, and again after removing, the movie-player controller. I made this 
my -shouldAutorotateToInterfaceOrientation: method:

- (BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) 
interfaceOrientation 
{
if (self.demoMovieController) {
return interfaceOrientation == self.demoOrientation;
}
else {
self.demoOrientation = interfaceOrientation;
return YES;
}
}

This did prevent the movie from rotating.

However, when the movie was dismissed, the screen was black. Rotating the 
device makes what looks to be the master view briefly visible at the corners. 
So (I am guessing) the detail view is black, and full-screen, and the master 
view is re-laid-out so that its right edge is at the left edge of the screen.

Earlier, I had tried only the -shouldAutorotateToInterfaceOrientation: method 
above, without + attemptRotationToDeviceOrientation. The effect was the same as 
without attemptRotation….

— F


On 3 Feb 2012, at 12:09 PM, Evadne Wu wrote:

 Just a wild guess, but can you use +[UIViewController 
 attemptRotationToDeviceOrientation] somewhere as a potential workaround?  It 
 seems that the behavior of the movie player messes with rotation notification 
 handling.  Another workaround if you need to target iOS 4.x is to show / hide 
 the status bar a couple of times.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

MPMoviePlayerController doesn't get control events when full-screen

2011-11-28 Thread Fritz Anderson
Xcode 4.2.1, iPad 4.3 Simulator, iOS 5.0 SDK, iPad-only.

My master-detail app has a bar button that triggers this action in the master 
view controller:

- (IBAction) showLegalText: (id) sender
{
UCPromotionController * ucp = [[UCPromotionController alloc] 
init];
ucp.delegate = self;
ucp.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController: ucp animated: YES];
}

In UCPromotionController, self.view is the root view. It contains a navigation 
bar to host some controls, and a web view. I have a Demo button at the left 
end of the nav bar. Its action is:

- (IBAction) videoButtonTapped: (id) sender
{
NSURL * videoURL = [[NSBundle mainBundle] URLForResource: @Demo
   withExtension: @mov];
//  Note that the video is in the application bundle.
//  H.264, AAC (but no audio present), 214 x 278
assert(videoURL);

MPMoviePlayerController *   player =
[[MPMoviePlayerController alloc] initWithContentURL: videoURL];
player.view.frame = self.view.bounds;
[self.view addSubview: player.view];

__block id  mpPlayBackFinishHandler = 
[[NSNotificationCenter defaultCenter]
addObserverForName: nil
object: player
queue: [NSOperationQueue mainQueue]
usingBlock: ^(NSNotification *note) {
if ([note.name isEqualToString: 
MPMoviePlayerPlaybackDidFinishNotification]) {
[player.view removeFromSuperview];
[[NSNotificationCenter defaultCenter]
removeObserver: mpPlayBackFinishHandler];
}
}];
[player play];
}

This works well when the animation runs in the modal window. If the user taps 
the full-screen control, the video goes to full screen. Full-screen 
movie-player views are supposed to show controls when tapped, but this one 
shows them only every four or five taps or so. The full-screen controls do not 
respond to taps at all, trapping the user in the video.

How can I get this to work? Is my problem that the presenting view controller 
is modal?

— F

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Hide Quicktime logo when using MPMoviePlayerController to play audio

2011-08-09 Thread John Love
Reference my  iOS TabController app...

Apple docs state that the AVAudioPlayer class does not provide support for 
streaming audio based on HTTP URL's. AVAudioPlayer plays only music embedded in 
the iApp.

Given that, I do use MPMoviePlayerController to play these web stored audio/mp3 
files which it can handle.

This definitely works. I start out with a UIView with the lyrics for the song. 
At the very bottom of this lyrics UIView is a Play button. The user taps this 
button and the audio/mp3 plays; however, the audio/QuickTime (( Q )) graphic 
comes to the foreground and the lyrics disappear and will stay away until the 
user taps Done.

What I want to happen is that the audio/mp3 is played, but the lyrics stay in 
front.

BTW, I really don't think I need the Done button to be seen because the user 
can stop the audio by simply selecting another Tab.

Obviously this coming to the foreground for the AV Quicktime graphic makes 
sense because the MPMoviePlayerController object is primarily designed to play 
video and the video ought to come to the front. Therefore, it is consistent in 
that the Quicktime graphic also comes to the foreground.

BUT, I really do need a way to defeat the audio/QuickTime (( Q )) graphic 
coming to the front and keep the lyrics there.

I did insert code to determine if it was an audio file (mp3), versus a video 
file (mp4).  So far so good ... and then if it was an audio file, within my 
actual playing segment, I have:


if ( NSClassFromString(@MPMoviePlayerViewController) )
{
if (!isAudioFile)
{
[senderViewController
 
presentMoviePlayerViewControllerAnimated:moviePlayerViewController_];
}
}

[moviePlayerController_ play];


It actually works, that is, I actually hear the mp3 in the background, with the 
lyrics staying in front and the audio/QuickTime (( Q )) graphic does not show …

**BUT, what does happen is horrible, that is, the Done button shows over the 
lyrics** I talked about with some sort of unknown ??? letters there.  The 
gibberish that appears looks line the Done label for the UIButton 
superimposed on which is the time remaining to finish the song.

FWIW, I really don't think I need a Done button because as soon as I go to 
another tab, either new music or a video, the music initially playing stops and 
the new AV file starts.  If I press the Home button, the music stops playing, 
so I think I can get along without the Done button being around.

Any ideas to cover over the Done button ?? ... because right now I don't have a 
clue what to do.


John Love
Touch the Future! Teach!



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: MPMoviePlayerController Fast forward

2011-07-29 Thread Matt Neuburg
On Thu, 28 Jul 2011 15:06:29 -0400, Steve Kostrey st...@askvideo.com said:
I've implemented MPMoviePlayerController (iPhone/iPad) and I'm playing videos 
without trouble but I'm not sure how to receive an event from the Fast forward 
overlay button.
I've tried everything the documentation suggests about remote control but I'm 
not sure that's the way.

I guess it all depends on what you mean by the fast forward overlay button. 
The remote control events are for events sent by the remote interface - that 
is, the buttons in a physical device (such as the earphones that come with an 
iPhone), or the buttons that you see when you double-click the Home button and 
swipe left.

But if you are referring to the buttons that are *part* of the 
MPMoviePlayerController's view interface, then those have nothing to do with 
remote control.

m.

--
matt neuburg, phd = m...@tidbits.com, http://www.apeth.net/matt/
A fool + a tool + an autorelease pool = cool!
Programming iOS 4!
http://www.apeth.net/matt/default.html#iosbook___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: MPMoviePlayerController Fast forward

2011-07-29 Thread Heath Borders
You could do key-value observing on currentPlaybackRate.

http://developer.apple.com/library/ios/#documentation/mediaplayer/reference/MPMediaPlayback_protocol/Reference/Reference.html#//apple_ref/occ/intfp/MPMediaPlayback/currentPlaybackRate

-Heath Borders
heath.bord...@gmail.com
Twitter: heathborders
http://heath-tech.blogspot.com



On Thu, Jul 28, 2011 at 2:06 PM, Steve Kostrey st...@askvideo.com wrote:
 I've implemented MPMoviePlayerController (iPhone/iPad) and I'm playing videos 
 without trouble but I'm not sure how to receive an event from the Fast 
 forward overlay button.
 I've tried everything the documentation suggests about remote control but I'm 
 not sure that's the way.

 I've tried the following code:

 [[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
 [self becomeFirstResponder];

 - (BOOL)canBecomeFirstResponder {
  return YES;
 }

 - (void)remoteControlReceivedWithEvent:(UIEvent *)event {

  if( event.type == UIEventTypeRemoteControl ) {
      NSLog(@sub type: %d, event.subtype);
  }
 }

 Not sure where to place this (and when I place it in the header I get 
 redefinition errors):

 typedef enum {
  // available in iPhone OS 3.0
  UIEventSubtypeNone                              = 0,

  // for UIEventTypeMotion, available in iPhone OS 3.0
  UIEventSubtypeMotionShake                       = 1,

  // for UIEventTypeRemoteControl, available in iPhone OS 4.0
  UIEventSubtypeRemoteControlPlay                 = 100,
  UIEventSubtypeRemoteControlPause                = 101,
  UIEventSubtypeRemoteControlStop                 = 102,
  UIEventSubtypeRemoteControlTogglePlayPause      = 103,
  UIEventSubtypeRemoteControlNextTrack            = 104,
  UIEventSubtypeRemoteControlPreviousTrack        = 105,
  UIEventSubtypeRemoteControlBeginSeekingBackward = 106,
  UIEventSubtypeRemoteControlEndSeekingBackward   = 107,
  UIEventSubtypeRemoteControlBeginSeekingForward  = 108,
  UIEventSubtypeRemoteControlEndSeekingForward    = 109,
 } UIEventSubtype;


 Bottom line is I would love to receive the FF event. Has anyone successfully 
 done this?



 ___

 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com

 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/heath.borders%40gmail.com

 This email sent to heath.bord...@gmail.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


MPMoviePlayerController Fast forward

2011-07-28 Thread Steve Kostrey
I've implemented MPMoviePlayerController (iPhone/iPad) and I'm playing videos 
without trouble but I'm not sure how to receive an event from the Fast forward 
overlay button.
I've tried everything the documentation suggests about remote control but I'm 
not sure that's the way.

I've tried the following code:

[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
[self becomeFirstResponder];

- (BOOL)canBecomeFirstResponder {
  return YES; 
}

- (void)remoteControlReceivedWithEvent:(UIEvent *)event {

  if( event.type == UIEventTypeRemoteControl ) {
  NSLog(@sub type: %d, event.subtype);
  }
}

Not sure where to place this (and when I place it in the header I get 
redefinition errors):

typedef enum {
  // available in iPhone OS 3.0
  UIEventSubtypeNone  = 0,

  // for UIEventTypeMotion, available in iPhone OS 3.0
  UIEventSubtypeMotionShake   = 1,

  // for UIEventTypeRemoteControl, available in iPhone OS 4.0
  UIEventSubtypeRemoteControlPlay = 100,
  UIEventSubtypeRemoteControlPause= 101,
  UIEventSubtypeRemoteControlStop = 102,
  UIEventSubtypeRemoteControlTogglePlayPause  = 103,
  UIEventSubtypeRemoteControlNextTrack= 104,
  UIEventSubtypeRemoteControlPreviousTrack= 105,
  UIEventSubtypeRemoteControlBeginSeekingBackward = 106,
  UIEventSubtypeRemoteControlEndSeekingBackward   = 107,
  UIEventSubtypeRemoteControlBeginSeekingForward  = 108,
  UIEventSubtypeRemoteControlEndSeekingForward= 109,
} UIEventSubtype;


Bottom line is I would love to receive the FF event. Has anyone successfully 
done this?



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: MPMoviePlayerController

2011-04-16 Thread Matt Neuburg
On Thu, 14 Apr 2011 14:58:06 -0400, Jeffrey Walton noloa...@gmail.com said:
The problem appears to be with the size of the M4V

I had trouble with this too, the first time I tried to use 
MPMoviePlayerController. Consult the specs for the hardware first. For example, 
here are the specs for an iPad 2:

http://www.apple.com/ipad/specs/

 Video formats supported: H.264 video up to 720p, 30 frames per second, Main 
 Profile level 3.1 with AAC-LC audio up to 160 Kbps, 48kHz, stereo audio in 
 .m4v, .mp4, and .mov file formats; MPEG-4 video, up to 2.5 Mbps, 640 by 480 
 pixels, 30 frames per second, Simple Profile with AAC-LC audio up to 160 Kbps 
 per channel, 48kHz, stereo audio in .m4v, .mp4, and .mov file formats;

I'm betting we can stop right there: your movie bitrate is probably too high, 
or the pixel dimensions are too great. Use QTAmateur to convert the video to 
something your device can play. m.

--
matt neuburg, phd = m...@tidbits.com, http://www.apeth.net/matt/
A fool + a tool + an autorelease pool = cool!
Programming iOS 4!
http://www.apeth.net/matt/default.html#iosbook___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: MPMoviePlayerController

2011-04-16 Thread Jeffrey Walton
On Sat, Apr 16, 2011 at 11:44 AM, Matt Neuburg m...@tidbits.com wrote:
 On Thu, 14 Apr 2011 14:58:06 -0400, Jeffrey Walton noloa...@gmail.com said:
The problem appears to be with the size of the M4V

 I had trouble with this too, the first time I tried to use 
 MPMoviePlayerController. Consult the specs for the hardware first. For 
 example, here are the specs for an iPad 2:

 http://www.apple.com/ipad/specs/

 Video formats supported: H.264 video up to 720p, 30 frames per second, Main 
 Profile level 3.1 with AAC-LC audio up to 160 Kbps, 48kHz, stereo audio in 
 .m4v, .mp4, and .mov file formats; MPEG-4 video, up to 2.5 Mbps, 640 by 480 
 pixels, 30 frames per second, Simple Profile with AAC-LC audio up to 160 
 Kbps per channel, 48kHz, stereo audio in .m4v, .mp4, and .mov file formats;

 I'm betting we can stop right there: your movie bitrate is probably too high, 
 or the pixel dimensions are too great. Use QTAmateur to convert the video to 
 something your device can play. m.

Hi Doctor,

I'll check the movie's specification and report back to the group (I'd
bet others will suffer in the future).

For what its worth, Apple's sample [1] is broken - it can't even play
the movie it supplies with its sample.

Jeff

[1] 
http://developer.apple.com/library/ios/#samplecode/MoviePlayer_iPhone/Introduction/Intro.html
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: MPMoviePlayerController

2011-04-16 Thread Matt Neuburg

On Apr 16, 2011, at 9:00 AM, Jeffrey Walton wrote:

 
 For what its worth, Apple's sample [1] is broken - it can't even play
 the movie it supplies with its sample.
 
 Jeff
 
 [1] 
 http://developer.apple.com/library/ios/#samplecode/MoviePlayer_iPhone/Introduction/Intro.html

That's a well-known bug in the example. It has nothing to do with the movie. In 
fact, I used that same movie in the tests for my book (you can see in the 
screen shots in the discussion of MPMoviePlayerController).

The history appears to be that this was a Mac OS X example and was then made 
available for iOS, and the example has forgotten to compensate. The code says 
[self.moviePlayer play], but they've forgotten the most important step: add the 
MPMoviePlayerController's view to the interface. So in fact the movie *is* 
playing - you just can't see it because it isn't in the interface. (On Mac OS X 
I think the movie played in a different window, but of course there is no 
different window on iOS.)

It's easy to fix:

-(IBAction)playMovieButtonPressed:(id)sender
{
MoviePlayerAppDelegate *appDelegate = 
(MoviePlayerAppDelegate *)[[UIApplication sharedApplication] delegate];
[appDelegate initAndPlayMovie:[self localMovieURL]];
UIView* v = [appDelegate moviePlayer].view;
appDelegate.moviePlayer.scalingMode = MPMovieScalingModeAspectFit;
v.frame = CGRectMake(54,39,205,135);
[[sender superview] addSubview:v];
return;
}

You could easily have found this out with Google; explanations of how to fix 
this example are plastered all over the Internet. 

m.

PS. And of course, the chapter in my book about MPMoviePlayerController lays a 
lot of stress on your responsibility to put the darned view into the interface! 
:)

--
matt neuburg, phd = m...@tidbits.com, http://www.apeth.net/matt/
pantes anthropoi tou eidenai oregontai phusei
Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf
Programming iOS 4! http://www.apeth.net/matt/default.html#iosbook
RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
TidBITS, Mac news and reviews since 1990, http://www.tidbits.com


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: MPMoviePlayerController

2011-04-16 Thread Jeffrey Walton
On Sat, Apr 16, 2011 at 12:39 PM, Matt Neuburg m...@tidbits.com wrote:

 On Apr 16, 2011, at 9:00 AM, Jeffrey Walton wrote:


 For what its worth, Apple's sample [1] is broken - it can't even play
 the movie it supplies with its sample.

 Jeff

 [1] 
 http://developer.apple.com/library/ios/#samplecode/MoviePlayer_iPhone/Introduction/Intro.html

 That's a well-known bug in the example. It has nothing to do with the movie. 
 In fact, I used that same movie in the tests for my book (you can see in the 
 screen shots in the discussion of MPMoviePlayerController).
Out of curiosity, did you test your book's code against a movie
acquired from iTunes? In my naiveness, I thought the combination of an
iTunes movie on authorized Apple hardware would work out of the box.
(I have not ruled out DRM at this point).

 The history appears to be that this was a Mac OS X example and was then made 
 available for iOS, and the example has forgotten to compensate. The code says 
 [self.moviePlayer play], but they've forgotten the most important step: add 
 the MPMoviePlayerController's view to the interface. So in fact the movie 
 *is* playing - you just can't see it because it isn't in the interface. (On 
 Mac OS X I think the movie played in a different window, but of course there 
 is no different window on iOS.)

 It's easy to fix:

 -(IBAction)playMovieButtonPressed:(id)sender
 {
    MoviePlayerAppDelegate *appDelegate =
        (MoviePlayerAppDelegate *)[[UIApplication sharedApplication] delegate];
    [appDelegate initAndPlayMovie:[self localMovieURL]];
    UIView* v = [appDelegate moviePlayer].view;
    appDelegate.moviePlayer.scalingMode = MPMovieScalingModeAspectFit;
    v.frame = CGRectMake(54,39,205,135);
    [[sender superview] addSubview:v];
    return;
 }
This looks similar to other examples I've seen. There is a noted
difference - the player appears to be part of the Application's
delegate rather than a modally presented view.

 You could easily have found this out with Google; explanations of how to fix 
 this example are plastered all over the Internet.
Perhaps my expectations are too high - I expect examples from the
vendor should work, without the need for an easter egg hunt. I think
its a reasonable expectation.

 PS. And of course, the chapter in my book about MPMoviePlayerController lays 
 a lot of stress on your responsibility to put the darned view into the 
 interface! :)
OK. I look forward to the day it goes to press (I've got it preordered
via Amazon).

Jeff
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: MPMoviePlayerController

2011-04-16 Thread Jeffrey Walton
On Sat, Apr 16, 2011 at 11:44 AM, Matt Neuburg m...@tidbits.com wrote:
 On Thu, 14 Apr 2011 14:58:06 -0400, Jeffrey Walton noloa...@gmail.com said:
The problem appears to be with the size of the M4V

 I had trouble with this too, the first time I tried to use 
 MPMoviePlayerController. Consult the specs for the hardware first. For 
 example, here are the specs for an iPad 2:

 http://www.apple.com/ipad/specs/

 Video formats supported: H.264 video up to 720p, 30 frames per second, Main 
 Profile level 3.1 with AAC-LC audio up to 160 Kbps, 48kHz, stereo audio in 
 .m4v, .mp4, and .mov file formats; MPEG-4 video, up to 2.5 Mbps, 640 by 480 
 pixels, 30 frames per second, Simple Profile with AAC-LC audio up to 160 
 Kbps per channel, 48kHz, stereo audio in .m4v, .mp4, and .mov file formats;

 I'm betting we can stop right there: your movie bitrate is probably too high, 
 or the pixel dimensions are too great. Use QTAmateur to convert the video to 
 something your device can play. m.

From QuickTime's Movie Inspector (I'm not sure what the 'millions' is):

Format: ACV0 Media, 640x480, Millions, AAC (Protected), 2 channels, 44100 HZ
FPS: 29.97
Data Size: 254.9 MB
Data Rate: 1560.66 kbit/s
Current Size: 640x480 (Actual)

Apple uses 1000*1000 as a MB (and not the customary 1024*1024), so the
reported size is not quite accurate. But I don't expect it to make a
difference.

Jeff
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: MPMoviePlayerController

2011-04-16 Thread Eli Bach

On Apr 16, 2011, at 11:35 AM, Jeffrey Walton wrote:

 Format: ACV0 Media, 640x480, Millions, AAC (Protected), 2 channels, 44100 HZ

I'm 90% sure that it's the (Protected) part that prevents it from playing in 
non-Apple created video players.

Eli

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: MPMoviePlayerController

2011-04-16 Thread Jeffrey Walton
On Sat, Apr 16, 2011 at 12:39 PM, Matt Neuburg m...@tidbits.com wrote:

 On Apr 16, 2011, at 9:00 AM, Jeffrey Walton wrote:


 For what its worth, Apple's sample [1] is broken - it can't even play
 the movie it supplies with its sample.

 Jeff

 [1] 
 http://developer.apple.com/library/ios/#samplecode/MoviePlayer_iPhone/Introduction/Intro.html

 That's a well-known bug in the example. It has nothing to do with the movie. 
 In fact, I used that same movie in the tests for my book (you can see in the 
 screen shots in the discussion of MPMoviePlayerController).

 The history appears to be that this was a Mac OS X example and was then made 
 available for iOS, and the example has forgotten to compensate. The code says 
 [self.moviePlayer play], but they've forgotten the most important step: add 
 the MPMoviePlayerController's view to the interface. So in fact the movie 
 *is* playing - you just can't see it because it isn't in the interface. (On 
 Mac OS X I think the movie played in a different window, but of course there 
 is no different window on iOS.)

 It's easy to fix:

 -(IBAction)playMovieButtonPressed:(id)sender
 {
    MoviePlayerAppDelegate *appDelegate =
        (MoviePlayerAppDelegate *)[[UIApplication sharedApplication] delegate];
    [appDelegate initAndPlayMovie:[self localMovieURL]];
    UIView* v = [appDelegate moviePlayer].view;
    appDelegate.moviePlayer.scalingMode = MPMovieScalingModeAspectFit;
    v.frame = CGRectMake(54,39,205,135);
    [[sender superview] addSubview:v];
    return;
 }

Hi Doctor,

With your changes, and the changes below, I was able to crash Xcode
(but the movie never played).

Apple appears to have serious problems with its MediaPlayer library
and its accompanying documentation. Its amazing it made t through QA
and was released for general consumption.

Jeff

// return a URL for the movie file in our bundle
-(NSURL *)localMovieURL
{
if (self.movieURL == nil)
{
// NSString *moviePath = [bundle pathForResource:@Movie 
ofType:@m4v];
NSString* path = [NSHomeDirectory()
stringByAppendingPathComponent:@Documents];
if(path)
{
NSString* moviePath = [path 
stringByAppendingPathComponent:@02
Lost Verizon.m4v];
if (moviePath)
{
self.movieURL = [NSURL 
fileURLWithPath:moviePath];
}
}
}

return self.movieURL;
}
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: MPMoviePlayerController

2011-04-16 Thread Jeffrey Walton
On Sat, Apr 16, 2011 at 2:19 PM, Eli Bach eba...@gmail.com wrote:

 On Apr 16, 2011, at 11:35 AM, Jeffrey Walton wrote:

 Format: ACV0 Media, 640x480, Millions, AAC (Protected), 2 channels, 44100 HZ

 I'm 90% sure that it's the (Protected) part that prevents it from playing 
 in non-Apple created video players.
Thanks Eli. 0 hits for AAC (Protected) in the developer area [1]. I
suppose we are left to guess and conjecture.

Apple states the following in quite a few documents: iPhone supports
the ability to play back video files directly from your application
(no strings attached). Is MPMoviePlayerController (and
MPMoviePlayerViewController) considered non-Apple? Neither the
MPMoviePlayerController Class Reference [2], Using Video [3], nor
Audio  Video Coding How-To's [4] mentions anything about protected
content or DRM.

Jeff

[1] http://developer.apple.com/library/ios/search/?q=%22AAC+%28Protected%29%22
[2] 
http://developer.apple.com/library/ios/#documentation/MediaPlayer/Reference/MPMoviePlayerController_Class/Reference/Reference.html
[3] 
http://developer.apple.com/library/ios/#documentation/AudioVideo/Conceptual/MultimediaPG/UsingVideo/UsingVideo.html
[4] 
http://developer.apple.com/library/ios/#codinghowtos/AudioAndVideo/_index.html
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: MPMoviePlayerController

2011-04-14 Thread Jeffrey Walton
On Wed, Apr 13, 2011 at 12:15 PM, Jeffrey Walton noloa...@gmail.com wrote:
 Hi All,

 I'm trying to play a M4V acquired from iTunes [1]. The movie is local
 and was transferred into my sandbox using iTunes via file sharing.

 Working from a Hillegass example ('Playing Movie Files', p. 294), the
 player appears to load/display but does not play.

 Unfortunately, PLAY is not documented [2]. In addition, I can't find a
 delegate (as with other controllers) and there are no notifications
 covering errors [2]. Finally, the error log is for network streams
 [2].

 How does one determine errors when using MPMoviePlayerController?

 More philosophical: why are the APIs so inconsistent? Why is there no
 readily apparent way to consistently retrieve error information
 (Windows has GetLastError and Linux has errno)?

The problem appears to be with the size of the M4V. For example,
Hillegass's Chapter 20 sample ('Layer.m4p') at 2.2 MB plays as
expected. The Simpsons episode, at 230 MB, does not play. The player
moves from a 'ready' state to a 'playing' state and then immediately
back to a 'ready' state without a Finished notification or error.

If anyone has experienced similar, work arounds would be appreciated.
So far, I have only figured out how to crash Xcode while the app was
under the debugger.

Jeff
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


MPMoviePlayerController

2011-04-13 Thread Jeffrey Walton
Hi All,

I'm trying to play a M4V acquired from iTunes [1]. The movie is local
and was transferred into my sandbox using iTunes via file sharing.

Working from a Hillegass example ('Playing Movie Files', p. 294), the
player appears to load/display but does not play.

Unfortunately, PLAY is not documented [2]. In addition, I can't find a
delegate (as with other controllers) and there are no notifications
covering errors [2]. Finally, the error log is for network streams
[2].

How does one determine errors when using MPMoviePlayerController?

More philosophical: why are the APIs so inconsistent? Why is there no
readily apparent way to consistently retrieve error information
(Windows has GetLastError and Linux has errno)?

Jeff

[1] http://www.apple.com/itunes/charts/tv-shows/the-simpsons/lost-verizon/

[2] 
http://developer.apple.com/library/ios/#documentation/mediaplayer/reference/MPMoviePlayerController_Class/Reference/Reference.html
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: MPMoviePlayerController

2011-04-13 Thread Kyle Sluder
On Apr 13, 2011, at 9:15 AM, Jeffrey Walton noloa...@gmail.com wrote:

 
 
 Unfortunately, PLAY is not documented [2]. In addition, I can't find a
 delegate (as with other controllers) and there are no notifications
 covering errors [2]. Finally, the error log is for network streams
 [2].

Not sure about the error handling, but MPMoviePlayerController is documented to 
conform to MPMediaPlayback, the documentation for which describes -play: 
http://developer.apple.com/library/ios/documentation/mediaplayer/reference/MPMediaPlayback_protocol/Reference/Reference.html#//apple_ref/occ/intfm/MPMediaPlayback/play


 More philosophical: why are the APIs so inconsistent? Why is there no
 readily apparent way to consistently retrieve error information
 (Windows has GetLastError and Linux has errno)?

And you've never seen An error occurred: There was an error (E_SUCCESS) on 
Windows, or similar errno stomping on *nix?

What UNIX libraries do you regularly use that set errno?

Returning errors from the place they happen, or providing a block argument that 
can act as an error handler, or notifying a delegate object than an error has 
occurred in an operation it requested before are all vastly superior to the 
last failure gets to write an oh-so-descriptive integer to a shared memory 
location.

--Kyle Sluder___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: MPMoviePlayerController

2011-04-13 Thread Jeffrey Walton
On Wed, Apr 13, 2011 at 1:26 PM, Kyle Sluder kyle.slu...@gmail.com wrote:
 On Apr 13, 2011, at 9:15 AM, Jeffrey Walton noloa...@gmail.com wrote:



 Unfortunately, PLAY is not documented [2]. In addition, I can't find a
 delegate (as with other controllers) and there are no notifications
 covering errors [2]. Finally, the error log is for network streams
 [2].

 Not sure about the error handling, but MPMoviePlayerController is documented 
 to conform to MPMediaPlayback, the documentation for which describes -play: 
 http://developer.apple.com/library/ios/documentation/mediaplayer/reference/MPMediaPlayback_protocol/Reference/Reference.html#//apple_ref/occ/intfm/MPMediaPlayback/play
Silly me. I went looking for documentation on MPMoviePlayerController
PLAY in MPMoviePlayerController's documentation.


 More philosophical: why are the APIs so inconsistent? Why is there no
 readily apparent way to consistently retrieve error information
 (Windows has GetLastError and Linux has errno)?

 And you've never seen An error occurred: There was an error (E_SUCCESS) on 
 Windows, or similar errno stomping on *nix?
It happens at times. My personal experience is that I sometimes log
*before* retrieving the error (the logging succeeds and stomps the
failure code). If you find a program is regularly producing incorrect
results and incorrectly reporting errors, its probably time to
uninstall.

 What UNIX libraries do you regularly use that set errno?
For example, socket calls. Typically, anything less than 0 cause me to
inspect errno. For the visual stuff, I use QT on Linux so an exception
is thrown.

 Returning errors from the place they happen, or providing a block argument 
 that can act as an error handler, or notifying a delegate object than an 
 error has occurred in an operation it requested before are all vastly 
 superior to the last failure gets to write an oh-so-descriptive integer to a 
 shared memory location.
The great thing about an immediate return code (followed by a call to
GetLastError or errno) is one can find the point of first failure
quickly, without disgorging the point of failure from the reporting
mechanism. There's a lot to be said about finding the point of first
failure quickly.

MPMoviePlayerPlaybackDidFinishNotification  ... is also sent when
playback fails because of an error. So how does one tell when the
notification is sent for a good reason, versus a bad reason? As can be
seen, the documentation does not clarify. Its too bad there is no
'MPMoviePlayerError' (or similar) notification (perhaps I'm reading
the notification section incorrectly).

Below is the rabbit hole I went down trying to play a Movie. I would
give my left arm for a return code right about now. With a error code,
I could search for MPMoviePlayerController play error 0xX and
probably get dozens of questions/answers pertinent to my situation.

Jeff

Purchase TV Show from Apple's iTunes
v
Attempt to play TV show on iPhone
v
UIWebView, loadRequest
v
Use code from a well known author
v
Video fails to play
v
Look up docs on loadRequest
v
Nothing about errors in loadRequest documentation
v
Ask for help to determine loadRequest errors
v
Use webView:didFailLoadWithError:
v
Error is Plug-in handled load (sounds a lot like stomping an error
with success)
v
Switch to MPMoviePlayerController
v
Use code from a well known author
v
Video fails to play
v
PLAY is not documented in MPMoviePlayerController
v
Try to locate the error
v
Stack Overflow states errors reported through notifications
v
MPMoviePlayerPlaybackDidFinishNotification is sent for both good and
bad conditions
v
Scratch head and wonder
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: MPMoviePlayerController

2011-04-13 Thread Quincey Morris
On Apr 13, 2011, at 11:39, Jeffrey Walton wrote:

 Silly me. I went looking for documentation on MPMoviePlayerController
 PLAY in MPMoviePlayerController's documentation.

Unfortunately, it's just something you need to learn about Apple's style of 
documentation -- when consulting the documentation for a class, especially the 
first time, you also need to look at the superclass documentation and (now that 
so many informal protocols have been formalized in Snow Leopard) in the 
documentation for protocols the class conforms to.

Although this can trip up the unwary (usually only once), it's hard to get 
worked up about, because the alternative -- repeating inherited method 
documentation everywhere, which some people have asked for on this list -- 
would probably be worse. There's an *awful* lot of methods whose behavior is 
shared.

 The great thing about an immediate return code (followed by a call to
 GetLastError or errno) is one can find the point of first failure
 quickly, without disgorging the point of failure from the reporting
 mechanism. There's a lot to be said about finding the point of first
 failure quickly.

The other point that Kyle didn't make explicitly is that global error variables 
aren't thread safe. Also, since Cocoa internally makes a lot of use of 
threading that you won't see explicitly, the point of failure can't be very 
well-defined in Mac OS X, in the sense it would be if you were single-threaded. 
'errno' is old-school.

 MPMoviePlayerPlaybackDidFinishNotification  ... is also sent when
 playback fails because of an error. So how does one tell when the
 notification is sent for a good reason, versus a bad reason? As can be
 seen, the documentation does not clarify. Its too bad there is no
 'MPMoviePlayerError' (or similar) notification (perhaps I'm reading
 the notification section incorrectly).

FWIW, anything involving QuickTime is special. Historically, the QuickTime 
APIs have been a mess, and there are now archeological remnants of various 
attempts to fix and/or simplify them. QuickTime-related frameworks are a lot 
more rational and usable than they used to be, but for those historical reasons 
they still play by a different set of rules.

I'm sorry that you've been through the wringer in getting up to speed on Cocoa. 
It's not your fault, and you've been a little bit unlucky. Take comfort that 
the worst of the nightmare is probably over.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: MPMoviePlayerController

2011-04-13 Thread Kyle Sluder
On Wed, Apr 13, 2011 at 11:39 AM, Jeffrey Walton noloa...@gmail.com wrote:
 On Wed, Apr 13, 2011 at 1:26 PM, Kyle Sluder kyle.slu...@gmail.com wrote:
 On Apr 13, 2011, at 9:15 AM, Jeffrey Walton noloa...@gmail.com wrote:



 Unfortunately, PLAY is not documented [2]. In addition, I can't find a
 delegate (as with other controllers) and there are no notifications
 covering errors [2]. Finally, the error log is for network streams
 [2].

 Not sure about the error handling, but MPMoviePlayerController is documented 
 to conform to MPMediaPlayback, the documentation for which describes -play: 
 http://developer.apple.com/library/ios/documentation/mediaplayer/reference/MPMediaPlayback_protocol/Reference/Reference.html#//apple_ref/occ/intfm/MPMediaPlayback/play

 Silly me. I went looking for documentation on MPMoviePlayerController
 PLAY in MPMoviePlayerController's documentation.

Well, the MPMoviePlayerController documentation's Overview section
does say the following:

This class supports programmatic control of movie playback, and
user-based control via buttons supplied by the movie player. You can
control most aspects of playback programmatically using the methods
and properties of the MPMediaPlayback protocol, to which this class
conforms. The methods and properties of that protocol let you start
and stop playback, seek forward and backward through the movie’s
content, and even change the playback rate.

 The great thing about an immediate return code (followed by a call to
 GetLastError or errno) is one can find the point of first failure
 quickly, without disgorging the point of failure from the reporting
 mechanism. There's a lot to be said about finding the point of first
 failure quickly.

Except when that error happens in a background task. You certainly
wouldn't want -play to block until the user stopped playback or an
error occurred.


 MPMoviePlayerPlaybackDidFinishNotification  ... is also sent when
 playback fails because of an error. So how does one tell when the
 notification is sent for a good reason, versus a bad reason? As can be
 seen, the documentation does not clarify. Its too bad there is no
 'MPMoviePlayerError' (or similar) notification (perhaps I'm reading
 the notification section incorrectly).

The sentence directly before the one you quoted: The userInfo
dictionary of this notification contains the
MPMoviePlayerPlaybackDidFinishReasonUserInfoKey key, which indicates
the reason that playback finished. Click the link, it takes you to
the documentation for that notification key, which states The value
of this key is an NSNumber containing an integer value that represents
one of the “MPMovieFinishReason” constants. Click that link, you get
the three values: MPMovieFinishReasonPlaybackEnded,
MPMovieFinishReasonPlaybackError, MPMovieFinishReasonUserExited.

Not that difficult.

--Kyle Sluder
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: MPMoviePlayerController

2011-04-13 Thread Kyle Sluder
On Wed, Apr 13, 2011 at 11:39 AM, Jeffrey Walton noloa...@gmail.com wrote:
 Below is the rabbit hole I went down trying to play a Movie. I would
 give my left arm for a return code right about now. With a error code,
 I could search for MPMoviePlayerController play error 0xX and
 probably get dozens of questions/answers pertinent to my situation.

I don't know what it is about Apple's documentation, but something
about it trips everyone up when they first get to the platform. I'm
certainly among that crowd. It's not that things aren't sufficiently
documented; usually they are, with certain notable exceptions like
Core Audio. Maybe it's that you really do need to be willing to make
plenty of clicks in order to understand small facets of the thing
you're looking at. On top of that, you really do need to understand
the whole of a class before you can proficiently work with it. Just
encountering methods that sound like they do the right thing rarely
works; there's usually some required supporting infrastructure.

Sorry this has frustrated you. But eventually everything starts making
perfect sense. The Mac and iOS platforms really are some of the
best-designed and most developer-friendly APIs in existence.

--Kyle Sluder
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: MPMoviePlayerController

2011-04-13 Thread Jeffrey Walton
On Wed, Apr 13, 2011 at 3:12 PM, Kyle Sluder kyle.slu...@gmail.com wrote:
 On Wed, Apr 13, 2011 at 11:39 AM, Jeffrey Walton noloa...@gmail.com wrote:
 On Wed, Apr 13, 2011 at 1:26 PM, Kyle Sluder kyle.slu...@gmail.com wrote:
 On Apr 13, 2011, at 9:15 AM, Jeffrey Walton noloa...@gmail.com wrote:

[ SNIP ]


 MPMoviePlayerPlaybackDidFinishNotification  ... is also sent when
 playback fails because of an error. So how does one tell when the
 notification is sent for a good reason, versus a bad reason? As can be
 seen, the documentation does not clarify. Its too bad there is no
 'MPMoviePlayerError' (or similar) notification (perhaps I'm reading
 the notification section incorrectly).

 The sentence directly before the one you quoted: The userInfo
 dictionary of this notification contains the
 MPMoviePlayerPlaybackDidFinishReasonUserInfoKey key, which indicates
 the reason that playback finished. Click the link, it takes you to
 the documentation for that notification key, which states The value
 of this key is an NSNumber containing an integer value that represents
 one of the “MPMovieFinishReason” constants. Click that link, you get
 the three values: MPMovieFinishReasonPlaybackEnded,
 MPMovieFinishReasonPlaybackError, MPMovieFinishReasonUserExited.

 Not that difficult.
:)

I'm registered for the following notifications:
* MPMoviePlayerPlaybackDidFinishNotification (0)
* MPMoviePlayerPlaybackDidFinishReasonUserInfoKey (1)
* MPMoviePlayerPlaybackStateDidChangeNotification (2)
* MPMoviePlayerLoadStateDidChangeNotification (3)
* MPMoviePlayerThumbnailImageRequestDidFinishNotification (4)

Here's what I am seeing (I'm logging in the notification). The double
MPMoviePlayerLoadStateDidChangeNotification is the Start/Stop sequence
from the player. The stop comes immediately. (I've also tried with a
filename which has no embedded spaces). Notice that
MPMoviePlayerPlaybackDidFinish* is never received.

2011-04-13 16:48:41.725 MyTestApp[364:707] Filename:
/var/mobile/Applications/82D7D326-A6FA-4DE9-8DB9-D703C5F3DCB9/Documents/02
Lost Verizon.m4v
...
[Switching to thread 13315]
2011-04-13 16:48:42.671 MyTestApp[364:707] Notification:
NSConcreteNotification 0x1735d0 {name =
MPMoviePlayerLoadStateDidChangeNotification; object =
MPMoviePlayerController: 0x1e8f20}
2011-04-13 16:48:42.677 MyTestApp[364:707] Notification:
NSConcreteNotification 0x16ade0 {name =
MPMoviePlayerPlaybackStateDidChangeNotification; object =
MPMoviePlayerController: 0x1e8f20}

Unfortunately, according to the documentation for
MPMoviePlayerPlaybackStateDidChangeNotification: There is no
userInfo. It kind of takes the wind out of the sails for fetching
MPMovieFinishReasonPlaybackError from the dictionary.

Jeff
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: MPMoviePlayerController

2011-04-13 Thread Jeffrey Walton
On Wed, Apr 13, 2011 at 3:32 PM, Kyle Sluder kyle.slu...@gmail.com wrote:
 On Wed, Apr 13, 2011 at 11:39 AM, Jeffrey Walton noloa...@gmail.com wrote:
 Below is the rabbit hole I went down trying to play a Movie. I would
 give my left arm for a return code right about now. With a error code,
 I could search for MPMoviePlayerController play error 0xX and
 probably get dozens of questions/answers pertinent to my situation.

 I don't know what it is about Apple's documentation, but something
 about it trips everyone up when they first get to the platform. I'm
 certainly among that crowd. It's not that things aren't sufficiently
 documented; usually they are, with certain notable exceptions like
 Core Audio. Maybe it's that you really do need to be willing to make
 plenty of clicks in order to understand small facets of the thing
 you're looking at. On top of that, you really do need to understand
 the whole of a class before you can proficiently work with it. Just
 encountering methods that sound like they do the right thing rarely
 works; there's usually some required supporting infrastructure.

 Sorry this has frustrated you. But eventually everything starts making
 perfect sense. The Mac and iOS platforms really are some of the
 best-designed and most developer-friendly APIs in existence.
There's no need to apologize for Apple.

I see why good iPhone programmers are worth their weight in gold (and
so hard to find).

Jeff
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: MPMoviePlayerController

2011-04-13 Thread Matt Neuburg
On Wed, 13 Apr 2011 12:32:27 -0700, Kyle Sluder kyle.slu...@gmail.com said:

I don't know what it is about Apple's documentation, but something
about it trips everyone up when they first get to the platform. I'm
certainly among that crowd. It's not that things aren't sufficiently
documented; usually they are, with certain notable exceptions like
Core Audio.

I would point to Core Animation, which omits or gets wrong a number of key 
(hint) fundamental facts.

Maybe it's that you really do need to be willing to make
plenty of clicks in order to understand small facets of the thing
you're looking at. On top of that, you really do need to understand
the whole of a class before you can proficiently work with it.

This is why my book has a chapter on documentation where I actually take the 
reader through a typical page of class documentation, while jumping up and down 
and yelling don't forget to look in the superclass, don't forget to look in 
the adopted protocols, and so on with all the other lessons I've learned over 
the years. Nonetheless, although I think the docs have become *vastly* better 
cross-linked than they used to be (and don't think I don't appreciate it!), the 
business of documenting things in multiple files, often *without* linkage of 
any kind, remains one of the documentation's greatest weaknesses. (My favorite 
examples are things like the string drawing methods and awakeFromNib - indeed, 
NSObject itself is very scattered and quite hard to get a complete handle on.) 
AppKiDo can be a help here.

And in the end, of course, documentation is only that - documentation. A list 
of methods and functions is not knowledge. Docs cannot be reasonably expected 
to have explanatory or (perhaps I should say) instructive power as well. It can 
often take a great deal of experimentation before the penny drops and the 
pieces of a framework or technology start to gel in your mind and you start to 
see when and how to use it. 

m.

PS In the particular case of MPMoviePlayerController, where the OP was having 
trouble tracking down a play command, my book has: Further programmatic 
control over the actual playing of the movie is obtained through the 
MPMediaPlayback protocol, which MPMoviePlayerController adopts. This gives you 
the expected play, pause, and stop methods, as well as commands for seeking 
quickly forward and backward... I had trouble discovering this too, the first 
time! I like to think that I've suffered so you don't have to... :)

--
matt neuburg, phd = m...@tidbits.com, http://www.apeth.net/matt/
A fool + a tool + an autorelease pool = cool!
Programming iOS 4!
http://www.apeth.net/matt/default.html#iosbook___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: MPMoviePlayerController setContentURL twice

2011-03-22 Thread Heath Borders
Your code worked!  Thanks!  The main difference between our snippets
was that you added the MPMoviePlayerController's view directly to the
UIViewController's view rather than putting it in a holder view (which
I doubt would matter) and that you aren't using the embedded controls.
 I'll post back when I figure out what went wrong.

-Heath Borders
heath.bord...@gmail.com
Twitter: heathborders
http://heath-tech.blogspot.com



On Mon, Mar 21, 2011 at 11:50 PM, Matt Neuburg m...@tidbits.com wrote:
 On Mon, 21 Mar 2011 22:59:04 -0500, Heath Borders heath.bord...@gmail.com 
 said:
That's exactly what I did.  I have a brand new project with just a
ViewController with 3 views

[SNIP ridiculous quantities of code]

 I can't read that. And it isn't what I suggested you do. I said make a 
 *minimal* project. Enough to prove to yourself that setting the contentURL 
 works. And no more than that! Here's my code; this is what I mean when I say 
 minimal and simple and stuff like that:

 - (void)viewDidLoad {
    [super viewDidLoad];
    MPMoviePlayerController *player = [[MPMoviePlayerController alloc] init];
    player.shouldAutoplay = NO;
    player.controlStyle = MPMovieControlStyleNone;
    [player.view setFrame: CGRectMake(0,0,200,150)];
    [self.view addSubview: player.view];
    self.thePlayer = player;
    [player release];

 }
 - (IBAction)play1:(id)sender { // button 1
    [self.thePlayer setContentURL: [[NSBundle mainBundle]
        URLForResource:@blend1 withExtension:@mp4]];
    [self.thePlayer play];
 }

 - (IBAction)play2:(id)sender { // button 2
    [self.thePlayer setContentURL: [[NSBundle mainBundle]
         URLForResource:@xbox withExtension:@mp4]];
    [self.thePlayer play];
 }

 That's all. It works. So then you build up from there towards what you 
 *really* want to do. When it stops working, that's when you broke it. m.


 --
 matt neuburg, phd = m...@tidbits.com, http://www.apeth.net/matt/
 A fool + a tool + an autorelease pool = cool!
 Programming iOS 4!
 http://www.apeth.net/matt/default.html#iosbook
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: MPMoviePlayerController setContentURL twice

2011-03-22 Thread Heath Borders
I was able to replicate my issue.  In my original code, I was only
allowing the movie to be played with the embedded controls.  When I
set the contentURL a second time, my embedded controls were not
showing, so I couldn't play the movie again.  As I mentioned
previously, Matt's code worked great.  However, I can replicate my
issue by removing line 4 below.

1 - (IBAction)play1:(id)sender { // button 1
2   [self.thePlayer setContentURL: [[NSBundle mainBundle]
3URLForResource:@blend1 withExtension:@mp4]];
4[self.thePlayer play];
5 }

I only want to control the movie from the embedded controls, so I
don't want to programmatically play it.  In the MPMediaPlayback
protocol, there is a prepareToPlay method, which must always be called
before the movie starts playing, and which is called if needed by
play.

So, replacing line 4 with

[self.thePlayer prepareToPlay];

makes my code work.

Thanks again for your help, Matt!

-Heath Borders
heath.bord...@gmail.com
Twitter: heathborders
http://heath-tech.blogspot.com



On Tue, Mar 22, 2011 at 8:30 AM, Heath Borders heath.bord...@gmail.com wrote:
 Your code worked!  Thanks!  The main difference between our snippets
 was that you added the MPMoviePlayerController's view directly to the
 UIViewController's view rather than putting it in a holder view (which
 I doubt would matter) and that you aren't using the embedded controls.
  I'll post back when I figure out what went wrong.

 -Heath Borders
 heath.bord...@gmail.com
 Twitter: heathborders
 http://heath-tech.blogspot.com



 On Mon, Mar 21, 2011 at 11:50 PM, Matt Neuburg m...@tidbits.com wrote:
 On Mon, 21 Mar 2011 22:59:04 -0500, Heath Borders heath.bord...@gmail.com 
 said:
That's exactly what I did.  I have a brand new project with just a
ViewController with 3 views

[SNIP ridiculous quantities of code]

 I can't read that. And it isn't what I suggested you do. I said make a 
 *minimal* project. Enough to prove to yourself that setting the contentURL 
 works. And no more than that! Here's my code; this is what I mean when I say 
 minimal and simple and stuff like that:

 - (void)viewDidLoad {
    [super viewDidLoad];
    MPMoviePlayerController *player = [[MPMoviePlayerController alloc] init];
    player.shouldAutoplay = NO;
    player.controlStyle = MPMovieControlStyleNone;
    [player.view setFrame: CGRectMake(0,0,200,150)];
    [self.view addSubview: player.view];
    self.thePlayer = player;
    [player release];

 }
 - (IBAction)play1:(id)sender { // button 1
    [self.thePlayer setContentURL: [[NSBundle mainBundle]
        URLForResource:@blend1 withExtension:@mp4]];
    [self.thePlayer play];
 }

 - (IBAction)play2:(id)sender { // button 2
    [self.thePlayer setContentURL: [[NSBundle mainBundle]
         URLForResource:@xbox withExtension:@mp4]];
    [self.thePlayer play];
 }

 That's all. It works. So then you build up from there towards what you 
 *really* want to do. When it stops working, that's when you broke it. m.


 --
 matt neuburg, phd = m...@tidbits.com, http://www.apeth.net/matt/
 A fool + a tool + an autorelease pool = cool!
 Programming iOS 4!
 http://www.apeth.net/matt/default.html#iosbook

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


MPMoviePlayerController setContentURL twice

2011-03-21 Thread Heath Borders
I create an embedded MPMoviePlayerController thusly inside my loadView method:

self.moviePlayerController = [[[MPMoviePlayerController alloc] init]
autorelease];

// add to view, setup moviePlayerController's view frame, etc

And I can later load a movie the user chooses thusly:

NSURL *fileUrl = ...
self.moviePlayerController.contentURL = fileUrl;

and everything works great.


However, if I set the contentURL again:

NSURL *fileUrl2 = ...
self.moviePlayerController.contentURL = fileUrl2;

This does not work, even if fileUrl2 == fileUrl1.

When I change the contentURL, I get the following playbackState and loadState:

After first setContentURL:
loadState == playable | playthroughOK
playbackState == playing

After my second setContentURL:
playbackState == stopped
loadState == unknown

I can of course create a new MPMoviePlayerController for every movie,
but I want to make sure this issue isn't indicative of a larger
problem.

Thanks!

-Heath Borders
heath.bord...@gmail.com
Twitter: heathborders
http://heath-tech.blogspot.com
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: MPMoviePlayerController setContentURL twice

2011-03-21 Thread Matt Neuburg
On Mon, 21 Mar 2011 16:04:52 -0500, Heath Borders heath.bord...@gmail.com 
said:
I create an embedded MPMoviePlayerController thusly inside my loadView method:

self.moviePlayerController = [[[MPMoviePlayerController alloc] init]
autorelease];

// add to view, setup moviePlayerController's view frame, etc

And I can later load a movie the user chooses thusly:

NSURL *fileUrl = ...
self.moviePlayerController.contentURL = fileUrl;

and everything works great.


However, if I set the contentURL again:

NSURL *fileUrl2 = ...
self.moviePlayerController.contentURL = fileUrl2;

This does not work, even if fileUrl2 == fileUrl1.

When I change the contentURL, I get the following playbackState and loadState:

After first setContentURL:
loadState == playable | playthroughOK
playbackState == playing

After my second setContentURL:
playbackState == stopped
loadState == unknown

I can of course create a new MPMoviePlayerController for every movie,
but I want to make sure this issue isn't indicative of a larger
problem.

You shouldn't have to create a new MPMoviePlayerController. Setting the 
contentURL to a different URL works fine. Something else must be going on at 
your end. As always, my advice is: make a new project, reduce this to the 
absolute simplest possible case (an MPMoviePlayerController, its view, two 
embedded movies, and two buttons) and convince yourself. m.

--
matt neuburg, phd = m...@tidbits.com, http://www.apeth.net/matt/
A fool + a tool + an autorelease pool = cool!
Programming iOS 4!
http://www.apeth.net/matt/default.html#iosbook___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: MPMoviePlayerController setContentURL twice

2011-03-21 Thread Heath Borders
That's exactly what I did.  I have a brand new project with just a
ViewController with 3 views: 1 to hold the MPMoviePlayerController's
view, 1 button for my first movie, and 1 button for my second movie.
When the buttons are clicked, I create NSURLs from the appropriate
files.  I've included my controller.  I just set it as the window's
rootViewController in my appDelegate.  Any comments you have are
greatly appreciated!

#import MediaPlayer/MediaPlayer.h
#import AVFoundation/AVFoundation.h
#import CoreMedia/CoreMedia.h
#import UIKit/UIKit.h


@interface MoviePlayerViewController : UIViewController {

}

@end

@interface MoviePlayerViewController()

@property (nonatomic, retain) UIView *moviePlayerHolderView;
@property (nonatomic, retain) MPMoviePlayerController *moviePlayerController;

- (void)loadBigVideoFromFile;
- (void)loadBigAudioFromFile;
- (void)loadAssetFromFileUrl: (NSURL *) fileUrl;

- (void)moviePlayerLoadStateDidChange;
- (void)moviePlayerPlaybackStateDidChange;

@end

@implementation MoviePlayerViewController

@synthesize moviePlayerHolderView = _moviePlayerHolderView;
@synthesize moviePlayerController = _moviePlayerController;

#pragma mark -
#pragma mark init/dealloc methods

- (id)init {
self = [super initWithNibName:nil bundle:nil];
if (self) {

}
return self;
}

- (void)dealloc {
self.moviePlayerHolderView = nil;
self.moviePlayerController = nil;

[[NSNotificationCenter defaultCenter] removeObserver:self];

[super dealloc];
}

#pragma mark -
#pragma mark UIViewController

- (void)loadView {
[super loadView];

self.moviePlayerHolderView = [[[UIView alloc]
initWithFrame:CGRectMake(CGRectGetMinX(self.view.bounds),

   
CGRectGetMinY(self.view.bounds),

   
CGRectGetWidth(self.view.bounds),

   
CGRectGetHeight(self.view.bounds) - 50)] autorelease];
self.moviePlayerHolderView.autoresizingMask =
UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

[self.view addSubview:self.moviePlayerHolderView];

self.moviePlayerController = [[[MPMoviePlayerController alloc] init]
autorelease];
[[NSNotificationCenter defaultCenter] addObserver:self

 selector:@selector(moviePlayerLoadStateDidChange)

 name:@MPMoviePlayerLoadStateDidChangeNotification

   object:self.moviePlayerController];
[[NSNotificationCenter defaultCenter] addObserver:self

 selector:@selector(moviePlayerPlaybackStateDidChange)

 name:@MPMoviePlayerPlaybackStateDidChangeNotification

   object:self.moviePlayerController];
self.moviePlayerController.controlStyle = MPMovieControlStyleEmbedded;
self.moviePlayerController.movieSourceType = MPMovieSourceTypeFile;
self.moviePlayerController.shouldAutoplay = NO;
self.moviePlayerController.view.autoresizingMask =
UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.moviePlayerController.view.frame = 
self.moviePlayerHolderView.bounds;

[self.moviePlayerHolderView addSubview:self.moviePlayerController.view];

UIButton *loadAudioButton = [UIButton 
buttonWithType:UIButtonTypeRoundedRect];
loadAudioButton.autoresizingMask =
UIViewAutoresizingFlexibleRightMargin |
UIViewAutoresizingFlexibleTopMargin;
loadAudioButton.frame = CGRectMake(CGRectGetMinX(self.view.bounds),
   
CGRectGetMaxY(self.moviePlayerHolderView.frame),
   
CGRectGetWidth(self.view.bounds) / 2,
   50);
[loadAudioButton addTarget:self

action:@selector(loadBigAudioFromFile)
  forControlEvents:UIControlEventTouchUpInside];
[loadAudioButton setTitle:@Load Audio

Re: MPMoviePlayerController setContentURL twice

2011-03-21 Thread Matt Neuburg
On Mon, 21 Mar 2011 22:59:04 -0500, Heath Borders heath.bord...@gmail.com 
said:
That's exactly what I did.  I have a brand new project with just a
ViewController with 3 views

[SNIP ridiculous quantities of code]

I can't read that. And it isn't what I suggested you do. I said make a 
*minimal* project. Enough to prove to yourself that setting the contentURL 
works. And no more than that! Here's my code; this is what I mean when I say 
minimal and simple and stuff like that:

- (void)viewDidLoad {
[super viewDidLoad];
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] init];
player.shouldAutoplay = NO;
player.controlStyle = MPMovieControlStyleNone;
[player.view setFrame: CGRectMake(0,0,200,150)];
[self.view addSubview: player.view];
self.thePlayer = player;
[player release];

}
- (IBAction)play1:(id)sender { // button 1
[self.thePlayer setContentURL: [[NSBundle mainBundle] 
URLForResource:@blend1 withExtension:@mp4]];
[self.thePlayer play];
}

- (IBAction)play2:(id)sender { // button 2
[self.thePlayer setContentURL: [[NSBundle mainBundle] 
 URLForResource:@xbox withExtension:@mp4]];
[self.thePlayer play];
}

That's all. It works. So then you build up from there towards what you *really* 
want to do. When it stops working, that's when you broke it. m.


--
matt neuburg, phd = m...@tidbits.com, http://www.apeth.net/matt/
A fool + a tool + an autorelease pool = cool!
Programming iOS 4!
http://www.apeth.net/matt/default.html#iosbook___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Catching errors with MPMoviePlayerController

2010-11-14 Thread Matt Neuburg
On Tue, 9 Nov 2010 08:12:54 +1100, Rogerio de Paula Assis rppas...@gmail.com 
said:
Hi guys,

Is there a way of catching exceptions (particularly for network errors
/ no connection available) when using a MPMoviePlayerController?

I think the movie will finish and you can examine for 
MPMovieFinishReasonPlaybackError. m.

--
matt neuburg, phd = m...@tidbits.com, http://www.apeth.net/matt/
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.apeth.net/matt/default.html#applescriptthings___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Catching errors with MPMoviePlayerController

2010-11-09 Thread Rogerio de Paula Assis
Hi guys,

Is there a way of catching exceptions (particularly for network errors
/ no connection available) when using a MPMoviePlayerController?

I have reviewed the available documentation and realise I can get a
notification for
moviePlayerLoadStateChanged:(NSNotification*)notification.

Problem is the loadState constants available don't cater for error handling:

MPMovieLoadStateUnknown
MPMovieLoadStatePlayable
MPMovieLoadStatePlaythroughOK
MPMovieLoadStateStalled (in case you are wondering this doesn't get
called during network errors for some reason?)

There's a deprecated MPMoviePlayerContentPreloadDidFinishNotification
that provides a userInfo dictionary with an error key but nothing
for iOS 3.2 and above.

Any help would be very much appreciated.
Cheers,
Rog
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Memory leak when using new MPMoviePlayerController notifications

2010-08-29 Thread Graham Cox

On 28/08/2010, at 11:11 PM, Michael Crawford wrote:

 My question is this: is my technique for releasing the only reference I have 
 to the movie controller, which is the notification object, valid?  NOTE: This 
 is the new 3.2 SDK movie player controller.
 
 - (BOOL)application:(UIApplication*)application 
 didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
 {
// start playback of intro movie and watch for notification of playback 
 completion
MPMoviePlayerController* moviePlayer = [[MPMoviePlayerController alloc] 
 initWithContentURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] 
 pathForResource:@intro_movie ofType:@mp4]]];


You are tying yourself in knots thinking about how the notification center 
might or might not be holding references to 'moviePlayer'. It's much simpler - 
you created it (alloc + init) therefore you own it. It is thus up to you to 
release it when you've finished with it.

Don't think in terms of incrementing and decrementing retain counts, just think 
about who owns what.

I wouldn't rely on NSNotificationCenter taking ownership of this object - in 
fact it's almost certain it does not (though it's an implementation detail 
you're not party to). The safest, sanest, conventional thing to do is to hold a 
reference to the player as an ivar and release it when it finishes. Why go to a 
lot of trouble to avoid doing that? Its cost is minute.

--Graham


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Memory leak when using new MPMoviePlayerController notifications

2010-08-28 Thread Michael Crawford
Instruments is saying I have a leak from playing my intro movie.  When I click 
on the stack trace it brings me to the second piece of code 
(-[moviePlaybackDidFinish:]),  which is called as a consequence of the 
notification handler setup in the first piece of code 
(-[application:didFinishLaunchingWithOptions:].

This code makes the following assumptions:

1. I don't have to keep a reference to the created controller because it will 
be returned to me in the notification handler.
2. The reference count for the MPMoviePlayerController is incremented when the 
notification object is allocated and initialized.
3. The notification object is auto-released after I return from handling the 
notification.
4. The notification object decrements the reference count of the 
MPMoviePlayerController when it is released.

My question is this: is my technique for releasing the only reference I have to 
the movie controller, which is the notification object, valid?  NOTE: This is 
the new 3.2 SDK movie player controller.

- (BOOL)application:(UIApplication*)application 
didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
// start playback of intro movie and watch for notification of playback 
completion
MPMoviePlayerController* moviePlayer = [[MPMoviePlayerController alloc] 
initWithContentURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] 
pathForResource:@intro_movie ofType:@mp4]]];
moviePlayer.controlStyle = MPMovieControlStyleNone;
moviePlayer.view.frame = window.bounds;
[window addSubview:moviePlayer.view];
[window makeKeyAndVisible];
[[NSNotificationCenter defaultCenter] addObserver:self 
selector:@selector(moviePlaybackDidFinish:) 
name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer];
[moviePlayer play];
return YES;
}

#pragma mark -
#pragma mark Movie Playback Notification Handler

- (void)moviePlaybackDidFinish:(NSNotification*)notification
{
// Playback has completed.  Release the player and the associated view-
// controller and continue with our default application view/controller 
pair.
[((MPMoviePlayerController*)notification.object).view removeFromSuperview];
[notification.object release];
[window addSubview:viewController.view];
}

-Michael
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


[Q] Is this a bug in MPMoviePlayerController? Then how to work around?

2010-07-13 Thread JongAm Park

 Hello, all.

My acquaintance told me that he found a strange problem while using 
MPMoviePlayerController.
According to him, from second play of a movie file located on a server, 
a server said that there was a cached movie clip on a client and guided 
to use the locally cached one, but on the client side, i.e. 
MPMoviePlayerController, it said that the server information was wrong 
and rejected it.


Is this a bug? How to work around it, then?

Thank you.

--

JongAm Park
Visit my technical blog at http://jongampark.wordpress.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


MPMoviePlayerController playhead position, setting markers to trigger events and notifications

2010-04-11 Thread Kevin Callahan
As a user scrubs forward and backward  through movie using 
MPMoviePlayerController, what's the most efficient way to know where the 
playhead is at? 
Is there a simple timeStamp one can grab?
Is there a way to set markers to trigger events and notifications?

Thanks,
Kevin
Accessorizer:   http://www.kevincallahan.org/software/accessorizer.html






___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: MPMoviePlayerController playhead position, setting markers to trigger events and notifications (MPMediaPlayback Protocol Reference)

2010-04-11 Thread Kevin Callahan

On Apr 11, 2010, at 8:18 PM, Kevin Callahan wrote:

 As a user scrubs forward and backward  through movie using 
 MPMoviePlayerController, what's the most efficient way to know where the 
 playhead is at? 
 Is there a simple timeStamp one can grab?
 Is there a way to set markers to trigger events and notifications?
 
 Thanks,
 Kevin
 Accessorizer: 
 http://www.kevincallahan.org/software/accessorizer.html

okay .. I found what I was looking for after sending the email, of course

MPMediaPlayback Protocol Reference

The current position of the playhead. (required)

@property(nonatomic) NSTimeInterval currentPlaybackTime

-K

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


iPhone MPMoviePlayerController stops iPod

2009-02-22 Thread Sebastian Morsch
I tried to implement a short modal and full-screen animation with  
MPMoviePlayerController within my application. It is only meant as a  
nice transition between two different working modes of the app.  
Understandably, playing a movie with MPMoviePlayerController pauses  
music playback of the iPod app, but this is not what I want. My  
application doesn't even use sound, so it feels totally weird for the  
user when his/her music just stops.


Does anyone have an idea how I can work around this?


Thanks!
Sebastian
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com