Giter Club home page Giter Club logo

playerview's People

Contributors

bluemix avatar davidlondono avatar milesegan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

playerview's Issues

sometimes, currentTime delegate is not called

Hello,
the delegate

playerVideo(player: PlayerView, currentTime: Double)

sometimes not called unless i explicitly I pause and play the video, which causes the time label to not be updated.

I hope it can be fixed.

After using PlayerView Podfile, there appear downcast problem

Before I installed PlayerView, I have only one Podfile "AWSS3" ,Podfile looks like that:

And it has "no error",

After install PlaerView , Podfile looks like that:

Here comes many Downcast problems.
And remove PlayerView, It comes normally again.
How can I build succeed with PlayerView?

Migrating to Swift3

I would love to keep using this library in my project, but I want to migrate to Swift3. Are there any plans?

ScreenShot Func Question

I take a screenshot from my video.
If the video is Portrait,after screenshot, my image show Landscape,
If the video is Landscape , and the image is the same with Video.

Could you please teach me how to fix it?

Wring Direction Pic
Correct Direction Pic

PS.
I use the function to fix my img from screenshot.
But it does not work.
Thank you!

extension UIImage {

  func fixOrientation() -> UIImage {
    if (self.imageOrientation == .Up) {
      return self
    }

    var transform = CGAffineTransformIdentity

    switch (self.imageOrientation) {
    case .Down, .DownMirrored:
      transform = CGAffineTransformTranslate(transform, self.size.width, self.size.height)
      transform = CGAffineTransformRotate(transform, CGFloat(M_PI))

    case .Left, .LeftMirrored:
      transform = CGAffineTransformTranslate(transform, self.size.width, 0)
      transform = CGAffineTransformRotate(transform, CGFloat(M_PI_2))

    case .Right, .RightMirrored:
      transform = CGAffineTransformTranslate(transform, 0, self.size.height)
      transform = CGAffineTransformRotate(transform, CGFloat(-M_PI_2))

    default:
      break
    }

    switch (self.imageOrientation) {
    case .UpMirrored, .DownMirrored:
      transform = CGAffineTransformTranslate(transform, self.size.width, 0)
      transform = CGAffineTransformScale(transform, -1, 1)

    case .LeftMirrored, .RightMirrored:
      transform = CGAffineTransformTranslate(transform, self.size.height, 0)
      transform = CGAffineTransformScale(transform, -1, 1)

    default:
      break
    }

    let ctx = CGBitmapContextCreate(nil, Int(self.size.width), Int(self.size.height),
      CGImageGetBitsPerComponent(self.CGImage), 0,
      CGImageGetColorSpace(self.CGImage),
      CGImageGetBitmapInfo(self.CGImage).rawValue)
    CGContextConcatCTM(ctx, transform)

    switch (self.imageOrientation) {
    case .Left, .LeftMirrored, .Right, .RightMirrored:
      CGContextDrawImage(ctx, CGRectMake(0,0,self.size.height,self.size.width), self.CGImage)

    default:
      CGContextDrawImage(ctx, CGRectMake(0,0,self.size.width,self.size.height), self.CGImage)
    }

    // And now we just create a new UIImage from the drawing context
    let cgimg = CGBitmapContextCreateImage(ctx)
    return UIImage(CGImage: cgimg!)
  }
}

let fixedImage = image.fixOrientation()

Need for isPlaying property to check is video is playing or not.

Hello, I think the PlayerView control should include a property like isPlaying using which one can check if the video is being played and it is not explicitly paused or stopped. Using rate property works with small remote videos (and local videos). But rate changes to 0 during buffering which is problematic to use because I am using rate 1 as playing and rate 0 as paused/stopped.

Video has no audio

Playing a video with audio after recording works fine but when the app exits then re open again, when playing the same video it has no audio anymore.

Crash in setter of currentTime property: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[AVPlayerItem seekToTime:toleranceBefore:toleranceAfter:completionHandler:] Seeking is not possible to time {INVALID}'

Hi there,

firstly thanks for the library, it works really well.
I got one issue though with a crash pretty frequently happening in the setter of the currentTime property in line 143:
player!.seekToTime(newTime,toleranceBefore: CMTime.zero,toleranceAfter: CMTime.zero)

It crashes due to the reason of newTime being invalid.
I added a workaround which works fine for me. I just do a safety check on newTime before calling seekToTime on the player:
if !CMTIME_IS_INVALID(newTime) { player!.seekToTime(newTime,toleranceBefore: CMTime.zero,toleranceAfter: CMTime.zero) }`

Could you add the code to the library or do you see problems with it? Or would you like me to create a pull request for it?

Thanks in advance

Pod Update with Swift 3

Hi,

Looks like swift-3 support in on master. Why not update the podspect to get it on cocoapods?

Thanks,
H.

Carthage PlayerView Problem

I use Carthage to download PlayerView,and install well.

But there seems have some thing wrong in "setUrl" method.


import UIKit
import PlayerView
import AVFoundation


class ViewController: UIViewController {

    var currentTimes:String?

    @IBOutlet var slider: UISlider!

    @IBOutlet var rateLabel: UILabel!

    @IBOutlet var progressBar: UIProgressView!

    @IBOutlet var playerVideo: PlayerView!


    @IBOutlet var playButton: UIButton!


    @IBAction func sliderChange(sender: UISlider) {

        playerVideo.currentTime = Double(sender.value)
    }


    @IBAction func sliderBegin(sender: AnyObject) {
        print("beginEdit")
        isEditingSlider = true

    }

    @IBAction func sliderEnd(sender: AnyObject) {
        print("endEdit")
        isEditingSlider = false
    }


    @IBAction func backwardTouch(sender: AnyObject) {

        playerVideo.rate = playerVideo.rate - 0.5

    }

    @IBAction func playTouch(sender: AnyObject) {
        if playerVideo.rate == 0 {
            playerVideo.play()
        } else {
            playerVideo.pause()
        }
    }

    @IBAction func fowardTouch(sender: AnyObject) {
        playerVideo.rate = playerVideo.rate + 0.5

    }

    func changeFill(sender: AnyObject) {
        switch playerVideo.fillMode {
        case .Some(.ResizeAspect):
            playerVideo.fillMode = .ResizeAspectFill
        case .Some(.ResizeAspectFill):
            playerVideo.fillMode = .Resize
        case .Some(.Resize):
            playerVideo.fillMode = .ResizeAspect
        default:
            break
        }
    }

    var duration: Float!
    var isEditingSlider = false
    let tap = UITapGestureRecognizer()

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        playerVideo.delegate = self
        let url = NSURL(string: "http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_30mb.mp4")!


       **#  // it say playerView has no member setUrl**
        playerVideo.setUrl(url)


        tap.numberOfTapsRequired = 2
        tap.addTarget(self, action: "changeFill:")
        view.addGestureRecognizer(tap)

    }

    override func loadView() {
        super.loadView()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}
extension ViewController: PlayerViewDelegate {

    func playerVideo(player: PlayerView, statusPlayer: PlayerViewStatus, error: NSError?) {
        print(statusPlayer)
    }

    func playerVideo(player: PlayerView, statusItemPlayer: PlayerViewItemStatus, error: NSError?) {

    }
    func playerVideo(player: PlayerView, loadedTimeRanges: [PlayerviewTimeRange]) {

        let dur2 = Float(loadedTimeRanges.first!.end.seconds)
        let progress = dur2 / duration
        progressBar?.progress = progress

        if loadedTimeRanges.count > 1 {
            print(loadedTimeRanges.count)
        }
        //print("progress",progress)
    }
    func playerVideo(player: PlayerView, duration: Double) {
        //print(duration.seconds)
        self.duration = Float(duration)
        slider?.maximumValue = Float(duration)
    }

    func playerVideo(player: PlayerView, currentTime: Double) {
        if !isEditingSlider {
            slider.value = Float(currentTime)
        }
        print("curentTime",currentTime)
        self.currentTimes = String(currentTime)
    }

    func playerVideo(player: PlayerView, rate: Float) {
        rateLabel.text = "x\(rate)"


        let buttonImageName = rate == 0.0 ? "PlayButton" : "PauseButton"

        let buttonImage = UIImage(named: buttonImageName)

        playButton.setImage(buttonImage, forState: .Normal)

        //        slider.value = Float(currentTime)
        //        print(currentTime.seconds)
    }
}

Not receiving callback from: func playerVideo(player: PlayerView, currentTime: Double)

Hey, loving the video player view so far however I seem to have an issue getting callback from func playerVideo(player: PlayerView, currentTime: Double). I have the delegate set and func playerVideo(player: PlayerView, duration: Double) works fine for getting the duration. Tried setting a different interval too using videoPlayerView.interval = CMTimeMake(1, 1). Any ideas what I might be doing wrong here?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.