You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2012/04/10 00:40:30 UTC

[20/34] wp7 commit: Added "create" media action

Added "create" media action


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/commit/6f4beaa3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/tree/6f4beaa3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/diff/6f4beaa3

Branch: refs/heads/master
Commit: 6f4beaa36b0d21510f51afeee05b609fb461ceda
Parents: 7b02e32
Author: filmaj <ma...@gmail.com>
Authored: Sun Apr 8 19:22:03 2012 -0700
Committer: filmaj <ma...@gmail.com>
Committed: Sun Apr 8 19:22:03 2012 -0700

----------------------------------------------------------------------
 framework/Cordova/Commands/Media.cs |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/6f4beaa3/framework/Cordova/Commands/Media.cs
----------------------------------------------------------------------
diff --git a/framework/Cordova/Commands/Media.cs b/framework/Cordova/Commands/Media.cs
index 9f669b0..cae0b3f 100644
--- a/framework/Cordova/Commands/Media.cs
+++ b/framework/Cordova/Commands/Media.cs
@@ -187,6 +187,35 @@ namespace WP7CordovaClassLib.Cordova.Commands
             }
         }
 
+        // Called when you create a new Media('blah') object in JS.
+        public void create(string options)
+        {
+            try
+            {
+                MediaOptions mediaOptions;
+
+                try
+                {
+                    mediaOptions = JSON.JsonHelper.Deserialize<MediaOptions>(options);
+                }
+                catch (Exception)
+                {
+                    DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION, "Error parsing options into create method"));
+                    return;
+                }
+
+                AudioPlayer audio = new AudioPlayer(this, mediaOptions.Id);
+                Media.players.Add(mediaOptions.Id, audio);
+          
+                DispatchCommandResult(new PluginResult(PluginResult.Status.OK));
+                  
+            }
+            catch (Exception e)
+            {
+                DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, e.Message));
+            }
+        }
+
         /// <summary>
         /// Starts or resume playing audio file 
         /// </summary>