Skip to content

Added duration getter to AVPlayer#33

Open
vorg wants to merge 1 commit into
deanm:v3from
vorg:avplayer-duration
Open

Added duration getter to AVPlayer#33
vorg wants to merge 1 commit into
deanm:v3from
vorg:avplayer-duration

Conversation

@vorg

@vorg vorg commented Dec 13, 2014

Copy link
Copy Markdown
Contributor

Added duration getter for AVPlayer e.g.:

this.audio = new plask.AVPlayer();
this.audio.appendFile('test.mp3');
this.audio.play();
console.log(this.audio.duration());

@deanm

deanm commented Dec 14, 2014

Copy link
Copy Markdown
Owner

The thing about AVPlayer is that it is a playlist. So duration could mean the duration of the entire playlist, just the current item, etc. Maybe currentDuration, and there could also be a totalDuration?

@vorg

vorg commented Dec 14, 2014

Copy link
Copy Markdown
Contributor Author

Renaming it to currentDuration in order to match currentTime sounds good. Don't need totalDuration. More useful would be currentTract / totalNumTracks.

@deanm

deanm commented Dec 14, 2014

Copy link
Copy Markdown
Owner

It's possible that currentItem is nil, see currentLoadedTimeRanges to how to handle that, you should return NULL.

TextureAVPlayer* player = ExtractPlayerPointer(args.This());
AVPlayerItem* item = [player currentItem];
if (item == nil)
  return args.GetReturnValue().SetNull();

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

Successfully merging this pull request may close these issues.

2 participants