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-7046] Ti.Media.VideoPlayer video times must be in milliseconds, not seconds #1147

Merged
merged 2 commits into from
Jan 13, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 19 additions & 11 deletions mobileweb/src/Ti/Media/VideoPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,15 @@ define("Ti/Media/VideoPlayer", ["Ti/_/declare", "Ti/Media", "Ti/UI/View"], funct

properties: {
autoplay: false,
repeatMode: Media.VIDEO_REPEAT_MODE_NONE,
currentPlaybackTime: {
get: function() {
return this._video ? this._video.currentTime * 1000 : 0;
},
set: function(value) {
this._video && (this._video.currentTime = (value / 1000) | 0);
return value;
}
},
fullscreen: {
// TODO: Add check for Firefox <http://www.thecssninja.com/javascript/fullscreen>
value: (function(s) {
Expand Down Expand Up @@ -63,6 +71,14 @@ define("Ti/Media/VideoPlayer", ["Ti/_/declare", "Ti/Media", "Ti/UI/View"], funct
return value;
}
},
mediaControlStyle: {
value: Media.VIDEO_CONTROL_DEFAULT,
set: function(value) {
this._video && (this._video.controls = value === Media.VIDEO_CONTROL_DEFAULT);
return value;
}
},
repeatMode: Media.VIDEO_REPEAT_MODE_NONE,
scalingMode: {
set: function(value) {
var n = this.domNode,
Expand All @@ -83,21 +99,13 @@ define("Ti/Media/VideoPlayer", ["Ti/_/declare", "Ti/Media", "Ti/UI/View"], funct
this._createVideo();
return value;
}
},
mediaControlStyle: {
value: Media.VIDEO_CONTROL_DEFAULT,
set: function(value) {
this._video.controls = value === Media.VIDEO_CONTROL_DEFAULT;
return value;
}
}
},

constants: {
playbackState: Media.VIDEO_PLAYBACK_STATE_STOPPED,
playing: false,
initialPlaybackTime: 0,
currentPlaybackTime: 0,
endPlaybackTime: 0,
playableDuration: 0,
loadState: Media.VIDEO_LOAD_STATE_UNKNOWN,
Expand Down Expand Up @@ -135,7 +143,7 @@ define("Ti/Media/VideoPlayer", ["Ti/_/declare", "Ti/Media", "Ti/UI/View"], funct
},

_durationChange: function() {
var d = this.duration,
var d = this._video.duration * 1000,
c = this.constants;
if (d !== Infinity) {
this.duration || this.fireEvent("durationAvailable", {
Expand Down Expand Up @@ -202,7 +210,7 @@ define("Ti/Media/VideoPlayer", ["Ti/_/declare", "Ti/Media", "Ti/UI/View"], funct
on(video, "loadedmetadata", this, "_metaDataLoaded"),
on(video, "durationchange", this, "_durationChange"),
on(video, "timeupdate", this, function() {
this.constants.currentPlaybackTime = Math.round(this.currentTime);
this.constants.currentPlaybackTime = this._video.currentTime * 1000;
this._currentState === STOPPING && this.pause();
}),
on(video, "error", this, function() {
Expand Down