Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 08-16-2009, 09:10 PM   #1 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 157
Default JavaScript in WebView?

Hi everyone. I need to stream videos... Using Brightcove.

They use a media player that provides javascript code to playing videos that use their player on the iPhone. The code is in javascript. Here's a link with it:

iPhone Video Portal Sample Application | Brightcove Developer

I figure I should be able to use a UIWebView to run the script... somehow.

Any ideas? Help would be amazing... Thanks in advance!
__________________
Check out our Apps!
Boxen4Oxen
VisCenter

Film Budget

Everwell TV

Last edited by starwarsdevwookie59; 09-10-2009 at 11:31 PM.
starwarsdevwookie59 is offline   Reply With Quote
Old 08-18-2009, 08:02 AM   #2 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 157
Default

In other words, how do I run javascript within an iPhone app.
__________________
Check out our Apps!
Boxen4Oxen
VisCenter

Film Budget

Everwell TV
starwarsdevwookie59 is offline   Reply With Quote
Old 08-18-2009, 01:22 PM   #3 (permalink)
Registered Member
 
Join Date: Apr 2009
Location: michigan
Posts: 185
Default

Quote:
Originally Posted by starwarsdevwookie59 View Post
In other words, how do I run javascript within an iPhone app.

Put the javascript in the app bundle and point your nsurl request at the appbundle.

you could use a loadHtml to load your uiwebview.

Thats how the shared browser here works.

Sharing Flow
michelle is offline   Reply With Quote
Old 08-20-2009, 07:23 PM   #4 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 157
Default

Thanks so much for your reply!

I was able to get the index.html to load in the webview and use the sources. here's the code I ended up using:

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"];
NSData *htmlData = [NSData dataWithContentsOfFile:filePath];
if (htmlData) {
NSBundle *bundle = [NSBundle mainBundle]; NSString *path = [bundle bundlePath]; NSString *fullPath = [NSBundle pathForResource:@"index" ofType:@"html" inDirectoryath];
[web loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:fullPath]]]; }


I got it to load in the webview, just one problem... IT DOESNT RESPOND TO ANYTHING. It loads great with all the images and such, just when i click/touch something, it doesn't do anything.

Any help is appreciated. thanks.
__________________
Check out our Apps!
Boxen4Oxen
VisCenter

Film Budget

Everwell TV

Last edited by starwarsdevwookie59; 08-30-2009 at 03:55 PM.
starwarsdevwookie59 is offline   Reply With Quote
Old 08-30-2009, 03:55 PM   #5 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 157
Default

https://devforums.apple.com/message/32282#32282

IT WORKS!!! YAYEE!
__________________
Check out our Apps!
Boxen4Oxen
VisCenter

Film Budget

Everwell TV

Last edited by starwarsdevwookie59; 08-30-2009 at 07:47 PM.
starwarsdevwookie59 is offline   Reply With Quote
Old 08-31-2009, 02:15 PM   #6 (permalink)
Registered Member
 
Join Date: Apr 2009
Location: michigan
Posts: 185
Default

Quote:
Originally Posted by starwarsdevwookie59 View Post
Thanks so much for your reply!

I was able to get the index.html to load in the webview and use the sources. here's the code I ended up using:

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"];
NSData *htmlData = [NSData dataWithContentsOfFile:filePath];
if (htmlData) {
NSBundle *bundle = [NSBundle mainBundle]; NSString *path = [bundle bundlePath]; NSString *fullPath = [NSBundle pathForResource:@"index" ofType:@"html" inDirectoryath];
[web loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:fullPath]]]; }


I got it to load in the webview, just one problem... IT DOESNT RESPOND TO ANYTHING. It loads great with all the images and such, just when i click/touch something, it doesn't do anything.

Any help is appreciated. thanks.

I feel particularly generous today, here's my code that works.. I think you are missing the base uril for one thing.

NSString *filePathString = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"];
NSMutableString *html = [[NSMutableString alloc] initWithContentsOfFile: filePathString];
[html replaceOccurrencesOfString: @"urlvar" withString:urlString
options: NSLiteralSearch range: NSMakeRange(0, [html length])];
// NSLog(html);
NSURL *aURL = [NSURL fileURLWithPath:filePathString];
[webView loadHTMLString:html baseURL:aURL];
michelle is offline   Reply With Quote
Old 11-20-2010, 05:34 PM   #7 (permalink)
aqm
Registered Member
 
Join Date: Nov 2010
Posts: 1
Default

Quote:
Originally Posted by starwarsdevwookie59 View Post
Could u please post the solution here, cause without an access to the devforum I cant read it. And I find it necessary to get my webapp working on the simulator as an native app (I tried it the same as u did) before I pay to use the Developerprogram.

Thx in advance.

aqm.
aqm is offline   Reply With Quote
Reply

Bookmarks

Tags
java, javascript, uiwebview, view, web

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 250
23 members and 227 guests
ADY, Alsahir, beleg_1998, Dani77, diyora, FAED, fredidf, iDifferent, iph_s, JamesCahall, JasonR, mer10, prchn4christ, Rudy, smithdale87, Speed, spiderguy84, stekki, tgjorgoski, timle8n1, Touchmint, twerner, vigu360
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,880
Threads: 89,228
Posts: 380,755
Top Poster: BrianSlick (7,129)
Welcome to our newest member, @sandris
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:11 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0