Documente Academic
Documente Profesional
Documente Cultură
LA CONCEPTION ET LA
REALISATION DE
MEDIAPLAYER
Atef bentahar
[LA CONCEPTION ET LA
REALISATION DE
MEDIAPLAYER]
Un nouveau lecteur multimedia avec une nouvelle conception, il est programmé sous la plateforme
code gear 2009 (delphi).
LA CONCEPTION ET LA REALISATION DE MEDIAPLAYER
1. INTODUCTION
audio comme :mp4 , mp3, mp2, wma, wav, asf, cda(cd audio),cde...ex
vidéo comme :mp4 , avi, mpeg, mpg, mov, wmv…ex.
Son interface graphique non-ambigue est enrichi avec des animations qui
permettent une bonne présentation et une ambiance graphique adéquate, ainsi
que sa liste de lecture qui affiche d’une façon graduelle, de haut en bas et vise
versa. En plus, l’utilisateur peut modifier l’aparance du fond-écran (skin).
mode normal.
mode minimisé.
A. Bentahar Page 1
LA CONCEPTION ET LA REALISATION DE MEDIAPLAYER
A. Bentahar Page 2
LA CONCEPTION ET LA REALISATION DE MEDIAPLAYER
A. Bentahar Page 3
LA CONCEPTION ET LA REALISATION DE MEDIAPLAYER
composants, dans l'onglet Système. Nous verrons que ce type de composant est
très utile. Il permet de définir une variable de temps qui s’incrémente à chaque
évènement "OnTimer" afin de réaliser ce tous ce qui dépend de l’animation et du
temps tels que:
La date et l’heure
La durée de la piste
Position de la piste en cours
Temps passé de piste en cours (en chiffre)
Durée passé de piste en cours sur la barre
Temps total de la lecture des pistes
Temps d’enregistrement
L’animation de l’adresse de la piste en cours
L’animation de l’affichage de la liste de lecture
Réaliser l’ambiance graphique
A. Bentahar Page 4
LA CONCEPTION ET LA REALISATION DE MEDIAPLAYER
A. Bentahar Page 5
LA CONCEPTION ET LA REALISATION DE MEDIAPLAYER
*** Initialisation des valeurs des variables dont chacune sera expliquée
en ce qui suit***
afi:=0;reco:=0;med2:=0;aff:=0;index:=0;ti:=0;ren:=false;
t:=false;btnpause.Enabled:=false;io:=0;re:=0;rep:=0;ou:=0;
ra:=0;ha:=1;actutabrendom:=1;itabrandom:=1;u:=1;r:=0;
A. Bentahar Page 6
LA CONCEPTION ET LA REALISATION DE MEDIAPLAYER
begin
tabrendom[itabrandom]:=-1;
itabrandom:=itabrandom+1;
end;
itabrandom:=1;
end;
L’ouverture des fichiers (l’élément 9 dans la figure 1 ) est faite sur deux parties,
la première fait l’animation quand le curseur soit sur le bouton ouvrir et ça
nécessite deux procédures TForm1.imgopenMouseMove et
TForm1.imgopenMouseDown. L’autre partie présente le fait du clic
(TForm1.openmClick).
A. Bentahar Page 7
LA CONCEPTION ET LA REALISATION DE MEDIAPLAYER
begin
if imgopen.Enabled=true then
imgopen.Picture.Graphic:=image52.Picture.Graphic;
end;
btnpause.Enabled:=true;
filte.Filter:=open.Filter;
mediaplayer1.Open;
if face.Transparent=true then
adressepiste.Font.Color:=clnavy
else
adressepiste.font.Color:=clskyblue;
play.Enabled:=true;
Imgstop.Enabled:=true;
play.Picture.Graphic:=image17.Picture.Graphic;
Imgstop.Picture.Graphic:=image18.Picture.Graphic;
Timertempspass.Enabled:=true;
adressepiste.Caption:=open.FileName;
Timertempstotal.Enabled:=true;
Timerambiance.Enabled:=true;
face.Picture.Graphic:=image9.Picture.Graphic;
Btnplay.Enabled:=false;
quickstop.Enabled:=true;
btnpistedureeClick(Sender);
***affichage de la Durée de la piste en cours (cela fait l’objet de la procédure
Suivante) ***
Imgrecord.Enabled:=true;imgrendom.Enabled:=true;
imgrepete.Enabled:=true;
MPSetVolume(MediaPlayer1, volumeBar.Position) ;
mediaplayer1.Play;
Buttonminimi.Enabled:=true;
A. Bentahar Page 8
LA CONCEPTION ET LA REALISATION DE MEDIAPLAYER
play.Picture.Graphic:=image39.Picture.Graphic;
end;
A. Bentahar Page 9
LA CONCEPTION ET LA REALISATION DE MEDIAPLAYER
7. CONCLUSION
Nous avons étudié et réalisé ce lecteur qui se caractérise par des privilèges
requis pour chaque autre lecteur multimédia ainsi que des privilèges
spéciaux pour le rendre capable de rivaliser ces lecteurs et se classer parmi
eux.
A. Bentahar Page 10
LA CONCEPTION ET LA REALISATION DE MEDIAPLAYER
Annex
Cet annex contient toutes les procédures qui n’ont pas présentées dans le
chapitre précédent. Ces procédures montrent le reste des éléments composant
l’interface graphique de notre application (voir figure 1 ).
A. Bentahar Page 11
LA CONCEPTION ET LA REALISATION DE MEDIAPLAYER
A. Bentahar Page 12
LA CONCEPTION ET LA REALISATION DE MEDIAPLAYER
form1.Height:=form1.Height-5;
end
else
begin
Timerlisteheight2.Enabled:=false;
form1.Height:=241;
end;
end;
{ce programme permet d’afficher la liste de lecture d’une façon graduelle, de
haut en bas et vice versa}
A. Bentahar Page 13
LA CONCEPTION ET LA REALISATION DE MEDIAPLAYER
end;
procedure TForm1.imgremoveMouseDown(Sender: TObject);
begin
if remove.Enabled=true then
imgremove.Picture:=b0.Picture;
end;
procedure TForm1.imgremoveMouseUp(Sender: TObject);
begin
if remove.Enabled=true then
begin
imgremove.Picture:=b1.Picture;
removeClick(Sender);
end;
end;
procedure TForm1.removeClick(Sender: TObject);
var ii:integer;
begin
for ii:=liste.items.count-1 downto 0 do
begin
if liste.Items.Count=1 then
exit;
if liste.selected[ii] then
begin
liste.Items.Delete(ii);
end;
end;
ii:=0;
end;
A. Bentahar Page 14
LA CONCEPTION ET LA REALISATION DE MEDIAPLAYER
ha:=1;
end
else
begin
if Timerambiance.Enabled=true then
play.Picture.Graphic:=image48.Picture.Graphic
else
play.Picture.Graphic:=image15.Picture.Graphic;
end; end;
procedure TForm1.playMouseUp(Sender: TObject);
begin
if ha=1 then
begin
if btnpause.Enabled=false then
begin
Imgstop.Picture.Graphic:=image18.Picture.Graphic;
play.Picture.Graphic:=image39.Picture.Graphic;
BtnplayClick(Sender);
{la procedure de la lecture (play)}
end
else
btnpauseClick(Sender);
{la procédure de mettre la piste en état de pause}
end;
end;
procedure TForm1.BtnplayClick(Sender: TObject);
var ii:integer;
begin
btnpause.Enabled:=true;
ra:=0;
ha:=1;
tete.Visible:=true;
for ii:=liste.items.count-1 downto 0 do
begin
if liste.selected[ii] then
begin
mediaplayer1.FileName:=liste.Items[ii];
end;
end;
mediaplayer1.Open;
MPSetVolume(MediaPlayer1, volumeBar.Position) ;
mediaplayer1.Play;
Btnplay.Enabled:=false;
quickstop.Enabled:=true;
Timerambiance.Enabled:=true;
end;
procedure TForm1.btnpauseClick(Sender: TObject);
begin
if ou=0 then
begin
mediaplayer1.Pause;
btnpause.Font.Color:=clgray;
A. Bentahar Page 15
LA CONCEPTION ET LA REALISATION DE MEDIAPLAYER
Imgstop.Enabled:=false;btnnext.Enabled:=false;
btnback.Enabled:=false;imgopen.Enabled:=false;
Timerambiance.Enabled:=false;
tete.Visible:=false;
ou:=1;
imgopen.Picture.Graphic:=image17.Picture.Graphic;
volumeBar.Visible:=false;image58.Visible:=false;
Imgstop.Picture.Graphic:=image27.Picture.Graphic;
play.Picture.Graphic:=image42.Picture.Graphic;
end
else
begin
mediaplayer1.Pause;
Timerambiance.Enabled:=true;
Imgstop.Enabled:=true;imgopen.Enabled:=true;
btnnext.Enabled:=true;btnback.Enabled:=true;
tete.Visible:=true;
ou:=0;
imgopen.Picture.Graphic:=image30.Picture.Graphic;
volumeBar.Visible:=true;
image58.Visible:=true;
Imgstop.Picture.Graphic:=image18.Picture.Graphic;
play.Picture.Graphic:=image39.Picture.Graphic;
end;
end;
A. Bentahar Page 16
LA CONCEPTION ET LA REALISATION DE MEDIAPLAYER
begin
btnpause.Enabled:=false;
mediaplayer1.Open;
mediaplayer1.Stop;
tete.Visible:=false;
face.Picture.Graphic:=image9.Picture.Graphic;
Btnplay.Enabled:=true;
quickstop.Enabled:=false;
ha:=0;
ra:=1;
Timerambiance.Enabled:=false;
end;
A. Bentahar Page 17
LA CONCEPTION ET LA REALISATION DE MEDIAPLAYER
ra:=0; ha:=1;
tete.Visible:=true;
if t=false then
begin
for ii:=liste.items.count-1 downto 0 do
begin
if liste.selected[ii] then
begin
if ii<liste.Items.Count-1 then
begin
mediaplayer1.FileName:=liste.Items[ii+1];
index:=ii+1;
end;
end;
end;
t:=true;
index:=index+1;
end
else
begin
index:=index+1;
if index< liste.Items.Count then
mediaplayer1.FileName:=liste.Items[index]
else
index:=0;
end;
re:=index;
mediaplayer1.FileName:=liste.Items[index];
mediaplayer1.Open;
adressepiste.Caption:=liste.Items[index];
MPSetVolume(MediaPlayer1, volumeBar.Position) ;
mediaplayer1.Play;
Btnplay.Enabled:=false;
quickstop.Enabled:=true;
Timerambiance.Enabled:=true;
end ;
if ren=true then
{2ème cas : la lecture aléatoire a été activée}
begin
ii:=liste.Items.Count;
index:=random(ii);
while (itabrandom<ii) do
begin
if tabrendom[itabrandom]=index then
begin
index:=random(ii);
itabrandom:=1;
end
else
itabrandom:=itabrandom+1;
end;
A. Bentahar Page 18
LA CONCEPTION ET LA REALISATION DE MEDIAPLAYER
A. Bentahar Page 19
LA CONCEPTION ET LA REALISATION DE MEDIAPLAYER
if ren=false then
{1 ère cas : la lecture aléatoire a été désactivé}
begin
btnpause.Enabled:=true;
ra:=0;ha:=1;
tete.Visible:=true;
if t=false then
begin
for ii:=liste.items.count-1 downto 0 do
begin
if liste.selected[ii] then
begin
if ii>0 then
begin
mediaplayer1.FileName:=liste.Items[ii-1];
index:=ii-1;
end;
end;
end;
index:=liste.Items.Count-1;
t:=true;
end
else
begin
index:=index-1;
if index>= 0 then
mediaplayer1.FileName:=liste.Items[index]
else
index:=liste.Items.Count-1;
end;
re:=index;
mediaplayer1.FileName:=liste.Items[index] ;
mediaplayer1.Open;
adressepiste.Caption:=liste.Items[index];
MPSetVolume(MediaPlayer1, volumeBar.Position) ;
mediaplayer1.Play;
Btnplay.Enabled:=false;
quickstop.Enabled:=true;
Timerambiance.Enabled:=true;
end ;
if ren=true then
{2 ème cas : la lecture aléatoire a été activée}
begin
ii:=liste.Items.Count;
index:=random(ii);
while (itabrandom<ii) do
begin
if tabrendom[itabrandom]=index then
begin
index:=random(ii);
itabrandom:=1;
end
A. Bentahar Page 20
LA CONCEPTION ET LA REALISATION DE MEDIAPLAYER
else
itabrandom:=itabrandom+1;
end;
tabrendom[actutabrendom]:=index;
actutabrendom:=actutabrendom+1;
itabrandom:=1;
if actutabrendom>ii then
actutabrendom:=1;
mediaplayer1.FileName:=liste.Items[index];
mediaplayer1.Open;
adressepiste.Caption:=liste.Items[index];
MPSetVolume(MediaPlayer1, volumeBar.Position) ;
mediaplayer1.Play;
Btnplay.Enabled:=false;
quickstop.Enabled:=true;
end;
end;
A. Bentahar Page 21
LA CONCEPTION ET LA REALISATION DE MEDIAPLAYER
filte.Filter:=open.Filter;
re:=index;
mediaplayer1.Open;
adressepiste.Caption:=liste.Items[index];
Timerambiance.Enabled:=true;
face.Picture.Graphic:=image9.Picture.Graphic;
btnpistedureeClick(Sender);
MPSetVolume(MediaPlayer1, volumeBar.Position) ;
mediaplayer1.Play;
Btnplay.Enabled:=false;
quickstop.Enabled:=true;
end;
A. Bentahar Page 22
LA CONCEPTION ET LA REALISATION DE MEDIAPLAYER
A. Bentahar Page 23
LA CONCEPTION ET LA REALISATION DE MEDIAPLAYER
mediaplayer1.Play;
end;
end
else
{indique que la lecture aléatoire a été activée}
begin
ii:=liste.Items.Count;
index:=random(ii);
while (itabrandom<ii) do
begin
if tabrendom[itabrandom]=index then
begin
index:=random(ii);
itabrandom:=1;
end
else
itabrandom:=itabrandom+1;
end;
tabrendom[actutabrendom]:=index;actutabrendom:=actutabrendom+1;
if actutabrendom>ii then
mediaplayer1.FileName:=liste.Items[index];
mediaplayer1.Open;
adressepiste.Caption:=liste.Items[index];
MPSetVolume(MediaPlayer1, volumeBar.Position) ;
mediaplayer1.Play;
Btnplay.Enabled:=false;
quickstop.Enabled:=true;
end;
end;
A. Bentahar Page 24
LA CONCEPTION ET LA REALISATION DE MEDIAPLAYER
pointeurposition.Enabled:=true;
end;
end;
{Changement de position par mouvement sur la barre}
procedure TForm1.teteClick(Sender: TObject);
begin
if afi=0 then
begin
if u=1 then
begin
tete.Picture.Graphic:=teteactive.Picture.Graphic;
u:=0;
end
else
begin
pointeurposition.Enabled:=true;
tete.Picture.Graphic:=tetenonactive.Picture.Graphic;
u:=1;
end; end; end;
procedure TForm1.barpisteMouseMove(Sender: TObject);
begin
if aff=1 then
begin
if ha=0 then
play.Picture.Graphic:=image13.Picture.Graphic
else
begin
if ou=0 then
play.Picture.Graphic:=image39.Picture.Graphic
else
play.Picture.Graphic:=image13.Picture.Graphic
end;
end;
if pointeurposition.Enabled=false then
begin
mediaplayer1.stop;
pointeurposition.Left:=x;
pbar1.Progress:=
(mediaplayer1.Length*pointeurposition.Left)div 350;
MediaPlayer1.Position:=
(mediaplayer1.Length*pointeurposition.Left)div 350;
MPSetVolume(MediaPlayer1, volumeBar.Position) ;
mediaplayer1.Play;
end;
end;
{ces deux dernières procédures permettent de changer la position de la piste en
cours en glissant sur la barre de la lecture (figure 1 élément 7), appuyer +
glisser}
A. Bentahar Page 25
LA CONCEPTION ET LA REALISATION DE MEDIAPLAYER
A. Bentahar Page 26
LA CONCEPTION ET LA REALISATION DE MEDIAPLAYER
begin
if aff=1 then
begin
if ren=false then
begin
imgrendom.Picture.Graphic:=image40.Picture.Graphic;
ren:=true;
end
else
begin
imgrendom.Picture.Graphic:=image41.Picture.Graphic;
ren:=false
end
end;
end;
A. Bentahar Page 27
LA CONCEPTION ET LA REALISATION DE MEDIAPLAYER
20. Enregistrement du son sur pc sous format wav (figure 1 : élément 23)
A. Bentahar Page 28
LA CONCEPTION ET LA REALISATION DE MEDIAPLAYER
imgnext.Picture.Graphic:=rig.Picture.Graphic;
imgremove.Picture.Graphic:=bbbb.Picture.Graphic;
btnpause.Enabled:=false;btnnext.Enabled:=false;
btnback.Enabled:=false;ajoute.Enabled:=false;
remove.Enabled:=false;listeheight.Enabled:=false;
Buttonminimi.Enabled:=false;imgopen.Enabled:=false;
Imgstop.Enabled:=false;play.Enabled:=false;
imgrendom.Enabled:=false;imgrepete.Enabled:=false;
play.Picture.Graphic:=image49.Picture.Graphic;
imgrepete.Picture.Graphic:=repe.Picture.Graphic;
imgrendom.Picture.Graphic:=alea.Picture.Graphic;
Imgstop.Picture.Graphic:=image27.Picture.Graphic;
volumeBar.Visible:=false;image58.Visible:=false;
imgopen.Picture.Graphic:=image17.Picture.Graphic;
pisteduree.Caption:=('0:00') ;
tempspass.Caption:=('0:00') ;
for ii:=liste.items.count-1 downto 0 do
begin
liste.Items.Delete(ii);
end;
ii:=0;
if Timerrecorde.Enabled=false then
begin
Timerrecorde.Enabled:=true;
mediaplayer1.StartRecording;
end
else
begin
Timerrecorde.Enabled:=false;
reco:=0;
if aff=1 then
begin
save.Execute;
mediaplayer1.FileName:=save.FileName;
mediaplayer1.save;
end;
Buttonminimi.Enabled:=false;
FormCreate(Sender);
imgopen.Enabled:=true;
Imgrecord.Picture.Graphic:=image35.Picture.Graphic;
recordetemps.Caption:=('') ;
Imgrecord.Enabled:=false;
Imgliste.Visible:=true;
end;
end;
procedure TForm1.TimerrecordeTimer(Sender: TObject);
begin
reco:=reco+1;
min:=reco div 60;
sec:=reco-(min*60);
if sec>9 then
begin
A. Bentahar Page 29
LA CONCEPTION ET LA REALISATION DE MEDIAPLAYER
recordetemps.Caption := IntToStr(min)+(':')+IntToStr(sec);
end
else
recordetemps.Caption :=
IntToStr(min)+(':')+('0')+IntToStr(sec);
end;
A. Bentahar Page 30