Warning: That file was not part of the compilation database. It may have many parsing errors.

1/* This file is part of the KDE project
2 Copyright (C) 2006 Matthias Kretz <kretz@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) version 3, or any
8 later version accepted by the membership of KDE e.V. (or its
9 successor approved by the membership of KDE e.V.), Nokia Corporation
10 (or its successors, if any) and the KDE Free Qt Foundation, which shall
11 act as a proxy defined in Section 6 of version 3 of the license.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library. If not, see <http://www.gnu.org/licenses/>.
20
21*/
22
23#include "crossfade.h"
24#include <phonon/mediaqueue.h>
25#include <phonon/audiopath.h>
26#include <phonon/audiooutput.h>
27#include <phonon/ui/seekslider.h>
28#include <kurl.h>
29#include <QtCore/QTimer>
30#include <kaboutdata.h>
31#include <kcmdlineargs.h>
32#include <kapplication.h>
33#include <klocale.h>
34
35Crossfader::Crossfader(const KUrl &url1, const KUrl &url2, QObject *parent)
36 : QObject(parent)
37 , media(new MediaQueue(this))
38 , path(new AudioPath(this))
39 , output(new AudioOutput(Phonon::MusicCategory, this))
40{
41 media->addAudioPath(path);
42 path->addOutput(output);
43 media->setUrl(url1);
44 media->setNextUrl(url2);
45 connect(media, SIGNAL(finished()), SLOT(finished()));
46 SeekSlider *slider = new SeekSlider();
47 slider->setMediaProducer(media);
48 slider->resize(1000, 50);
49 slider->show();
50 media->play();
51 media->seek(media->totalTime() * 97 / 100);
52 //QTimer::singleShot(0, media, SLOT(play()));
53}
54
55void Crossfader::finished()
56{
57 static int count = 0;
58 ++count;
59 if (count == 2)
60 {
61 qApp->quit();
62 }
63}
64
65int main(int argc, char ** argv)
66{
67 KCmdLineOptions options;
68 options.add("+URL1", ki18n("The first URL to play"));
69 options.add("+URL2", ki18n("The second URL to play"));
70
71 KAboutData about("crossfade", 0, ki18n("Phonon Crossfade Example"),
72 "1.0", KLocalizedString(),
73 KAboutData::License_LGPL);
74 about.addAuthor(ki18n("Matthias Kretz"), KLocalizedString(), "kretz@kde.org");
75 KCmdLineArgs::init(argc, argv, &about);
76 KCmdLineArgs::addCmdLineOptions(options);
77 KApplication app;
78 KUrl url1;
79 KUrl url2;
80 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
81 if (args->count() == 2)
82 {
83 url1 = args->url(0);
84 url2 = args->url(1);
85 if (url1.isValid() && url2.isValid())
86 {
87 Crossfader xfader(url1, url2);
88 return app.exec();
89 }
90 }
91 return 1;
92}
93
94#include "crossfade.moc"
95

Warning: That file was not part of the compilation database. It may have many parsing errors.