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

TIMOB-15675-expose property time #5121

Merged
merged 3 commits into from
Jan 17, 2014
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import android.app.Activity;

@Kroll.proxy(creatableInModule=MediaModule.class, propertyAccessors={
TiC.PROPERTY_VOLUME, TiC.PROPERTY_TIME
TiC.PROPERTY_VOLUME
})
public class AudioPlayerProxy extends KrollProxy
implements OnLifecycleEvent, OnWindowFocusChangedEvent
Expand Down Expand Up @@ -160,6 +160,28 @@ public void stop() {
s.stop();
}
}

@Kroll.method @Kroll.getProperty
public double getTime() {
TiSound s = getSound();
if (s != null) {
int time = s.getTime();
setProperty(TiC.PROPERTY_TIME, time);
}
return TiConvert.toDouble(getProperty(TiC.PROPERTY_TIME));
}

@Kroll.method @Kroll.setProperty
public void setTime(Object pos) {
if (pos != null) {
TiSound s = getSound();
if (s != null) {
s.setTime(TiConvert.toInt(pos));
} else {
setProperty(TiC.PROPERTY_TIME, TiConvert.toDouble(pos));
}
}
}

protected TiSound getSound()
{
Expand Down
6 changes: 6 additions & 0 deletions apidoc/Titanium/Media/AudioPlayer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -324,3 +324,9 @@ properties:
summary: Size of the buffer used for streaming, in bytes.
type: Number
platforms: [iphone, ipad]
- name: time
summary: Current playback position of the audio.
description: |
Time is reported in milliseconds.
type: Number
platforms: [android]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this property since 3.3.0?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I will update the doc