BrikerMan / BMPlayer

A video player for iOS, based on AVPlayer, support the horizontal, vertical screen. support adjust volume, brightness and seek by slide, support subtitles.
https://eliyar.biz
MIT License
1.97k stars 419 forks source link

Fullscreen option button doesn't works #141

Closed ArunDevOpsiOS closed 7 years ago

ArunDevOpsiOS commented 7 years ago

BMPlayer version

0.8.7

Installed with

Issue Description

I downloaded the example from Github that is working perfectly, But when I integrated it into my app the fullscreen option is not working anymore. I haven't done any code to change the orientation. My app is portrait only, but I want the video should be played horizontally as well.

What

When I click on the full-screen button, the button changes icon to that of full-screen but the video doesn't go into full-screen.

Reproduce

I've used this code in viewController

//
//  testViewController.swift
//  ninetofive
//
//  Created by Apple on 8/5/17.
//  Copyright © 2017 Relinns. All rights reserved.
//

import UIKit
import BMPlayer
import NVActivityIndicatorView

class testViewController: UIViewController {
var player: BMPlayer!
    override func viewDidLoad() {
        super.viewDidLoad()
        setupPlayerManager()
        preparePlayer()
        setupPlayerResource()
        // Do any additional setup after loading the view.
    }
    func setupPlayerManager(){
        BMPlayerConf.topBarShowInCase = .none
        BMPlayerConf.shouldAutoPlay = false

    }
    func preparePlayer() {

        player = BMPlayer()
        view.addSubview(player)
        player.snp.makeConstraints { (make) in
            make.top.equalTo(view.snp.top)
            make.left.equalTo(view.snp.left)
            make.right.equalTo(view.snp.right)
            make.height.equalTo(view.snp.width).multipliedBy(9.0/16.0)
        }
        player.delegate = self
        self.view.layoutIfNeeded()
    }
    @IBAction func change(_ sender: UIButton) {
        player.pause()
    }
    func setupPlayerResource() {
        let url = URL(string: "https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4")!
        let asset = BMPlayerResource(name: "Video Name Here",
                                     definitions: [BMPlayerResourceDefinition(url: url, definition: "")],
                                     cover: nil,
                                     subtitles: nil
        )
            player.panGesture.isEnabled = false
            player.setVideo(resource: asset)
            }
    @IBOutlet weak var v: UIView!

    deinit {
        player.prepareToDealloc()
        print("VideoPlayViewController Deinit")
    }

}// MARK:- BMPlayerDelegate example
extension testViewController: BMPlayerDelegate {
    // Call back when playing state changed, use to detect is playing or not
    func bmPlayer(player: BMPlayer, playerIsPlaying playing: Bool) {
        print("| BMPlayerDelegate | playerIsPlaying | playing - \(playing)")
    }

    // Call back when playing state changed, use to detect specefic state like buffering, bufferfinished
    func bmPlayer(player: BMPlayer, playerStateDidChange state: BMPlayerState) {
        print("| BMPlayerDelegate | playerStateDidChange | state - \(state)")
    }

    // Call back when play time change
    func bmPlayer(player: BMPlayer, playTimeDidChange currentTime: TimeInterval, totalTime: TimeInterval) {
        //        print("| BMPlayerDelegate | playTimeDidChange | \(currentTime) of \(totalTime)")
    }
    // Call back when the video loaded duration changed
    func bmPlayer(player: BMPlayer, loadedTimeDidChange loadedDuration: TimeInterval, totalDuration: TimeInterval) {
        //        print("| BMPlayerDelegate | loadedTimeDidChange | \(loadedDuration) of \(totalDuration)")
    }
}
BrikerMan commented 7 years ago

You should change the app plist to support Landscape mode. Or there is no other way to change video orient.