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/01/13 05:10:52 UTC
[2/2] git commit: Audio playback issue CB-142
Audio playback issue CB-142
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/e1bc2c72
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/tree/e1bc2c72
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/diff/e1bc2c72
Branch: refs/heads/master
Commit: e1bc2c725ab9960914bbddd8dbc75c65f6ca5147
Parents: 32edf51
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Thu Jan 12 20:06:19 2012 -0800
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Thu Jan 12 20:06:19 2012 -0800
----------------------------------------------------------------------
example/www/audio.html | 22 +----------------
example/www/capture.html | 22 +----------------
framework/PhoneGap/Commands/AudioPlayer.cs | 29 ++++++++++++++-------
framework/PhoneGap/Commands/Notification.cs | 2 -
4 files changed, 21 insertions(+), 54 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/e1bc2c72/example/www/audio.html
----------------------------------------------------------------------
diff --git a/example/www/audio.html b/example/www/audio.html
index a5c851b..449331b 100644
--- a/example/www/audio.html
+++ b/example/www/audio.html
@@ -1,4 +1,4 @@
-<!DOCTYPE HTML>
+<!DOCTYPE html>
<html>
<head>
<!-- meta name="viewport" content="width=device-width, height=device-height, user-scalable=yes, initial-scale=2.0, maximum-scale=4.0, minimum-scale=1.0" / -->
@@ -7,26 +7,11 @@
<title>PhoneGap</title>
<link rel="stylesheet" href="master.css" type="text/css" media="screen">
- <script type="text/javascript">
- // provide our own console if it does not exist, huge dev aid!
- if (typeof window.console == "undefined") {
- window.console = { log: function (str) { window.external.Notify(str); } };
- }
-
- // output any errors to console log, created above.
- window.onerror = function (e) {
- console.log("window.onerror ::" + JSON.stringify(e));
- };
-
- console.log("Installed console ! ");
- </script>
-
<script type="text/javascript" charset="utf-8" src="phonegap-1.3.0.js"></script>
<script type="text/javascript" charset="utf-8">
- var deviceReady = false;
//-------------------------------------------------------------------------
// Audio player
@@ -235,11 +220,6 @@
deviceReady = true;
console.log("Device="+device.platform+" "+device.version);
}, false);
- window.setTimeout(function() {
- if (!deviceReady) {
- alert("Error: PhoneGap did not initialize. Demo will not run correctly.");
- }
- },1000);
}
</script>
http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/e1bc2c72/example/www/capture.html
----------------------------------------------------------------------
diff --git a/example/www/capture.html b/example/www/capture.html
index 462dd72..e3aa3d5 100644
--- a/example/www/capture.html
+++ b/example/www/capture.html
@@ -1,4 +1,4 @@
-<!DOCTYPE HTML>
+<!DOCTYPE html>
<html>
<head>
<!-- meta name="viewport" content="width=device-width, height=device-height, user-scalable=yes, initial-scale=2.0, maximum-scale=4.0, minimum-scale=1.0" / -->
@@ -6,27 +6,13 @@
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> <!-- ISO-8859-1 -->
<title>PhoneGap</title>
<link rel="stylesheet" href="master.css" type="text/css" media="screen"/>
-
- <script type="text/javascript">
- // provide our own console if it does not exist, huge dev aid!
- if (typeof window.console == "undefined") {
- window.console = { log: function (str) { window.external.Notify(str); } };
- }
-
- // output any errors to console log, created above.
- window.onerror = function (e) {
- console.log("window.onerror ::" + JSON.stringify(e));
- };
- console.log("Installed console ! ");
- </script>
<script type="text/javascript" charset="utf-8" src="phonegap-1.3.0.js"></script>
<script type="text/javascript" charset="utf-8">
- var deviceReady = false;
// last captured media file
var mediaFile = null;
@@ -151,14 +137,8 @@
*/
function init() {
document.addEventListener("deviceready", function () {
- deviceReady = true;
console.log("Device=" + device.platform + " " + device.version);
}, false);
- window.setTimeout(function () {
- if (!deviceReady) {
- alert("Error: PhoneGap did not initialize. Demo will not run correctly.");
- }
- }, 1000);
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/e1bc2c72/framework/PhoneGap/Commands/AudioPlayer.cs
----------------------------------------------------------------------
diff --git a/framework/PhoneGap/Commands/AudioPlayer.cs b/framework/PhoneGap/Commands/AudioPlayer.cs
index ffa4c4f..e8796be 100644
--- a/framework/PhoneGap/Commands/AudioPlayer.cs
+++ b/framework/PhoneGap/Commands/AudioPlayer.cs
@@ -21,6 +21,7 @@ using System.Windows.Threading;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Media;
+using Microsoft.Phone.Controls;
namespace WP7GapClassLib.PhoneGap.Commands
{
@@ -229,21 +230,29 @@ namespace WP7GapClassLib.PhoneGap.Commands
{
if (this.player == null)
{
-
- if (!Application.Current.Resources.Contains("PhoneGapMediaPlayer"))
+ // this.player is a MediaElement, it must be added to the visual tree in order to play
+ PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame;
+ if (frame != null)
{
- throw new Exception("PhoneGapMediaPlayer wasn't found in application resources");
+ PhoneApplicationPage page = frame.Content as PhoneApplicationPage;
+ if (page != null)
+ {
+ Grid grid = page.FindName("LayoutRoot") as Grid;
+ if (grid != null)
+ {
+ this.player = new MediaElement();
+ grid.Children.Add(this.player);
+ this.player.Visibility = Visibility.Collapsed;
+ this.player.MediaOpened += MediaOpened;
+ this.player.MediaEnded += MediaEnded;
+ this.player.MediaFailed += MediaFailed;
+ }
+ }
}
- this.player = Application.Current.Resources["PhoneGapMediaPlayer"] as MediaElement;
-
- this.player.MediaOpened += MediaOpened;
- this.player.MediaEnded += MediaEnded;
- this.player.MediaFailed += MediaFailed;
-
}
this.audioFile = filePath;
- this.player.AutoPlay = false;
+
Uri uri = new Uri(filePath, UriKind.RelativeOrAbsolute);
if (uri.IsAbsoluteUri)
{
http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/e1bc2c72/framework/PhoneGap/Commands/Notification.cs
----------------------------------------------------------------------
diff --git a/framework/PhoneGap/Commands/Notification.cs b/framework/PhoneGap/Commands/Notification.cs
index f6bcfd6..4bf5a42 100644
--- a/framework/PhoneGap/Commands/Notification.cs
+++ b/framework/PhoneGap/Commands/Notification.cs
@@ -125,8 +125,6 @@ namespace WP7GapClassLib.PhoneGap.Commands
var t1 = Application.Current.RootVisual;
PhoneApplicationFrame frame = t1 as PhoneApplicationFrame;
- var temp1 = frame.FindName("LayoutRoot");
-
if (frame != null)
{
PhoneApplicationPage page = frame.Content as PhoneApplicationPage;