History

Moved SoundEffect into a separate compilation unit.

Also, fixed license header in TabletScriptingInterface, to include proper author and date.

Anthony J. Thibault committed 9 years ago

Commit 05429451 parent 116eef04 files · +80 −66Browse files

Showing the changes to libraries/script-engine/src/TabletScriptingInterface.cpp (1 of 4 files). Show all

Unified · Split

libraries/script-engine/src/TabletScriptingInterface.cpp+2−44
@@ -1,5 +1,5 @@
11 //
2−// Created by Bradley Austin Davis on 2016-06-16
2+// Created by Anthony J. Thibault on 2016-12-12
33 // Copyright 2013-2016 High Fidelity, Inc.
44 //
55 // Distributed under the Apache License, Version 2.0.
@@ -10,13 +10,13 @@ · 4 unmodified lines
1010
1111 #include <QtCore/QThread>
1212
13−#include <AudioInjector.h>
1413 #include <AccountManager.h>
1514 #include <PathUtils.h>
1615 #include <RegisteredMetaTypes.h>
1716 #include "ScriptEngineLogging.h"
1817 #include "DependencyManager.h"
1918 #include "OffscreenUi.h"
19+#include "SoundEffect.h"
2020
2121 TabletScriptingInterface::TabletScriptingInterface() {
2222 qmlRegisterType<SoundEffect>("Hifi", 1, 0, "SoundEffect");
@@ -416,47 +416,5 @@ void TabletButtonProxy::editProperties(QVariantMap properties) { · 393 unmodified lines
416416 }
417417 }
418418
419−//
420−// SoundEffect
421−//
422−
423−SoundEffect::~SoundEffect() {
424− if (_sound) {
425− _sound->deleteLater();
426− }
427− if (_injector) {
428− // stop will cause the AudioInjector to delete itself.
429− _injector->stop();
430− }
431−}
432−
433−QUrl SoundEffect::getSource() const {
434− return _url;
435−}
436−
437−void SoundEffect::setSource(QUrl url) {
438− _url = url;
439− _sound = DependencyManager::get<SoundCache>()->getSound(_url);
440−}
441−
442−void SoundEffect::play(QVariant position) {
443− auto tsi = DependencyManager::get<TabletScriptingInterface>();
444− if (tsi) {
445− TabletProxy* tablet = qobject_cast<TabletProxy*>(tsi->getTablet("com.highfidelity.interface.tablet.system"));
446− if (tablet) {
447− AudioInjectorOptions options;
448− options.position = vec3FromVariant(position);
449− options.localOnly = true;
450− if (_injector) {
451− _injector->setOptions(options);
452− _injector->restart();
453− } else {
454− QByteArray samples = _sound->getByteArray();
455− _injector = AudioInjector::playSound(samples, options);
456− }
457− }
458− }
459−}
460−
461419 #include "TabletScriptingInterface.moc"
462420