Skip to content

Commit

Permalink
Adding language call.
Browse files Browse the repository at this point in the history
  • Loading branch information
fabian authored and chregu committed May 31, 2010
1 parent 390fa9c commit 9e2c83d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions PhoneGapLib/Classes/AudioStream.h
Expand Up @@ -18,6 +18,7 @@

- (void)play:(NSArray*)arguments withDict:(NSDictionary*)options;
- (void)stop:(NSArray*)arguments withDict:(NSDictionary*)options;
- (void)lang:(NSArray*)arguments withDict:(NSDictionary*)options;
- (void)mute:(NSArray*)arguments withDict:(NSDictionary*)options;
- (void)unmute:(NSArray*)arguments withDict:(NSDictionary*)options;
- (void)metaDataUpdated:(NSString *)metaData;
Expand Down
20 changes: 20 additions & 0 deletions PhoneGapLib/Classes/AudioStream.m
Expand Up @@ -111,6 +111,26 @@ - (void)stop:(NSArray*)arguments withDict:(NSDictionary*)options
[streamer stop];
}

- (void)lang:(NSArray*)arguments withDict:(NSDictionary*)options
{
NSUInteger argc = [arguments count];
NSString* successCallback = nil;
if (argc > 0) successCallback = [arguments objectAtIndex:0];

if (argc < 1) {
NSLog(@"AudioStream.lang: Missing 1st parameter.");
return;
}

NSUserDefaults* defs = [NSUserDefaults standardUserDefaults];
NSArray* languages = [defs objectForKey:@"AppleLanguages"];
NSString* preferredLang = [languages objectAtIndex:0];

NSString* jsString = [[NSString alloc] initWithFormat:@"%@(\"%@\");", successCallback, preferredLang];
[webView stringByEvaluatingJavaScriptFromString:jsString];
[jsString release];
}

- (void)mute:(NSArray*)arguments withDict:(NSDictionary*)options
{
NSLog(@"mute");
Expand Down
3 changes: 3 additions & 0 deletions PhoneGapLib/javascripts/plugins/AudioStream.js
Expand Up @@ -25,6 +25,9 @@ AudioStream.prototype.play = function(url,metaCallBack) {
AudioStream.prototype.stop = function() {
PhoneGap.exec("AudioStream.stop");
};
AudioStream.prototype.lang = function(successCallback) {
PhoneGap.exec("AudioStream.lang", successCallback);
};
AudioStream.prototype.mute = function() {
PhoneGap.exec("AudioStream.mute");
};
Expand Down

0 comments on commit 9e2c83d

Please sign in to comment.