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

Player isn't working unless in fullscreen mode + events questions #129

Closed
ThiagoMiranda opened this issue Mar 14, 2016 · 4 comments
Closed

Comments

@ThiagoMiranda
Copy link

@sahin

Hi..
I'm trying to implement the mobileios and I've been running in some issues.
When I try to put the player in a "subview" it doesn't receive any user input ( I just can't pause/play or do any of the actions ).
Here's my code:

        let videoURL = NSURL(string: url)!
        let player = MobilePlayerViewController(contentURL: videoURL,
            config: MobilePlayerConfig(fileURL: NSBundle.mainBundle().URLForResource("PlayerSkin", withExtension: "json")!))

        player.title = media.title
        player.activityItems = [videoURL]
        player.view.frame = CGRect(x: 30, y: 25, width: 640, height: 360)

        container.addSubview(player.view) //container is a UIView inside my main controller

captura de tela 2016-03-14 as 15 12 44

Another question: how can I listen to the player events? Like "onPlay", "onPause", "onProgress" and so on?

Thanks

@sahin
Copy link
Owner

sahin commented Mar 17, 2016

@ThiagoMiranda super thank you, very detailed.

I will forward the error to our main engineer @isair , he will check it asap.

@isair
Copy link
Contributor

isair commented Mar 17, 2016

Are you adding the view controller as a child view controller?

@ThiagoMiranda
Copy link
Author

Thanks for the reply. @sahin and @isair

For the first question for some reason when I did a refactor on my code ( initializing all of the project again ) and it worked. We don't seem to have the answer why this happened yet but it's working so be it =p
For the second one I'm using:

        notificationCenter.addObserverForName(
            MPMoviePlayerPlaybackStateDidChangeNotification,
            object: player.moviePlayer,
            queue: NSOperationQueue.mainQueue()) { notification in
                switch player.state {
                case .Playing:
                    eventType = "play"
                case .Paused:
                    eventType = "pause"
                case .Buffering:
                    eventType = "buffer"
                default:
                    break
                }
        }

Can I make two quick questions?
1- Do you have a "fullscreen" button? If it does, how can I show it? Or at least how can I trigger a fullscreen event? I've tried

    player.moviePlayer.setFullscreen(true, animated: false)

but it shows a black screen and pauses the video.

2- We wanna put a play and pause button right on the middle of the screen like this:
captura de tela 2016-03-17 as 17 19 52
Do you guys have a "nice way" to do that or would be necessary to edit the framework itself?

@isair
Copy link
Contributor

isair commented Apr 1, 2016

Glad it's working! As for your questions

  1. Sadly, we don't have a fullscreen button at the moment. If you replace our player view controller with a standard MPMoviePlayerViewController and you're not having this black screen issue, then it's certainly a bug and a separate issue for it should be created.

  2. You can create an overlay with a play/pause button in it, then add it as a pre-roll and pause overlay.

@isair isair closed this as completed Apr 1, 2016
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

3 participants