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

Wrong pre-loaded time for youtube audio 140 #99

Open
starlight173 opened this issue Dec 2, 2015 · 9 comments
Open

Wrong pre-loaded time for youtube audio 140 #99

starlight173 opened this issue Dec 2, 2015 · 9 comments

Comments

@saiday
Copy link
Member

saiday commented Dec 3, 2015

Where did you get pre-loaded time? from delegate method?
- (void)hysteriaPlayerCurrentItemPreloaded:(CMTime)time;

More detail required

@starlight173
Copy link
Author

Yes, that delegate.
Media format:
Download Audio Format: m4a
Audio: Stereo, 44.1 KHz 128 Kbps
Audio Format: AAC [DASH audio]

Playing audio code:
self.hysteriaPlayer.removeAllItems()
self.items.removeAll()
self.items.append(audioURL)
self.hysteriaPlayer.fetchAndPlayPlayerItem(0)

@starlight173
Copy link
Author

I found that hysteriaPlayerCurrentItemPreloaded get called 2 times when using the youtube link decoded. While with another service, only 1 time. That causes the problem.

@han9over
Copy link

han9over commented Mar 3, 2016

I believe this problem is with how AVPlayer works. If you try to paste the URL in your safari and run also you will get same calculation.

If you are playing a youtube audio, I would suggest to listen for playing time and when its half of the total time, move to next song programatically.

@starlight173
Copy link
Author

@han9over : yes, so far I had to make a timer to compare and decide when should the video stopped. But think it's a litte bit hacking.

@patrickjquinn
Copy link

patrickjquinn commented Mar 28, 2017

@han9over Just tested this and i'm getting the same output, incorrect duration being reported by the player, opening the link in Chrome reports the correct duration where as the player doubles it, mp4 issue doubling the of the content size means incorrect reporting of player time.

@patrickjquinn
Copy link

Also @gloryluu if you could share your calculation logic to compare it against my own solution to skip to the next track for efficiency it would be greatly appreciated 👍

@patrickjquinn
Copy link

In HysteriaPlayer.m on line 652 if you change return duration to return (duration / 2) that seems to be the neatest way to propagate the change in the most minimal fashion across the player.

@patrickjquinn
Copy link

You will also need a timer running a scheduled update to check which checks if the progress is duration - 0.5 in order to stop the audio and call the delegate you use to inform the UI as much.

Note that this timer should be run every 0.4 seconds and preferably on a GCD thread (In order to ensure you can catch the progress at dur - 0.5

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

4 participants