Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
440 views
in Technique[技术] by (71.8m points)

iphone - Overlay on top of Streaming MPMoviePlayerController

I went through the example from apple "MoviePlayer on iPhone"

Im trying to overlay on top of the mpmovieplayercontroller,

it works perfectly with video clip that is in bundle,

but it wont work if i stream the video from the url.

the overlay view will just get hide behind the player.

is there a way to bring the overlay view up to front?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

MPMoviePlayerController creates its own window and sets that as the key window - you probably know this already from the MoviePlayer sample app.

I don't know why, but there's a delay when the player uses a stream - so the keyWindow you get right after you initialize the player is likely not the player's window, since that seems to get added later.

You can "cheat" and use a timer to get the player window a few seconds later, and add your overlay:

[NSTimer scheduledTimerWithTimeInterval:5 target:self selector:@selector(addMyOverlay:) userInfo:nil repeats:FALSE]

Or you can listen for the UIWindowDidBecomeKeyNotification event, and do the same:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyWindowChanged:) name:UIWindowDidBecomeKeyNotification object:nil];

Neither option is great (I'd love to know a cleaner way to do this), but it gets the job done.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...