Skip to content

Commit

Permalink
Merge pull request #4034 from BlainHamon/timob-12651
Browse files Browse the repository at this point in the history
TIMOB-12651 Addressing issues that slipped past first pull requests.
  • Loading branch information
vishalduggal committed Mar 29, 2013
2 parents 2e126c1 + 56826a8 commit a13502d
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ private Object eventToHashMap(SensorEvent event, long timestamp)
}

KrollDict data = new KrollDict();
data.putCodeAndMessage(TiC.ERROR_CODE_NO_ERROR, null);
data.put(TiC.PROPERTY_HEADING, heading);
return data;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,9 @@ public void stop()

public void onCompletion(MediaPlayer mp)
{
proxy.fireEvent(EVENT_COMPLETE, null);
KrollDict data = new KrollDict();
data.putCodeAndMessage(TiC.ERROR_CODE_NO_ERROR, null);
proxy.fireEvent(EVENT_COMPLETE, data);
stop();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,11 @@ public void fireComplete(int reason)
{
KrollDict args = new KrollDict();
args.put(TiC.EVENT_PROPERTY_REASON, reason);
if (reason == MediaModule.VIDEO_FINISH_REASON_PLAYBACK_ERROR) {
args.putCodeAndMessage(-1,"Video Playback encountered an error");
} else {
args.putCodeAndMessage(0,null);
}
fireEvent(TiC.EVENT_COMPLETE, args);
}

Expand Down
44 changes: 44 additions & 0 deletions apidoc/Titanium/Media/VideoPlayer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,29 @@ events:
[VIDEO_FINISH_REASON_USER_EXITED](Titanium.Media.VIDEO_FINISH_REASON_USER_EXITED).
type: Number

- name: success
summary: |
Indicates if the video was played successfully. User exit counts as a success.
Returns `true` if `reason` is not
[VIDEO_FINISH_REASON_PLAYBACK_ERROR](Titanium.Media.VIDEO_FINISH_REASON_PLAYBACK_ERROR),
`false` otherwise.
type: Boolean
platforms: [iphone, ipad, android]

- name: error
summary: Error message, if any returned. Will be undefined if `success` is `true`.
type: String
platforms: [iphone, ipad, android]

- name: code
summary: |
Error code.
Error code will be 0 if `success` is `true`, nonzero otherwise. If the error
was generated by the operating system, that system's error value is used.
Otherwise, this value will be -1.
type: Number
platforms: [iphone, ipad, android]

- name: durationAvailable
deprecated:
since: "3.0.0"
Expand Down Expand Up @@ -299,8 +322,29 @@ events:
- name: message
summary: Reason for error as a string.
type: String
deprecated:
since: "3.1.0"

- name: success
summary: Indicates a successful operation. Returns `false`.
type: Boolean
platforms: [android]

- name: error
summary: Error message, if any returned. May be undefined.
type: String
platforms: [android]

- name: code
summary: |
Error code.
If the error was generated by the operating system, that system's error value
is used. Otherwise, this value will be -1.
type: Number
platforms: [android]
platforms: [android, mobileweb]


- name: fullscreen
summary: Fired when a movie changes to or from fullscreen view.
description: |
Expand Down
24 changes: 21 additions & 3 deletions iphone/Classes/TiMediaVideoPlayerProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -838,13 +838,31 @@ - (void) handlePlayerNotification: (NSNotification *) notification
{
if ([self _hasListeners:@"complete"])
{
NSMutableDictionary *event = [NSMutableDictionary dictionary];
NSNumber *reason = [[notification userInfo] objectForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey];

NSString * errorMessage;
int errorCode;
if ([reason intValue] == MPMovieFinishReasonPlaybackError)
{
errorMessage = @"Video Playback encountered an error";
errorCode = -1;
}
else
{
errorMessage = nil;
errorCode = 0;
}

NSMutableDictionary *event;
if (reason!=nil)
{
[event setObject:reason forKey:@"reason"];
event = [NSDictionary dictionaryWithObject:reason forKey:@"reason"];
}
else
{
event = nil;
}
[self fireEvent:@"complete" withObject:event];
[self fireEvent:@"complete" withObject:event errorCode:errorCode message:errorMessage];
}
playing = NO;
}
Expand Down

0 comments on commit a13502d

Please sign in to comment.