diff --git a/CDVVideo.js b/CDVVideo.js deleted file mode 100644 index 18e21ee..0000000 --- a/CDVVideo.js +++ /dev/null @@ -1,8 +0,0 @@ -var CDVVideo = { - play: function play(video, portrait, callback, errback) { - cordova.exec(callback, errback, 'CDVVideo', 'play', [video, portrait]); - }, - finished: function finished(video) { - console.log("finished playing video " + video); - } -} \ No newline at end of file diff --git a/README.md b/README.md index e65de0f..64c85b4 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,16 @@ # CDVVideo -CDVVideo is a Cordova 1.7+ plugin for iOS that allows playing video (local or remote) via a native video player. It is essentially a port of eiffelqiu's [phonegape-videoplayer-plugin](phonegap-videoplayer-plugin). +NOTE: I've edited this plugin to work with the way I was storing files on iOS. If you want to go back to how it was, just compare the CVVideo.m files from this fork and bubblefoundry's [https://github.com/bubblefoundry/CDVVideo](CDVVideo Cordova +1.7). + +## Description +CDVVideo is a Cordova/Phonegap 3.0+ plugin for iOS that allows playing video (local or remote) via a native video player. + +## History +This is a port of eiffelqiu's [https://github.com/eiffelqiu/phonegap-videoplayer-plugin](phonegap-videoplayer-plugin) done by bubblefoundry [https://github.com/bubblefoundry/CDVVideo](CDVVideo Cordova +1.7) which was then edited by wootwoot1234 to work with the Cordova/Phonegap 3.0+ command line interface. ## Installation -1. Drop the `.h` and `.m` files into the Cordova `Plugins` folder. Use the default options. -2. Add an entry to the `Plugins` dictionary in `Cordova.plist`. The key should be `CDVVideo` and the value must be `CDVVideo`. -3. Add the `CDVVideo.js` file somewhere under your `www` directory and include it in your `index.html` file. -4. Play a video by calling `CDVVideo.play(video, portrait)`, where `video` is the URL or filename you wish to play and `portrait` is a string that is either `YES` or `NO`, indicating whether portrait or landscape orientation should be used. -5. _Optional:_ Change or overwrite `CDVVideo.finished(video)` to handle when a video finishes playing. `video` corresponds to the video that you passed to `CDVVideo.play()`. \ No newline at end of file +1. Using Phonegap CLI, in terminal navigate to your projects root directory. +2. run `phonegap local plugin add https://github.com/wootwoot1234/CDVVideo.git` +3. Play a video by calling `window.plugins.CDVVideo.play(video, portrait)`, where `video` is the URL or filename you wish to play and `portrait` is a string that is either `YES` or `NO`, indicating whether portrait or landscape orientation should be used. +4. _Optional:_ Change or overwrite `window.plugins.CDVVideo.finished(video)` to handle when a video finishes playing. `video` corresponds to the video that you passed to `window.plugins.CDVVideo.play()`. \ No newline at end of file diff --git a/plugin.xml b/plugin.xml new file mode 100644 index 0000000..74aff57 --- /dev/null +++ b/plugin.xml @@ -0,0 +1,36 @@ + + + + CDVVideo + This plugin allows you to play videos. + MIT + cordova,video,videos,movies + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CDVVideo.h b/src/ios/CDVVideo.h old mode 100644 new mode 100755 similarity index 72% rename from CDVVideo.h rename to src/ios/CDVVideo.h index c16baea..761ae02 --- a/CDVVideo.h +++ b/src/ios/CDVVideo.h @@ -2,6 +2,7 @@ // CDVVideo.h // // +// Updated by Tom Krones 2013-09-30. // Created by Peter Robinett on 2012-10-15. // // @@ -14,6 +15,6 @@ NSString *movie; } -- (void)play:(NSMutableArray *)arguments withDict:(NSMutableDictionary *)options; +- (void) play:(CDVInvokedUrlCommand*)command; @end \ No newline at end of file diff --git a/CDVVideo.m b/src/ios/CDVVideo.m old mode 100644 new mode 100755 similarity index 83% rename from CDVVideo.m rename to src/ios/CDVVideo.m index 7d57868..062eebb --- a/CDVVideo.m +++ b/src/ios/CDVVideo.m @@ -2,6 +2,7 @@ // CDVVideo.m // // +// Updated by Tom Krones 2013-09-30. // Created by Peter Robinett on 2012-10-15. // // @@ -13,10 +14,10 @@ #import @implementation CDVVideo - -- (void)play:(NSMutableArray *)arguments withDict:(NSMutableDictionary *)options { - movie = [arguments objectAtIndex:1]; - NSString *orient = [arguments objectAtIndex:2]; +- (void) play:(CDVInvokedUrlCommand*)command +{ + movie = [command.arguments objectAtIndex:0]; + NSString *orient = [command.arguments objectAtIndex:1]; NSRange range = [movie rangeOfString:@"http"]; if(range.length > 0) { if ([@"YES" isEqualToString:orient]) { @@ -47,14 +48,14 @@ - (void)MovieDidFinish:(NSNotification *)notification { [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:nil]; - [self writeJavascript:[NSString stringWithFormat:@"CDVVideo.finished(\"%@\");", movie]]; + [self writeJavascript:[NSString stringWithFormat:@"window.plugins.CDVVideo.finished(\"%@\");", movie]]; } - (void)dealloc { - [player release]; - [movie release]; - [super dealloc]; + //[player release]; + //[movie release]; + //[super dealloc]; } @end diff --git a/MovieViewController.h b/src/ios/MovieViewController.h old mode 100644 new mode 100755 similarity index 92% rename from MovieViewController.h rename to src/ios/MovieViewController.h index bc5fa5e..cd4921b --- a/MovieViewController.h +++ b/src/ios/MovieViewController.h @@ -2,6 +2,7 @@ // MovieViewController.h // // +// Updated by Tom Krones 2013-09-30. // Created by Peter Robinett on 2012-10-15. // // Based on phonegap-videoplayer-plugin by eiffel on 2011-11-09 diff --git a/MovieViewController.m b/src/ios/MovieViewController.m old mode 100644 new mode 100755 similarity index 86% rename from MovieViewController.m rename to src/ios/MovieViewController.m index 438dadb..39e4fa9 --- a/MovieViewController.m +++ b/src/ios/MovieViewController.m @@ -2,6 +2,7 @@ // MovieViewController.m // // +// Updated by Tom Krones 2013-09-30. // Created by Peter Robinett on 2012-10-15. // // Based on phonegap-videoplayer-plugin by eiffel on 2011-11-09 @@ -14,7 +15,7 @@ @implementation MovieViewController - (id)initWithContentURL:(NSURL *)url andOrientation:(BOOL)orientation { - MovieViewController *o = [[[[self class] alloc] initWithContentURL:url] autorelease]; + MovieViewController *o = [[[self class] alloc] initWithContentURL:url]; o.orientation = orientation; return o; } diff --git a/www/CDVVideo.js b/www/CDVVideo.js new file mode 100755 index 0000000..7e73508 --- /dev/null +++ b/www/CDVVideo.js @@ -0,0 +1,16 @@ +var exec = require("cordova/exec"); + +function CDVVideo() +{ + this.available = false; +} + +CDVVideo.prototype.play = function(video, portrait, callback, errback) +{ + exec(callback, errback, 'CDVVideo', 'play', [video, portrait]); +}; +CDVVideo.prototype.finished = function(video) +{ + console.log("finished playing video " + video); +}; +module.exports = new CDVVideo(); \ No newline at end of file