andreipitis / ASPVideoPlayer

A simple video player that allow animations to be performed on the view during playback.
MIT License
89 stars 43 forks source link

Async, retain cycles, tests, buffering and more #9

Closed iwasrobbed closed 6 years ago

iwasrobbed commented 7 years ago

Hey @andreipitis 👋

I've decided to use this video player in a production application and found some issues while digging through and testing it out. I did not change the external API very much (view the updated README for the minimal changes).

If you'd rather not have these changes, I'm fine with forking off as well; just let me know but figured I'd try and give back.

Todo:

Changes (based on commit msgs):

Caution:

codecov-io commented 7 years ago

Codecov Report

Merging #9 into master will decrease coverage by 7.88%. The diff coverage is 72.36%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master       #9      +/-   ##
==========================================
- Coverage   83.52%   75.63%   -7.89%     
==========================================
  Files          13       13              
  Lines         959     1252     +293     
==========================================
+ Hits          801      947     +146     
- Misses        158      305     +147
Impacted Files Coverage Δ
Example/ASPVideoPlayer/AppDelegate.swift 100% <ø> (ø) :arrow_up:
ASPVideoPlayer/Classes/Math.swift 100% <100%> (ø) :arrow_up:
...ExampleUITests/ASPVideoPlayer_ExampleUITests.swift 100% <100%> (ø) :arrow_up:
Example/ASPVideoPlayer/PlayerViewController.swift 100% <100%> (ø) :arrow_up:
ASPVideoPlayer/Classes/AnimationForwarder.swift 100% <100%> (ø) :arrow_up:
Example/ASPVideoPlayer/ViewController.swift 28.33% <29.31%> (-50%) :arrow_down:
ASPVideoPlayer/Classes/Loader.swift 43.18% <43.18%> (-48.82%) :arrow_down:
ASPVideoPlayer/Classes/Scrubber.swift 53.84% <53.84%> (-3.43%) :arrow_down:
ASPVideoPlayer/Classes/ASPVideoPlayerView.swift 77.43% <77.43%> (-15.9%) :arrow_down:
ASPVideoPlayer/Classes/ControlButtons.swift 79.45% <79.45%> (-1.37%) :arrow_down:
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 845262a...d329d44. Read the comment docs.

andreipitis commented 7 years ago

Hi @iwasrobbed 👋

I apologise for the late reply.

Wow! This is amazing work 🎉 . I might make some minor changes before I publish the next release but overall this looks awesome.

I have one question regarding the multiple observers on closures (dd1ee0965f9a2da2251b76d2c5c6e1307456a7fc). Do you have a specific use case where you need multiple observers or is this change only because you want to have an observer on the ASPVideoPlayer instance? Adding the closure functionality to ASPVideoPlayer sounds like a good idea but I'm not sure if it should support multiple observers.

Thank you very much for contributing to this project.

iwasrobbed commented 7 years ago

hey @andreipitis! regarding multiple observers, there are a few considerations:

andreipitis commented 7 years ago

Hey @iwasrobbed!

When I created this component, it only had the ASPVideoPlayerView. Then I thought I should include a simple player for someone who just wanted to play videos, but was not interested in getting callbacks, or just didn't want to create a custom UI. That’s why I didn’t include the closure functionality for the ASPVideoPlayer component, but I guess I should have expected someone would want both the UI and the closures 😄 .

I planned to include a delegate, or to forward the closures to the ASPVideoPlayer but I haven’t gotten around to it yet.

This is a good approach however it does have it’s set of issues:

I will probably change this once I merge the PR.

I also found a few issues related to some of your other changes:

I will try to find a fix for the remaining issues and if I manage I will merge your PR.

iwasrobbed commented 7 years ago

I agree, the closures design has its limitations. It was just a stop-gap until something else could be implemented since I needed to move quickly while trying to limit bugs or API changes.

Re: AVQueuePlayer: I'm not really using it as a queue, but the only advantage I saw over a regular player is that it avoids the white/black blip in between looping videos. My app displays only one video at a time and loops it, so this was an important consideration for me.

If you need any help on other bugs, feel free to assign to me. Otherwise, I'd be happy to test your changes and obviously feel free to change anything you'd like or cherry-pick anything from this PR if you'd rather not merge it all.