mirror of https://github.com/qt/qt3d.git
Fix audio-visualizer example
Pick-to: 6.2 6.4 Fixes: QTCREATORBUG-27852 Change-Id: Icc10aa51f54a7ff19dcff2349048b436f273d6bf Reviewed-by: Janne Koskinen <janne.p.koskinen@qt.io> Reviewed-by: Antti Määttä <antti.maatta@qt.io>
This commit is contained in:
parent
e06bccdc93
commit
be9ccff07d
|
|
@ -10,9 +10,10 @@ Entity {
|
||||||
id: sceneRoot
|
id: sceneRoot
|
||||||
property int barRotationTimeMs: 1
|
property int barRotationTimeMs: 1
|
||||||
property int numberOfBars: 1
|
property int numberOfBars: 1
|
||||||
property string animationState: "stopped"
|
property string animationState
|
||||||
property real titleStartAngle: 95
|
property real titleStartAngle: 95
|
||||||
property real titleStopAngle: 5
|
property real titleStopAngle: 5
|
||||||
|
property bool started: false
|
||||||
|
|
||||||
onAnimationStateChanged: {
|
onAnimationStateChanged: {
|
||||||
if (animationState == "playing") {
|
if (animationState == "playing") {
|
||||||
|
|
@ -73,6 +74,7 @@ Entity {
|
||||||
progressTransformAnimation.duration = mediaPlayer.duration
|
progressTransformAnimation.duration = mediaPlayer.duration
|
||||||
mainview.state = "playing"
|
mainview.state = "playing"
|
||||||
progressTransformAnimation.start()
|
progressTransformAnimation.start()
|
||||||
|
started = true
|
||||||
}
|
}
|
||||||
|
|
||||||
//![0]
|
//![0]
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
|
qputenv("QML_XHR_ALLOW_FILE_READ", "1");
|
||||||
#ifdef Q_OS_ANDROID
|
#ifdef Q_OS_ANDROID
|
||||||
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
// Copyright (C) 2017 The Qt Company Ltd.
|
// Copyright (C) 2017 The Qt Company Ltd.
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
||||||
|
|
||||||
import QtQuick 2.0
|
import QtQuick
|
||||||
import QtQuick.Scene3D 2.0
|
import QtQuick.Scene3D
|
||||||
import QtQuick.Layouts 1.2
|
import QtQuick.Layouts
|
||||||
import QtMultimedia 5.0
|
import QtMultimedia
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: mainview
|
id: mainview
|
||||||
|
|
@ -70,19 +70,14 @@ Item {
|
||||||
//![0]
|
//![0]
|
||||||
MediaPlayer {
|
MediaPlayer {
|
||||||
id: mediaPlayer
|
id: mediaPlayer
|
||||||
autoPlay: true
|
|
||||||
volume: 0.5
|
|
||||||
source: "qrc:/music/tiltshifted_lost_neon_sun.mp3"
|
source: "qrc:/music/tiltshifted_lost_neon_sun.mp3"
|
||||||
|
audioOutput: AudioOutput {}
|
||||||
//![0]
|
//![0]
|
||||||
|
|
||||||
onStatusChanged: {
|
onMediaStatusChanged: {
|
||||||
if (status == MediaPlayer.EndOfMedia) //{
|
if (mediaStatus == MediaPlayer.EndOfMedia) {
|
||||||
state = "stopped"
|
mainview.state = "stopped"
|
||||||
}
|
} else if (mediaStatus == MediaPlayer.LoadedMedia && !visualizer.started) {
|
||||||
|
|
||||||
onError: console.error("error with audio " + mediaPlayer.error)
|
|
||||||
|
|
||||||
onDurationChanged: {
|
|
||||||
// Load the pre-calculated magnitude data for the visualizer
|
// Load the pre-calculated magnitude data for the visualizer
|
||||||
var request = new XMLHttpRequest()
|
var request = new XMLHttpRequest()
|
||||||
request.responseType = 'arraybuffer'
|
request.responseType = 'arraybuffer'
|
||||||
|
|
@ -104,6 +99,9 @@ Item {
|
||||||
request.open('GET', magnitudeDataSourceFile, true)
|
request.open('GET', magnitudeDataSourceFile, true)
|
||||||
request.send(null)
|
request.send(null)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onErrorStringChanged: console.error("error with audio " + errorString)
|
||||||
|
|
||||||
function getNextAudioLevel(offsetMs) {
|
function getNextAudioLevel(offsetMs) {
|
||||||
if (magnitudeArray === null)
|
if (magnitudeArray === null)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue