NCL Composer  0.1.5
 All Classes Functions Variables Pages
audioplayer.cpp
1 /*INF2102 Projeto Final de Programação*****************
2  *Período: 2012/2
3  *Coordenador: Prof. Carlos José Pereira Lucena *
4  *Projeto: Media-Preview Plugin para o Composer 3.0 *
5  *Nome do aluno: Amparito Alexandra Morales Figueroa. *
6  *Matrícula: 1121838 *
7  *Orientador: Prof. Luiz Fernando Gomes Soares *
8  *Classe: AudioPlayer *
9  *Descrição: Exibição de mídias de audio***************/
10 
11 #include <audioplayer.h>
12 #include<QObject>
13 #include<QPushButton>
14 #include<MediaObject>
15 #include<QWidget>
16 #include<QMouseEvent>
17 #include<QHBoxLayout>
18 #include<VideoPlayer>
19 #include<QFont>
20 #include<AudioOutput>
21 #include<QSlider>
22 #include<VolumeSlider>
23 #include<Path>
24 
25 audioplayer::audioplayer(QString filename)
26 
27 {
28  setStyleSheet("* { background-color: rgb(220,220,220) }");
29  setMinimumWidth(150);
30  setMinimumHeight(60);
31 
32  mediaobject = Phonon::createPlayer(Phonon::MusicCategory,
33  Phonon::MediaSource(filename));
34  /*Criação dos botões de controle(play, pause, stop, slider de voulme,e
35  seek slider*/
36 
37  playButton = new QPushButton();
38  pauseButton = new QPushButton();
39  stopButton = new QPushButton();
40  playButton->setFont(QFont("Comic Sans MS",10,QFont::Bold));
41  pauseButton->setFont(QFont("Comic Sans MS",10,QFont::Bold));
42  stopButton->setFont(QFont("Comic Sans MS",10,QFont::Bold));
43 
44  playButton->setIcon(QIcon("play.jpeg"));
45  playButton->setFixedWidth(51);
46  playButton->setFixedHeight(34);
47  playButton->setIconSize(QSize (26,26));
48  playButton->setStyleSheet("* { background-color: rgb(173,255,47) }");
49  playButton->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum);
50 
51  pauseButton->setIcon(QIcon("pause.jpeg"));
52  pauseButton->setFixedWidth(51);
53  pauseButton->setFixedHeight(34);
54  pauseButton->setIconSize(QSize (26,26));
55  pauseButton->setStyleSheet("* { background-color: rgb(173,255,47) }");
56  pauseButton->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum);
57 
58  stopButton->setIcon(QIcon("stop.jpeg"));
59  stopButton->setFixedWidth(51);
60  stopButton->setFixedHeight(34);
61  stopButton->setIconSize(QSize (26,26));
62  stopButton->setStyleSheet("* { background-color: rgb(173,255,47) }");
63 stopButton->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum);
64 
65  mediaobject = new Phonon::MediaObject(this);
66  mediaobject->setCurrentSource(Phonon::MediaSource(filename));
67  Audioutput =new Phonon::AudioOutput(Phonon::MusicCategory, this);
68  audioOutputPath = Phonon::createPath(mediaobject, Audioutput);
69  Audioutput->setVolume(0.003);
70 
71  volumeslider= new Phonon::VolumeSlider();
72  volumeslider->setAudioOutput(Audioutput);
73 
74  volumeslider->setSingleStep(0.002);
75  volumeslider->setMaximumVolume(0.5);
76  volumeslider->setTracking(true);
77  volumeslider->setMaximumVolume(1);
78  volumeslider->setMuteVisible(true);
79  volumeslider->setFixedSize(150,31);
80  volumeslider->setFixedWidth(170);
81  volumeslider->setSizePolicy(QSizePolicy::Maximum,QSizePolicy::MinimumExpanding);
82 
83 
84 
85  Phonon::SeekSlider *slider = new Phonon::SeekSlider;
86  slider->setMediaObject(mediaobject);
87  slider->setFixedWidth(510);
88  slider->show();
89 
90 
91  QHBoxLayout *layout = new QHBoxLayout;
92  layout->addWidget(playButton);
93  layout->addWidget(pauseButton);
94  layout->addWidget(stopButton);
95  layout->addWidget(volumeslider);
96 
97  QHBoxLayout *layout2=new QHBoxLayout;
98  layout2->addWidget(slider);
99 
100  QVBoxLayout *layoutf=new QVBoxLayout;
101 
102  layoutf->addLayout(layout);
103  layoutf->addLayout(layout2);
104 
105 setLayout(layoutf);
106 
107 setVisible(true);
108 
109 
110 /*Slots para o controle dos botões*/
111 
112 QObject::connect(playButton,SIGNAL(clicked()),this,SLOT(play()));
113 QObject::connect(pauseButton,SIGNAL(clicked()),this,SLOT(pause()));
114 QObject::connect(stopButton,SIGNAL(clicked()),this,SLOT(stop()));
115 
116 }
117 
118 
120 {
121 
122 }
123 
125 {
126  mediaobject->play();
127 
128 }
129 
131 {
132  mediaobject->pause();
133 }
134 
136 {
137  mediaobject->stop();
138 }
139 
140 
141 
142 
143 
144 
145 
146