From ccc41383044f192353d035dd9b94d2b62b0e52ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Str=C3=B8mme?= Date: Wed, 12 Jun 2013 17:49:08 +0200 Subject: [PATCH 1/2] Fix for url bug in the qmlvideo examples. In the FileBrowser paths where being prepended with file:///, since all the paths already starts with a forward slash, navigating away from the initial directory was therefore not possible. To make the examples work on Android, QT += multimedia was added. Change-Id: Iff96729d476c4292999b022bdd6d5770b6b011e7 Reviewed-by: Paul Olav Tvete Reviewed-by: Andy Nichols --- examples/multimedia/video/qmlvideo/main.cpp | 4 ++-- .../multimedia/video/qmlvideo/qml/qmlvideo/FileBrowser.qml | 2 +- examples/multimedia/video/qmlvideo/qmlvideo.pro | 2 +- examples/multimedia/video/qmlvideofx/main.cpp | 6 +++--- .../video/qmlvideofx/qml/qmlvideofx/FileBrowser.qml | 2 +- examples/multimedia/video/qmlvideofx/qmlvideofx.pro | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/examples/multimedia/video/qmlvideo/main.cpp b/examples/multimedia/video/qmlvideo/main.cpp index e44476a1..81c38d24 100644 --- a/examples/multimedia/video/qmlvideo/main.cpp +++ b/examples/multimedia/video/qmlvideo/main.cpp @@ -132,10 +132,10 @@ int main(int argc, char *argv[]) QUrl videoPath; const QStringList moviesLocation = QStandardPaths::standardLocations(QStandardPaths::MoviesLocation); if (moviesLocation.isEmpty()) { - QUrl appPath(QString("file:///%1").arg(app.applicationDirPath())); + QUrl appPath(QString("file://%1").arg(app.applicationDirPath())); videoPath = appPath.resolved(QUrl("./")); } else - videoPath = QString("file:///%1").arg(moviesLocation.first()); + videoPath = QString("file://%1").arg(moviesLocation.first()); viewer.rootContext()->setContextProperty("videoPath", videoPath); QMetaObject::invokeMethod(rootObject, "init"); diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/FileBrowser.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/FileBrowser.qml index 04f1092f..18b7b0e0 100644 --- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/FileBrowser.qml +++ b/examples/multimedia/video/qmlvideo/qml/qmlvideo/FileBrowser.qml @@ -101,7 +101,7 @@ Rectangle { Rectangle { id: wrapper function launch() { - var path = "file:///" + filePath; + var path = "file://" + filePath; if (folders.isFolder(index)) down(path); else diff --git a/examples/multimedia/video/qmlvideo/qmlvideo.pro b/examples/multimedia/video/qmlvideo/qmlvideo.pro index 3ea513d3..26865c59 100644 --- a/examples/multimedia/video/qmlvideo/qmlvideo.pro +++ b/examples/multimedia/video/qmlvideo/qmlvideo.pro @@ -1,7 +1,7 @@ TEMPLATE = app TARGET = qmlvideo -QT += quick +QT += quick multimedia LOCAL_SOURCES = main.cpp LOCAL_HEADERS = trace.h diff --git a/examples/multimedia/video/qmlvideofx/main.cpp b/examples/multimedia/video/qmlvideofx/main.cpp index ab613daa..b0698e23 100644 --- a/examples/multimedia/video/qmlvideofx/main.cpp +++ b/examples/multimedia/video/qmlvideofx/main.cpp @@ -116,13 +116,13 @@ int main(int argc, char *argv[]) FileReader fileReader; viewer.rootContext()->setContextProperty("fileReader", &fileReader); - QUrl appPath(QString("file:///%1").arg(app.applicationDirPath())); + QUrl appPath(QString("file://%1").arg(app.applicationDirPath())); QUrl imagePath; const QStringList picturesLocation = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation); if (picturesLocation.isEmpty()) imagePath = appPath.resolved(QUrl("images")); else - imagePath = QString("file:///%1").arg(picturesLocation.first()); + imagePath = QString("file://%1").arg(picturesLocation.first()); viewer.rootContext()->setContextProperty("imagePath", imagePath); QUrl videoPath; @@ -130,7 +130,7 @@ int main(int argc, char *argv[]) if (moviesLocation.isEmpty()) videoPath = appPath.resolved(QUrl("./")); else - videoPath = QString("file:///%1").arg(moviesLocation.first()); + videoPath = QString("file://%1").arg(moviesLocation.first()); viewer.rootContext()->setContextProperty("videoPath", videoPath); viewer.setTitle("qmlvideofx"); diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/FileBrowser.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/FileBrowser.qml index c089f6b1..3d4343c2 100644 --- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/FileBrowser.qml +++ b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/FileBrowser.qml @@ -102,7 +102,7 @@ Rectangle { Rectangle { id: wrapper function launch() { - var path = "file:///" + filePath + var path = "file://" + filePath if (folders.isFolder(index)) down(path); else diff --git a/examples/multimedia/video/qmlvideofx/qmlvideofx.pro b/examples/multimedia/video/qmlvideofx/qmlvideofx.pro index d62ade86..56344490 100644 --- a/examples/multimedia/video/qmlvideofx/qmlvideofx.pro +++ b/examples/multimedia/video/qmlvideofx/qmlvideofx.pro @@ -1,7 +1,7 @@ TEMPLATE = app TARGET = qmlvideofx -QT += quick +QT += quick multimedia SOURCES += filereader.cpp main.cpp HEADERS += filereader.h trace.h From 16a775d47a69913ce4f0306531c97469066ea896 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Str=C3=B8mme?= Date: Thu, 13 Jun 2013 15:42:12 +0200 Subject: [PATCH 2/2] Android: Fix for uncaught java exception. If an exception's getMessage() function returns a null object, we can't send it directly to the Log function, as it will throw an exception... To avoid this we can prepend the string from getMessage() with an empty string. Change-Id: Ie026cbf9af133352919a4536c152b6d35cb8c0a7 Reviewed-by: Paul Olav Tvete Reviewed-by: Yoann Lopes --- .../multimedia/QtAndroidMediaPlayer.java | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/plugins/android/jar/src/org/qtproject/qt5/android/multimedia/QtAndroidMediaPlayer.java b/src/plugins/android/jar/src/org/qtproject/qt5/android/multimedia/QtAndroidMediaPlayer.java index b2115b7d..e4dbae63 100644 --- a/src/plugins/android/jar/src/org/qtproject/qt5/android/multimedia/QtAndroidMediaPlayer.java +++ b/src/plugins/android/jar/src/org/qtproject/qt5/android/multimedia/QtAndroidMediaPlayer.java @@ -82,7 +82,7 @@ public class QtAndroidMediaPlayer extends MediaPlayer try { mApplicationContext = activity.getApplicationContext(); } catch(final Exception e) { - Log.d(TAG, e.getMessage()); + Log.d(TAG, "" + e.getMessage()); } } @@ -101,7 +101,7 @@ public class QtAndroidMediaPlayer extends MediaPlayer currentPosition = getCurrentPosition(); } } catch (final InterruptedException e) { - Log.d(TAG, e.getMessage()); + Log.d(TAG, "" + e.getMessage()); return; } } @@ -262,7 +262,7 @@ public class QtAndroidMediaPlayer extends MediaPlayer progressThread.start(); } catch (final IllegalStateException e) { reset(); - Log.d(TAG, e.getMessage()); + Log.d(TAG, "" + e.getMessage()); } } @@ -276,7 +276,7 @@ public class QtAndroidMediaPlayer extends MediaPlayer super.pause(); } catch (final IllegalStateException e) { reset(); - Log.d(TAG, e.getMessage()); + Log.d(TAG, "" + e.getMessage()); } } @@ -289,7 +289,7 @@ public class QtAndroidMediaPlayer extends MediaPlayer try { super.stop(); } catch (final IllegalStateException e) { - Log.d(TAG, e.getMessage()); + Log.d(TAG, "" + e.getMessage()); } finally { reset(); } @@ -305,7 +305,7 @@ public class QtAndroidMediaPlayer extends MediaPlayer super.seekTo(msec); onMediaPlayerInfoNative(MEDIA_PLAYER_PROGRESS, msec, mID); } catch (final IllegalStateException e) { - Log.d(TAG, e.getMessage()); + Log.d(TAG, "" + e.getMessage()); } } @@ -320,7 +320,7 @@ public class QtAndroidMediaPlayer extends MediaPlayer try { playing = super.isPlaying(); } catch (final IllegalStateException e) { - Log.d(TAG, e.getMessage()); + Log.d(TAG, "" + e.getMessage()); } return playing; @@ -345,13 +345,13 @@ public class QtAndroidMediaPlayer extends MediaPlayer /* MEDIA_ERROR_UNSUPPORTED= */ -1010, mID); } catch (final IllegalArgumentException e) { - Log.d(TAG, e.getMessage()); + Log.d(TAG, "" + e.getMessage()); } catch (final SecurityException e) { - Log.d(TAG, e.getMessage()); + Log.d(TAG, "" + e.getMessage()); } catch (final IllegalStateException e) { - Log.d(TAG, e.getMessage()); + Log.d(TAG, "" + e.getMessage()); } catch (final NullPointerException e) { - Log.d(TAG, e.getMessage()); + Log.d(TAG, "" + e.getMessage()); } } @@ -366,7 +366,7 @@ public class QtAndroidMediaPlayer extends MediaPlayer try { currentPosition = super.getCurrentPosition(); } catch (final IllegalStateException e) { - Log.d(TAG, e.getMessage()); + Log.d(TAG, "" + e.getMessage()); } return currentPosition; @@ -383,7 +383,7 @@ public class QtAndroidMediaPlayer extends MediaPlayer try { duration = super.getDuration(); } catch (final IllegalStateException e) { - Log.d(TAG, e.getMessage()); + Log.d(TAG, "" + e.getMessage()); } return duration; @@ -415,7 +415,7 @@ public class QtAndroidMediaPlayer extends MediaPlayer if (!mMuted) mVolume = volume; } catch (final IllegalStateException e) { - Log.d(TAG, e.getMessage()); + Log.d(TAG, "" + e.getMessage()); } }