Cherry picking r9720 into releases/2.2
git-svn-id: https://google-web-toolkit.googlecode.com/svn/releases/2.2@9721 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/media/Media.gwt.xml b/user/src/com/google/gwt/media/Media.gwt.xml
index 4588b70..c40ce2d 100644
--- a/user/src/com/google/gwt/media/Media.gwt.xml
+++ b/user/src/com/google/gwt/media/Media.gwt.xml
@@ -16,5 +16,50 @@
<module>
<inherits name="com.google.gwt.user.User"/>
<inherits name="com.google.gwt.media.dom.DOM"/>
+
+ <!-- Define the support property for Video and Audio-->
+ <define-property name="videoElementSupport" values="maybe,no" />
+ <define-property name="audioElementSupport" values="maybe,no" />
+
+ <!-- Give default support value of no -->
+ <set-property name="videoElementSupport" value="no" />
+ <set-property name="audioElementSupport" value="no" />
+
+ <set-property name="videoElementSupport" value="maybe">
+ <any>
+ <when-property-is name="user.agent" value="safari" />
+ <when-property-is name="user.agent" value="gecko1_8" />
+ <when-property-is name="user.agent" value="opera" />
+ </any>
+ </set-property>
+
+ <set-property name="audioElementSupport" value="maybe">
+ <any>
+ <when-property-is name="user.agent" value="safari" />
+ <when-property-is name="user.agent" value="gecko1_8" />
+ <when-property-is name="user.agent" value="opera" />
+ </any>
+ </set-property>
+
+ <replace-with class="com.google.gwt.media.client.Video.VideoElementSupportDetectedMaybe">
+ <when-type-is class="com.google.gwt.media.client.Video.VideoElementSupportDetector" />
+ <when-property-is name="videoElementSupport" value="maybe" />
+ </replace-with>
+
+ <replace-with class="com.google.gwt.media.client.Video.VideoElementSupportDetectedNo">
+ <when-type-is class="com.google.gwt.media.client.Video.VideoElementSupportDetector" />
+ <when-property-is name="videoElementSupport" value="no" />
+ </replace-with>
+
+ <replace-with class="com.google.gwt.media.client.Audio.AudioElementSupportDetectedMaybe">
+ <when-type-is class="com.google.gwt.media.client.Audio.AudioElementSupportDetector" />
+ <when-property-is name="videoElementSupport" value="maybe" />
+ </replace-with>
+
+ <replace-with class="com.google.gwt.media.client.Audio.AudioElementSupportDetectedNo">
+ <when-type-is class="com.google.gwt.media.client.Audio.AudioElementSupportDetector" />
+ <when-property-is name="audioElementSupport" value="no" />
+ </replace-with>
+
<source path="client"/>
</module>
diff --git a/user/src/com/google/gwt/media/client/Audio.java b/user/src/com/google/gwt/media/client/Audio.java
index 210c90a..987dbb2 100644
--- a/user/src/com/google/gwt/media/client/Audio.java
+++ b/user/src/com/google/gwt/media/client/Audio.java
@@ -76,23 +76,14 @@
}
/**
- * Protected constructor. Use {@link #createIfSupported()} to create an Audio.
+ * Protected constructor. Use {@link #createIfSupported()} to create
+ * an Audio element.
*/
private Audio(AudioElement element) {
setElement(element);
}
/**
- * Creates an Audio widget with a given source URL.
- *
- * @param src a String URL
- */
- public Audio(String src) {
- setElement(Document.get().createAudioElement());
- getAudioElement().setSrc(src);
- }
-
- /**
* Returns the attached AudioElement.
*
* @return the AudioElement
@@ -112,7 +103,7 @@
* @return true if supported, false otherwise.
*/
static native boolean isSupportedRunTime(AudioElement element) /*-{
- return !!element.getContext;
+ return !!element.play;
}-*/;
/**
diff --git a/user/src/com/google/gwt/media/client/Video.java b/user/src/com/google/gwt/media/client/Video.java
index bd1eac7..92ed14e 100644
--- a/user/src/com/google/gwt/media/client/Video.java
+++ b/user/src/com/google/gwt/media/client/Video.java
@@ -81,13 +81,6 @@
}
/**
- * Creates a Video widget.
- */
- public Video() {
- setElement(Document.get().createVideoElement());
- }
-
- /**
* Creates a Video widget with a given source URL.
*
* @param src a String URL
@@ -117,7 +110,7 @@
* @return true if supported, false otherwise.
*/
static native boolean isSupportedRunTime(VideoElement element) /*-{
- return !!element.getContext;
+ return !!element.play;
}-*/;
/**
diff --git a/user/test/com/google/gwt/media/MediaSuite.java b/user/test/com/google/gwt/media/MediaSuite.java
index 3174327..388c736 100644
--- a/user/test/com/google/gwt/media/MediaSuite.java
+++ b/user/test/com/google/gwt/media/MediaSuite.java
@@ -27,10 +27,10 @@
public static Test suite() {
GWTTestSuite suite = new GWTTestSuite("Test suite for Media GWTTestCases");
- /*
+ /*
* Tests disabled temporarily
- * suite.addTestSuite(AudioTest.class);
- * suite.addTestSuite(VideoTest.class);
+ * suite.addTestSuite(AudioTest.class);
+ * suite.addTestSuite(VideoTest.class);
*/
return suite;
diff --git a/user/test/com/google/gwt/media/MediaTest.gwt.xml b/user/test/com/google/gwt/media/MediaTest.gwt.xml
index 11f6d65..1c6246dc 100644
--- a/user/test/com/google/gwt/media/MediaTest.gwt.xml
+++ b/user/test/com/google/gwt/media/MediaTest.gwt.xml
@@ -15,12 +15,11 @@
<module>
<!-- Inherit the JUnit support -->
<inherits name='com.google.gwt.junit.JUnit'/>
+
+ <inherits name="com.google.gwt.media.Media" />
<!-- Make media files available on the server by abusing the 'script' tag -->
<source path="client"/>
- <script src="jabberwocky.ogg"></script>
- <script src="jabberwocky.mp3"></script>
- <script src="testogg.ogv"></script>
- <script src="testh264.mp4"></script>
- <script src="poster.jpg"></script>
+
+ <public path="public-test" />
</module>
diff --git a/user/test/com/google/gwt/media/client/AudioTest.java b/user/test/com/google/gwt/media/client/AudioTest.java
index e491cd4..29b8b87 100644
--- a/user/test/com/google/gwt/media/client/AudioTest.java
+++ b/user/test/com/google/gwt/media/client/AudioTest.java
@@ -33,9 +33,9 @@
public class AudioTest extends MediaTest {
Audio audio;
- final static String audioUrlMp3 = "jabberwocky.mp3";
+ final static String audioUrlMp3 = "smallmp3.mp3";
final static String audioFormatMp3 = "audio/mpeg";
- final static String audioUrlOgg = "jabberwocky.ogg";
+ final static String audioUrlOgg = "smallogg.ogg";
final static String audioFormatOgg = "audio/ogg";
@Override
diff --git a/user/test/com/google/gwt/media/client/VideoTest.java b/user/test/com/google/gwt/media/client/VideoTest.java
index 069ef0f..05cecfe 100644
--- a/user/test/com/google/gwt/media/client/VideoTest.java
+++ b/user/test/com/google/gwt/media/client/VideoTest.java
@@ -35,13 +35,13 @@
Video video;
final static String posterUrl = "poster.jpg";
- final static String videoUrlH264 = "testh264.mp4";
+ final static String videoUrlH264 = "smallh264.mp4";
final static String videoFormatH264 = "video/mp4; codecs=\"avc1.42E01E, mp4a.40.2\"";
- final static String videoUrlOgg = "testogg.ogv";
- final static String videoFormatOgg = "video/ogg; codecs=\"theora, vorbis\"";
+ final static String videoUrlOgv = "smalltheora.ogv";
+ final static String videoFormatOgv = "video/ogg; codecs=\"theora, vorbis\"";
- final static int videoWidth = 480;
- final static int videoHeight = 270;
+ final static int videoWidth = 32;
+ final static int videoHeight = 18;
@Override
public MediaElement getElement() {
@@ -56,7 +56,7 @@
StringBuilder sb = new StringBuilder();
VideoElement e = video.getVideoElement();
- sb.append("AudioElement[");
+ sb.append("VideoElement[");
sb.append("currentSrc=");
sb.append(e.getCurrentSrc());
sb.append(",currentTime=");
@@ -163,9 +163,9 @@
if (!element.canPlayType(videoFormatH264).equalsIgnoreCase(
MediaElement.CANNOT_PLAY)) {
element.setSrc(videoUrlH264);
- } else if (!element.canPlayType(videoFormatOgg).equalsIgnoreCase(
+ } else if (!element.canPlayType(videoFormatOgv).equalsIgnoreCase(
MediaElement.CANNOT_PLAY)) {
- element.setSrc(videoUrlOgg);
+ element.setSrc(videoUrlOgv);
} else {
throw new Exception("Could not find suitable video format");
}
diff --git a/user/test/com/google/gwt/media/public/poster.jpg b/user/test/com/google/gwt/media/public-test/poster.jpg
similarity index 100%
rename from user/test/com/google/gwt/media/public/poster.jpg
rename to user/test/com/google/gwt/media/public-test/poster.jpg
Binary files differ
diff --git a/user/test/com/google/gwt/media/public-test/smallh264.mp4 b/user/test/com/google/gwt/media/public-test/smallh264.mp4
new file mode 100644
index 0000000..1ec0fea
--- /dev/null
+++ b/user/test/com/google/gwt/media/public-test/smallh264.mp4
Binary files differ
diff --git a/user/test/com/google/gwt/media/public/jabberwocky.mp3 b/user/test/com/google/gwt/media/public-test/smallmp3.mp3
similarity index 100%
rename from user/test/com/google/gwt/media/public/jabberwocky.mp3
rename to user/test/com/google/gwt/media/public-test/smallmp3.mp3
Binary files differ
diff --git a/user/test/com/google/gwt/media/public/jabberwocky.ogg b/user/test/com/google/gwt/media/public-test/smallogg.ogg
similarity index 100%
rename from user/test/com/google/gwt/media/public/jabberwocky.ogg
rename to user/test/com/google/gwt/media/public-test/smallogg.ogg
Binary files differ
diff --git a/user/test/com/google/gwt/media/public-test/smalltheora.ogv b/user/test/com/google/gwt/media/public-test/smalltheora.ogv
new file mode 100644
index 0000000..c0950be
--- /dev/null
+++ b/user/test/com/google/gwt/media/public-test/smalltheora.ogv
Binary files differ
diff --git a/user/test/com/google/gwt/media/public/testh264.mp4 b/user/test/com/google/gwt/media/public/testh264.mp4
deleted file mode 100644
index df28ab1..0000000
--- a/user/test/com/google/gwt/media/public/testh264.mp4
+++ /dev/null
Binary files differ
diff --git a/user/test/com/google/gwt/media/public/testogg.ogv b/user/test/com/google/gwt/media/public/testogg.ogv
deleted file mode 100644
index f428074..0000000
--- a/user/test/com/google/gwt/media/public/testogg.ogv
+++ /dev/null
Binary files differ