-
Notifications
You must be signed in to change notification settings - Fork 0
/
ControleLecture.cs
98 lines (85 loc) · 2.71 KB
/
ControleLecture.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using Microsoft.DirectX.AudioVideoPlayback;
using System.Windows.Controls;
namespace Lecteur_mp3
{
public class ControleLecture
{
public Audio Lecteur;
public void _lire()
{
if (Lecteur != null)
{
Lecteur.Play();
}
}
public string _ouvrir(typeFichier tf)
{
OpenFileDialog ofd = new OpenFileDialog();
if (tf == typeFichier.musique)
{
ofd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic);
ofd.Filter = "mp3 files (*.mp3)|*.mp3";
ofd.FilterIndex = 2;
ofd.RestoreDirectory = true;
if (ofd.ShowDialog() == DialogResult.OK)
{
if (ofd.OpenFile() != null)
{
try
{
Lecteur = new Audio(ofd.FileName, false);
}
catch (Exception esx)
{
MessageBox.Show("Fichier non reconnu." + esx.HResult);
return null;
}
return ofd.FileName;
}
}
return null;
}
else if (tf == typeFichier.image)
{
ofd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
ofd.Filter = "JPG (*.jpg)|*.jpg";
ofd.FilterIndex = 2;
ofd.RestoreDirectory = true;
if (ofd.ShowDialog() == DialogResult.OK)
{
try
{
if (ofd.OpenFile() != null)// On attribue le chemin du fichier à lire au
{
return ofd.FileName;
}
}
catch (Exception ex)
{
MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
return null;
}
}
return null;
}
return null;
}
public void _arreter()
{
if (Lecteur != null)
Lecteur.Stop();
}
public void _interrompre()
{
if (Lecteur != null)
Lecteur.Pause();
}
}
}