Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MPMoviePlaybackState always Paused #8

Closed
rocxteady opened this issue Apr 2, 2014 · 11 comments
Closed

MPMoviePlaybackState always Paused #8

rocxteady opened this issue Apr 2, 2014 · 11 comments

Comments

@rocxteady
Copy link

Hello. I am trying to get mediaplayer situations when it is paused or stoped. But I can't receive correct notification.

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(stateDidChange:) name:IJKMoviePlayerPlaybackStateDidChangeNotification object:self.player];

But the state is always "MPMoviePlaybackStatePaused".

Please help.

@bbcallen
Copy link
Contributor

bbcallen commented Apr 3, 2014

Which player did you use, IJKMPMoviePlayerController or IJKFFMoviePlayerController?
For IJKMPMoviePlayerController, did you set shouldAutoplay=YES?
Or could you paste corresponding code here?

@rocxteady
Copy link
Author

I am using IJKFFMoviePlayerController. I did not set shouldAutoPlayer=YES. Now I did but same result.

Here is my code:

inViewDidLoad:

self.player = [[IJKFFMoviePlayerController alloc] initWithContentURL:theMovieURL withOptions:nil];
[self.player setShouldAutoplay:YES];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(stateDidChange:) name:IJKMoviePlayerPlaybackStateDidChangeNotification object:self.player];

self.player.view.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
self.player.view.frame = self.view.bounds;

self.view.autoresizesSubviews = YES;
[self.view addSubview:self.player.view];
[self.view sendSubviewToBack:self.player.view];

[self.player prepareToPlay];
[self.player play];

notification method:
IJKFFMoviePlayerController *moviePlayer = notification.object;
if (moviePlayer.playbackState == MPMoviePlaybackStatePlaying){
//here playbackState always paused
[_loadingIndicatorView stopAnimating];
}

On 03 Apr 2014, at 07:58, bbcallen notifications@github.com wrote:

Which player did you use, IJKMPMoviePlayerController or IJKFFMoviePlayerController?
For IJKMPMoviePlayerController, did you set shouldAutoplay=YES?
Or could you paste corresponding code here?


Reply to this email directly or view it on GitHub.

@bbcallen
Copy link
Contributor

bbcallen commented Apr 3, 2014

Fixed: 17c7ade

Now, "prepared" state is treated as "playing"

@rocxteady
Copy link
Author

Thank you for that. And How do I know player is buffering at any time?

On 03 Apr 2014, at 10:27, bbcallen notifications@github.com wrote:

Fixed: 17c7ade

Now, state is treated as


Reply to this email directly or view it on GitHub.

@bbcallen
Copy link
Contributor

bbcallen commented Apr 3, 2014

see: d948865

- (void)loadStateDidChange:(NSNotification*)notification
{
//    MPMovieLoadStateUnknown        = 0,
//    MPMovieLoadStatePlayable       = 1 << 0,
//    MPMovieLoadStatePlaythroughOK  = 1 << 1, // Playback will be automatically started in this state when shouldAutoplay is YES
//    MPMovieLoadStateStalled        = 1 << 2, // Playback will be automatically paused in this state, if started

    MPMovieLoadState loadState = _player.loadState;

    if ((loadState & MPMovieLoadStatePlaythroughOK) != 0) {
        // [self changeBufferingStatus:NO]; hide buffering progress
    } else if ((loadState & MPMovieLoadStateStalled) != 0) {
        // [self changeBufferingStatus:YES]; show buffering progress
    }

    NSLog(@"loadStateDidChange %d", (int)(long)_player.loadState);
}

@rocxteady
Copy link
Author

Is this update for IJKMPMoviePlayerController?

I need for IJKFFMoviePlayerController. My player does not get triggered while buffering. :(

On 03 Apr 2014, at 11:19, bbcallen notifications@github.com wrote:

see: d948865

  • (void)loadStateDidChange:(NSNotification*)notification
    {
    // MPMovieLoadStateUnknown = 0,
    // MPMovieLoadStatePlayable = 1 << 0,
    // MPMovieLoadStatePlaythroughOK = 1 << 1, // Playback will be automatically started in this state when shouldAutoplay is YES
    // MPMovieLoadStateStalled = 1 << 2, // Playback will be automatically paused in this state, if started

    MPMovieLoadState loadState = _player.loadState;

    if ((loadState & MPMovieLoadStatePlaythroughOK) != 0) {
    // [self changeBufferingStatus:NO]; hide buffering progress
    } else if ((loadState & MPMovieLoadStateStalled) != 0) {
    // [self changeBufferingStatus:YES]; show buffering progress
    }

    NSLog(@"loadStateDidChange %d", (int)(long)_player.loadState);
    }

    Reply to this email directly or view it on GitHub.

@bbcallen
Copy link
Contributor

bbcallen commented Apr 3, 2014

Both IJKMPMoviePlayerController and IJKFFMoviePlayerController are OK in latest IJKMediaDemo on master.
Can you receive other notification?

Add some sleep() around av_read_frame() to demonstrate slow network.
Or add some breakpoint in IJKFFMoviePlayerController postEvent.

@rocxteady
Copy link
Author

While player is playing url, I change stream from my server but in the app I can’t get buffer notification for new stream, my new stream plays automatically. I can’t know when it started to play.

avmsg->what cvalues always “502 or 503 or 504” when I change the stream. Like it never changed.

On 03 Apr 2014, at 15:03, bbcallen notifications@github.com wrote:

Both IJKMPMoviePlayerController and IJKFFMoviePlayerController are OK in latest IJKMediaDemo on master.
Can you receive other notification?

Add some sleep() around av_read_frame() to demonstrate slow network.
Or add some breakpoint in IJKFFMoviePlayerController postEvent.


Reply to this email directly or view it on GitHub.

@bbcallen
Copy link
Contributor

bbcallen commented Apr 8, 2014

If you mean FFP_MSG_BUFFERING_START(END) messages, stalled buffering only happens when there is not enough data to decode at all.

“502, 503, 504” is designed to indicate pre-fetching progress displayed on UI, such as second progress in slider, no only for stalled buffering, but also for normal pre-fetching.

You should make the streaming slowly enough to reproduce FFP_MSG_BUFFERING_START(END) messages

@bbcallen
Copy link
Contributor

Can this issue be closed?

@rocxteady
Copy link
Author

Yes, thank you.

@smartTop smartTop mentioned this issue May 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants