Précédent   Forum du club des développeurs et IT Pro > Environnements de développement > MATLAB > Téléchargez
Téléchargez Récupérez et commentez les sources et outils mis à disposition par la rubrique MATLAB
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse
 
Outils de la discussion
Publicité
'
Vieux 26/02/2008, 22h00   #1
Dut
Responsable MATLAB & Hardware/PC

 
Avatar de Dut
 
Inscription : novembre 2006
Messages : 15 072
Détails du profil
Informations personnelles :
Localisation : France

Informations forums :
Inscription : novembre 2006
Messages : 15 072
Points : 31 146
Points : 31 146
Par défaut [ActiveX] Afficher du contenu multimedia grâce au VLC Media Player

Mise à jour

19 Septembre 2009 :
  • Les versions VLC et VLCLITE développées pour la version 0.8 Janus du VLC media player sont améliorées dans des versions VLC2 et VLCLITE2 fonctionnant avec la version 1.0.1 Goldeneye du VLC media player
---------------------------------------------------
Mise à jour

01 Avril 2008 :
  • VLCLITE devient VLC (tout court) avec la prise en charge du temps de chargement de la video.
  • Ajout du nouveau code VLCLITE qui est une version légère de VLC et qui permet de mettre le flux du media dans un objet Axes (axes ou subplot).
---------------------------------------------------

Les codes qui suivent permettent de contrôler le VLC Media Player (plus d'info sur le projet VideoLAN : http://www.videolan.org/) dans MATLAB afin d'afficher du contenu multimedia.

Ce player est disponible gratuitement et permet de lire de nombreux formats audio et video : VLC features list

Comme il utilise le controle ActiveX du VLC Media Player, il ne fonctionne que sous Windows.

Vous devez dans un premier temps télécharger et installer le VLC Media Player ici

---------------------------------------------------

Note : contrairement aux fonction AVIREAD ou MMREADER, il n'est pas possible d'avoir accès au contenu du flux.

---------------------------------------------------

N'hésitez pas à nous faire part de vos remarques ou de vos suggestions à propos de cette contribution
Dut est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 01/04/2008, 02h02   #2
Dut
Responsable MATLAB & Hardware/PC

 
Avatar de Dut
 
Inscription : novembre 2006
Messages : 15 072
Détails du profil
Informations personnelles :
Localisation : France

Informations forums :
Inscription : novembre 2006
Messages : 15 072
Points : 31 146
Points : 31 146
La fonction VLC permet d'utiliser le lecteur VLC dans sa version standard.

Les controles du media disponibles sont :
  • lecture/pause/arrêt
  • ralentit : x1/2, x1/4 et x1/8
  • avance rapide : x2, x4 et x8
  • positionnement flexible dans le flux
  • son on/off

Les données affichées pendant la lecture sont :
  • Temps parcouru
  • Temps total
  • Vitesse de lecture
  • Chemin d'accès du fichier


Code :
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
function vlc(file,volume)
% VLC Display movie/sound file using VLC media player
%   VLC(FILE) display movie/sound file named FILE in a new
%   Figure object.
%   VLC(FILE,VOLUME) display movie/sound file named FILE in a
%   new Figure object with sound volume VOLUME in the 
%   range [0 100] (0:nosound, 100 full sound).
%
%   User controls avaible :
%       PLAY / PAUSE
%       STOP
%       PLAY FASTER / PLAY SLOWER
%       SHUTTLE
%       TOGGLE MUTE
%
%   Data display :
%       Elapsed Time
%       Full Time
%       Speed Ratio
%       File Name
%       Path Name
%
%   More informations about the VLC Media Player : 
%       http://www.videolan.org/vlc/
%       http://wiki.videolan.org/ActiveX_Controls   
%
%   See also vlclite
%

%   Author: Jérôme Briot
%           http://www.developpez.net/forums/member.php?u=125006
%           http://www.mathworks.com/matlabcentral/fileexchange/loadAuthor.do?objectId=1094934&objectType=author
%   Contact: dutmatlab#yahoo#fr
%   Version: 1.0 - 01 Apr 2008
%   Comments:
%

nargchk(1,2,nargin);

if exist(file,'file')~=2
    error('Can''t read %s',file);
end

if nargin==1
    volume = 50; 
end

[pname,fname,ext]=fileparts(file);

fig = figure('units','pixels','position',[381 188 500 400],...
    'menubar','none',...
    'numbertitle','off',...
    'closerequestfcn',@crfcn);

tb = uitoolbar(fig);
X={};
parseIcons;
addbutton2toolbar;

edit(1)=uicontrol('style','edit','units','pixels','position',[0 0 75 25],'enable','inactive','hor','center',...
    'tooltipstring','Total time');
edit(2)=uicontrol('style','edit','units','pixels','position',[75 0 35 25],'enable','inactive','hor','center',...
    'tooltipstring','Elapsed time','string','x1.00');
edit(3)=uicontrol('style','edit','units','pixels','position',[110 0 390 25],'enable','inactive','string',pname,...
    'hor','left');

slider=uicontrol('style','slider','units','pixels','position',[0 25 500 25],...
    'callback',@slidfcn,...
    'sliderstep',[.01 .01]);

movegui('center');

actx = actxcontrol('VideoLAN.VLCPlugin.1', ...
    'position',[0 50 500 350], ...
	'parent',fig);

set(fig,'resizefcn',@rfcn);

vi = get(actx,'VersionInfo');
vr = version('-release');

set(fig,'name',sprintf('%s%s - VLC media player (%s) - MATLAB %s',fname,ext,vi,vr));

invoke(actx,'addTarget',file,[],12,int32(1));

l=-inf;
while l<=0
    l=double(get(actx,'length'));
    pause(.01);
end

set(actx,'volume',volume);

vitesse = 1;
mtotal=uint8(floor(l/60));
stotal=uint8(rem(l,60));
set(edit(1),'string',sprintf('00:00 / %02d:%02d',mtotal,stotal))

tim = timer('timerfcn',@timfcn,'period',1,'executionmode','fixedRate');

start(tim)

    function parseIcons
        
        bmpfiles = {'pause.bmp' 'stop.bmp' 'slower.bmp' 'faster.bmp' 'on.bmp' 'off.bmp' 'play.bmp'};
        uibgcol = uint8(255*get(0,'factoryUicontrolBackgroundColor'));
        
        for n=1:numel(bmpfiles)
           
            X{n} = imread(bmpfiles{n},'bmp');
            idx = find((X{n}(:,:,1)==212 & X{n}(:,:,2)==208 & X{n}(:,:,3)==200));
            X{n}(idx) = uibgcol(1);
            X{n}(25*25+idx) = uibgcol(2); 
            X{n}(2*25*25+idx) = uibgcol(3);
            
        end
        
    end
        
    function addbutton2toolbar

        cb = {'Pause' 'Stop' 'Slower' 'Faster' 'Sound Off'};
        
        sep={'off' 'off' 'on' 'off' 'off' 'on'};
        
        for n=1:numel(cb)

            uipushtool(tb, ...
                'cdata',X{n}, ...
                'tooltipstring',cb{n},...
                'clickedcallback',@action,...
                'tag',cb{n},...
                'separator',sep{n});

        end
     
    end

    function action(obj,event)
        
        act = get(obj,'tag');
        
        switch act
            
            case 'Stop' 
                
                stop(tim);
                invoke(actx,act);
                delete(actx); 
                pause(.05);
                delete(fig);
                    
            case 'Pause'
        
                flag = get(actx,'Playing');
                if flag                    
                    n = 7; 
                    cb = 'Play';
                    stop(tim);
                else                    
                    n=1; 
                    cb = 'Pause';
                    start(tim);
                end

                set(obj,'tooltipstring',cb,'cdata',X{n});                
                invoke(actx,act);
                
            case 'Slower'
                
                vitesse=vitesse/2;
                if vitesse<0.125
                    vitesse=0.125;
                end
                
                act = sprintf('play%s',act);
                invoke(actx,act);
                set(edit(2),'string',sprintf('x%.2f',vitesse))
                
            case 'Faster'
                
                vitesse=vitesse*2;
                if vitesse>8
                    vitesse=8;
                end
                
                act = sprintf('play%s',act);
                invoke(actx,act);
                set(edit(2),'string',sprintf('x%.2f',vitesse))
                
            case {'Sound Off'}

                flag = strcmp(get(obj,'tooltipstring'),'Sound Off');
                
                if flag
                   n = 6; 
                   tts = 'Sound On';
                else
                   n = 5; 
                   tts = 'Sound Off';
                end

                set(obj,'cdata',X{n},'tooltipstring',tts);
                invoke(actx,'toggleMute');
                
        end
                
    end    

    function timfcn(obj,event)
        
        pos=get(actx,'position');
        
        if pos>1
            pos = 0;
            stop(tim);
        end
        
        t=pos*l;      
        m=uint8(floor(t/60));
        s=uint8(rem(t,60));

        set(edit(1),'string',sprintf('%02d:%02d / %02d:%02d',m,s,mtotal,stotal))
        set(slider,'value',pos)
     
    end

    function crfcn(obj,event)
        
        invoke(actx,'Stop');
        delete(actx);
        stop(tim);
        pause(.05);
        delete(fig);
        
    end

    function rfcn(obj,event)
        
        pos = get(obj,'position');
        move(actx,[0 50 pos(3:4)]);
        set(edit(3),'position',[110 0 pos(3)-110 25]);
        set(slider,'position',[0 25 pos(3) 25]);
    end

    function slidfcn(obj,event)
        
        t=get(obj,'value');
        
        actxpos=get(actx,'position');
        incr=round((t-actxpos)*l);
        actx.shuttle(incr);
        
        t=t*l;
        m=uint8(floor(t/60));
        s=uint8(rem(t,60));

        set(edit(1),'string',sprintf('%02d:%02d / %02d:%02d',m,s,mtotal,stotal))

    end
        
end
L'archive .zip attachée à ce message contient les fichiers suivants :
  • vlc.m
  • faster.bmp
  • off.bmp
  • on.bmp
  • pause.bmp
  • play.bmp
  • slower.bmp
  • stop.bmp
Fichiers attachés
Type de fichier : zip vlc.zip (3,7 Ko, 104 affichages)
Dut est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 01/04/2008, 02h18   #3
Dut
Responsable MATLAB & Hardware/PC

 
Avatar de Dut
 
Inscription : novembre 2006
Messages : 15 072
Détails du profil
Informations personnelles :
Localisation : France

Informations forums :
Inscription : novembre 2006
Messages : 15 072
Points : 31 146
Points : 31 146
Le code suivant est une forme allégée du code ci-dessus.
Il permet d'intégrer directement le flux dans un objet Axes (axes ou subplot).

En réalité, le flux (le control ActiveX) n'est pas placé dans l'objet Axes mais sur l'objet Axes (celui-ci étant rendu invisible).

Aucun contrôle n'est disponible pour gérer le flux dans cette version.

Code :
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
function vlclite(varargin)
% VLCLITE Display movie/sound file using VLC media player in an axes
%   VLCLITE(AX,FILE) display movie/sound file named FILE in the axes 
%   with handle AX.
%   VLCLITE(AX,FILE,VOLUME) display movie/sound file named FILE in the 
%   axes with handle AX with sound volume VOLUME in the range [0 100] 
%   (0:nosound, 100 full sound).
%
%   If first argument AX is omitted, the media is displayed in the 
%   current axes.
%
%   Note : VLCLITE includes no feature to control the media.
%
%   More informations about the VLC Media Player : 
%       http://www.videolan.org/vlc/
%       http://wiki.videolan.org/ActiveX_Controls   
%
%   See also vlc
%

%   Author: Jérôme Briot
%           http://www.developpez.net/forums/member.php?u=125006
%           http://www.mathworks.com/matlabcentral/fileexchange/loadAuthor.do?objectId=1094934&objectType=author
%   Contact: dutmatlab#yahoo#fr
%   Version: 1.0 - 01 Apr 2008
%   Comments:
%

nargchk(1,3,nargin);

if ~ishandle(varargin{1})     
    if nargin == 1
        volume = 50;   
    else
        volume = varargin{2};     
    end
    file = varargin{1};
    handle = gca;    
else    
    if strcmpi(get(varargin{1},'type'),'axes')
        if nargin == 2
           volume = 50; 
           file = varargin{2};
           handle = varargin{1};
        else
           volume = varargin{3}; 
           file = varargin{2};
           handle = varargin{1};
        end       
    else
        error('First argument must be handle of an Axes object in VLCLITE(AX,...)');
    end   
end

if exist(file,'file')~=2
    error('Can''t read %s',file);
end

units = get(handle,'units');
set(handle,'units','pixels');
position = plotboxpos(handle);
set(handle,'units',units,'visible','off');

fig = get(handle,'parent');

actx = actxcontrol('VideoLAN.VLCPlugin.1', ...
    'position',position, ...
	'parent', fig);

invoke(actx,'addTarget',file,[],12,int32(1));

l=-inf;
while l<=0
    l=double(get(actx,'length'));
    pause(.01);
end

set(actx,'volume',volume);

set(fig,'closerequestfcn',@crfcn)

    function crfcn(obj,event)
        
        invoke(actx,'Stop');
        pause(.02);
        delete(actx);
        pause(.02);
        delete(fig);
        
    end

end
VLCLITE utilise deux contributions du FEX (incluses dans l'archive vlclite.zip) :
Fichiers attachés
Type de fichier : zip vlclite.zip (3,0 Ko, 26 affichages)
Dut est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 18/09/2009, 11h10   #4
khaptain
Candidat au titre de Membre du Club
 
Inscription : juillet 2009
Messages : 29
Détails du profil
Informations personnelles :
Âge : 27
Localisation : France, Paris (Île de France)

Informations forums :
Inscription : juillet 2009
Messages : 29
Points : 13
Points : 13
Bonjour Dut,

J'utilise le code que tu as fourni ci-dessus qui marche bien, mais ne connaissant rien en controle activex, je me demandais s'il est possible de le modifier pour qu'il fonctionne avec les dernières versions de vlc? En effet, après en avoir essayé plusieurs, j'en ai conclu que la plus récente qui fonctionne est bien la 0.8...

Merci d'avance
khaptain est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 18/09/2009, 11h22   #5
Dut
Responsable MATLAB & Hardware/PC

 
Avatar de Dut
 
Inscription : novembre 2006
Messages : 15 072
Détails du profil
Informations personnelles :
Localisation : France

Informations forums :
Inscription : novembre 2006
Messages : 15 072
Points : 31 146
Points : 31 146
En effet, on peut mainteant lire sur la page que je citais dans le premier message :
Citation:
The API described in this page only reflects VLC ActiveX controls prior to 0.8.5.1. This API will be removed soon.

It is not advised to use this JS API any longer.

Please use the VLC ActiveX v2 interface as described in the new documentation.
Il faut donc se référer à cette page : http://wiki.videolan.org/Documentation:WebPlugin

Et, si je ne me trompe pas, il faut maintenant utiliser ce controle :
Code :
actx = actxcontrol('VideoLAN.VLCPlugin.2');
Les propriétés sont données par

et les méthodes par

Il suffit ensuite de modifier les anciens appels par les nouveaux en comparant les deux pages de la documentation

Je vais essayer de trouver un peu de temps pour mettre à jour cette contribution
__________________
Identification de processeur sous MATLAB (3/3) Identification de processeur sous MATLAB (2/3) Mes contributions MATLAB (R2009a - Windows & Linux)

J'étais le meilleur ami que le vieux Jim avait au monde. Il fallait choisir. J'ai réfléchi un moment, puis je me suis dit : "Tant pis ! J'irai en enfer" (Saint Huck)
Dut est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 18/09/2009, 14h14   #6
khaptain
Candidat au titre de Membre du Club
 
Inscription : juillet 2009
Messages : 29
Détails du profil
Informations personnelles :
Âge : 27
Localisation : France, Paris (Île de France)

Informations forums :
Inscription : juillet 2009
Messages : 29
Points : 13
Points : 13
Je vais essayer. Merci!
khaptain est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 19/09/2009, 18h13   #7
Dut
Responsable MATLAB & Hardware/PC

 
Avatar de Dut
 
Inscription : novembre 2006
Messages : 15 072
Détails du profil
Informations personnelles :
Localisation : France

Informations forums :
Inscription : novembre 2006
Messages : 15 072
Points : 31 146
Points : 31 146
Voici pour commencer VLCLITE2 la version de VLCLITE qui marche avec le VLC 1.0.1 goldeneye

Code :
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
function vlclite2(varargin)
% VLCLITE2 Display movie/sound file using VLC media player in an axes
%   VLCLITE2(AX,FILE) display movie/sound file named FILE in the axes
%   with handle AX.
%   VLCLITE2(AX,FILE,VOLUME) display movie/sound file named FILE in the
%   axes with handle AX with sound volume VOLUME in the range [0 100]
%   (0:nosound, 100 full sound).
%
%   If first argument AX is omitted, the media is displayed in the
%   current axes.
%
%   Note : VLCLITE2 includes no feature to control the media.
%
%   VLCLITE2 works with VLC 1.0.1 Goldeneye
%
%   More informations about the VLC Media Player :
%       http://www.videolan.org/vlc/
%       http://wiki.videolan.org/ActiveX_Controls
%
%   See also vlc2
%

%   Author: Jérôme Briot
%           http://www.developpez.net/forums/member.php?u=125006
%           http://www.mathworks.com/matlabcentral/fileexchange/loadAuthor.do?objectId=1094934&objectType=author
%   Contact: dutmatlab#yahoo#fr
%   Version: 1.0 - 19 Sep 2009
%  
%   Comments:
%

nargchk(1,3,nargin);

if ~ishandle(varargin{1})
    if nargin == 1
        volume = 50;
    else
        volume = varargin{2};
    end
    file = varargin{1};
    handle = gca;
else
    if strcmpi(get(varargin{1},'type'),'axes')
        if nargin == 2
            volume = 50;
            file = varargin{2};
            handle = varargin{1};
        else
            volume = varargin{3};
            file = varargin{2};
            handle = varargin{1};
        end
    else
        error('First argument must be handle of an Axes object in VLCLITE(AX,...)');
    end
end

if exist(file,'file')~=2
    error('Can''t read %s',file);
end

units = get(handle,'units');
set(handle,'units','pixels');
position = plotboxpos(handle);
set(handle,'units',units,'visible','off');

fig = get(handle,'parent');

actx = actxcontrol('VideoLAN.VLCPlugin.2', ...
    'position',position, ...
    'parent', fig);

actx.playlist.add(file);
actx.playlist.play();

l=0;
while l<=0
    l=double(actx.Input.Length);
    pause(.01);
end

actx.audio.Volume = volume;

set(fig,'closerequestfcn',@crfcn)

    function crfcn(obj,event)

        actx.playlist.stop();
        pause(.02);
        delete(actx);
        pause(.02);
        delete(fig);

    end

end
Comme VLCLITE, VLCLITE2 utilise deux contributions du FEX (incluses dans l'archive vlclite2.zip) :
Le reste un peu plus tard...
Fichiers attachés
Type de fichier : zip vlclite2.zip (1,1 Ko, 20 affichages)
__________________
Identification de processeur sous MATLAB (3/3) Identification de processeur sous MATLAB (2/3) Mes contributions MATLAB (R2009a - Windows & Linux)

J'étais le meilleur ami que le vieux Jim avait au monde. Il fallait choisir. J'ai réfléchi un moment, puis je me suis dit : "Tant pis ! J'irai en enfer" (Saint Huck)
Dut est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 19/09/2009, 19h11   #8
Dut
Responsable MATLAB & Hardware/PC

 
Avatar de Dut
 
Inscription : novembre 2006
Messages : 15 072
Détails du profil
Informations personnelles :
Localisation : France

Informations forums :
Inscription : novembre 2006
Messages : 15 072
Points : 31 146
Points : 31 146
Et voici VLC2 la version de VLC qui marche avec le VLC 1.0.1 goldeneye

Code :
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
function vlc2(file,volume)
% VLC2 Display movie/sound file using VLC2 media player
%   VLC2(FILE) display movie/sound file named FILE in a new
%   Figure object.
%   VLC2(FILE,VOLUME) display movie/sound file named FILE in a
%   new Figure object with sound volume VOLUME in the 
%   range [0 100] (0:nosound, 100 full sound).
%
%   User controls avaible :
%       PLAY / PAUSE
%       STOP
%       PLAY FASTER / PLAY SLOWER
%       SHUTTLE
%       TOGGLE MUTE
%
%   Data display :
%       Elapsed Time
%       Full Time
%       Speed Ratio
%       File Name
%       Path Name
%
%   VLC2 works with VLC 1.0.1 Goldeneye
%
%   More informations about the VLC Media Player : 
%       http://www.videolan.org/vlc/
%       http://wiki.videolan.org/ActiveX_Controls   
%
%   See also vlclite2
%

%   Author: Jérôme Briot
%           http://www.developpez.net/forums/member.php?u=125006
%           http://www.mathworks.com/matlabcentral/fileexchange/loadAuthor.do?objectId=1094934&objectType=author
%   Contact: dutmatlab@yahoo.fr
%   Version: 1.0 - 19 Sep 2009
%   Comments:
%

nargchk(1,2,nargin);

if exist(file,'file')~=2
    error('Can''t read %s',file);
end

if nargin==1
    volume = 50; 
end

[pname,fname,ext]=fileparts(file);

fig = figure('units','pixels','position',[381 188 500 400],...
    'menubar','none',...
    'numbertitle','off',...
    'closerequestfcn',@crfcn);

tb = uitoolbar(fig);
X={};
parseIcons;
addbutton2toolbar;

edit(1)=uicontrol('style','edit','units','pixels','position',[0 0 75 25],'enable','inactive','hor','center',...
    'tooltipstring','Total time');
edit(2)=uicontrol('style','edit','units','pixels','position',[75 0 35 25],'enable','inactive','hor','center',...
    'tooltipstring','Elapsed time','string','x1.00');
edit(3)=uicontrol('style','edit','units','pixels','position',[110 0 390 25],'enable','inactive','string',pname,...
    'hor','left');

slider=uicontrol('style','slider','units','pixels','position',[0 25 500 25],...
    'callback',@slidfcn,...
    'sliderstep',[.01 .01]);

movegui('center');

actx = actxcontrol('VideoLAN.VLCPlugin.2', ...
    'position',[0 50 500 350], ...
	'parent',fig);

set(fig,'resizefcn',@rfcn);

vi = actx.versionInfo();
vr = version('-release');

set(fig,'name',sprintf('%s%s - VLC media player (%s) - MATLAB %s',fname,ext,vi,vr));

actx.playlist.add(file);
actx.playlist.play();

l=-inf;
while l<=0
    l=double(actx.input.length)/1000;
    pause(.01);
end

actx.audio.Volume = volume;

vitesse = 1;
mtotal=uint8(floor(l/60));
stotal=uint8(rem(l,60));
set(edit(1),'string',sprintf('00:00 / %02d:%02d',mtotal,stotal))

tim = timer('timerfcn',@timfcn,'period',1,'executionmode','fixedRate');

start(tim)

    function parseIcons
        
        bmpfiles = {'pause.bmp' 'stop.bmp' 'slower.bmp' 'faster.bmp' 'on.bmp' 'off.bmp' 'play.bmp'};
        uibgcol = uint8(255*get(0,'factoryUicontrolBackgroundColor'));
        
        for n=1:numel(bmpfiles)
           
            X{n} = imread(bmpfiles{n},'bmp');
            idx = find((X{n}(:,:,1)==212 & X{n}(:,:,2)==208 & X{n}(:,:,3)==200));
            X{n}(idx) = uibgcol(1);
            X{n}(25*25+idx) = uibgcol(2); 
            X{n}(2*25*25+idx) = uibgcol(3);
            
        end
        
    end
        
    function addbutton2toolbar

        cb = {'Pause' 'Stop' 'Slower' 'Faster' 'Sound Off'};
        
        sep={'off' 'off' 'on' 'off' 'off' 'on'};
        
        for n=1:numel(cb)

            uipushtool(tb, ...
                'cdata',X{n}, ...
                'tooltipstring',cb{n},...
                'clickedcallback',@action,...
                'tag',cb{n},...
                'separator',sep{n});

        end
     
    end

    function action(obj,event)
        
        act = get(obj,'tag');
        
        switch act
            
            case 'Stop' 
                
                stop(tim);
                actx.playlist.stop();
                delete(actx); 
                pause(.05);
                delete(fig);
                    
            case 'Pause'

                flag = actx.playlist.isPlaying;
                if flag                    
                    n = 7; 
                    cb = 'Play';
                    stop(tim);
                else                    
                    n=1; 
                    cb = 'Pause';
                    start(tim);
                end

                set(obj,'tooltipstring',cb,'cdata',X{n});                
                actx.playlist.togglePause();
                
            case 'Slower'
                
                vitesse=vitesse/2;
                if vitesse<0.125
                    vitesse=0.125;
                end

                actx.input.rate = vitesse;
                set(edit(2),'string',sprintf('x%.2f',vitesse))
                
            case 'Faster'
                
                vitesse=vitesse*2;
                if vitesse>8
                    vitesse=8;
                end
                
                actx.input.rate = vitesse;
                set(edit(2),'string',sprintf('x%.2f',vitesse))
                
            case {'Sound Off'}
                
                flag = actx.audio.mute;
                
                if flag
                   n = 5; 
                   tts = 'Sound Off';
                else
                   n = 6; 
                   tts = 'Sound On';
                end

                set(obj,'cdata',X{n},'tooltipstring',tts);
                actx.audio.toggleMute();
                
        end
                
    end    

    function timfcn(obj,event)
        
        pos=actx.input.position;
        
        if pos>1
            pos = 0;
            stop(tim);
        end
        
        t=pos*l;      
        m=uint8(floor(t/60));
        s=uint8(rem(t,60));

        set(edit(1),'string',sprintf('%02d:%02d / %02d:%02d',m,s,mtotal,stotal))
        set(slider,'value',pos)
     
    end

    function crfcn(obj,event)
        
        actx.playlist.stop();
        delete(actx);
        stop(tim);
        pause(.05);
        delete(fig);
        
    end

    function rfcn(obj,event)
        
        pos = get(obj,'position');
        move(actx,[0 50 pos(3:4)]);
        set(edit(3),'position',[110 0 pos(3)-110 25]);
        set(slider,'position',[0 25 pos(3) 25]);
    end

    function slidfcn(obj,event)
        
        t = get(obj,'value');
        
        actx.input.position = t;

        t=t*l;
        m=uint8(floor(t/60));
        s=uint8(rem(t,60));

        set(edit(1),'string',sprintf('%02d:%02d / %02d:%02d',m,s,mtotal,stotal))

    end
        
end
L'archive .zip attachée à ce message contient les fichiers suivants :
  • vlc2.m
  • faster.bmp
  • off.bmp
  • on.bmp
  • pause.bmp
  • play.bmp
  • slower.bmp
  • stop.bmp
Fichiers attachés
Type de fichier : zip vlc2.zip (6,2 Ko, 42 affichages)
__________________
Identification de processeur sous MATLAB (3/3) Identification de processeur sous MATLAB (2/3) Mes contributions MATLAB (R2009a - Windows & Linux)

J'étais le meilleur ami que le vieux Jim avait au monde. Il fallait choisir. J'ai réfléchi un moment, puis je me suis dit : "Tant pis ! J'irai en enfer" (Saint Huck)
Dut est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/09/2009, 10h07   #9
khaptain
Candidat au titre de Membre du Club
 
Inscription : juillet 2009
Messages : 29
Détails du profil
Informations personnelles :
Âge : 27
Localisation : France, Paris (Île de France)

Informations forums :
Inscription : juillet 2009
Messages : 29
Points : 13
Points : 13
Bonjour Dut!

Oui j'ai pu testé ton nouveau code mis à jours. Je me sers de fichiers AVI, MPEG et WMV avec la version 1.0.1 de VLC, et tout marche impeccablement bien

Encore un grand merci!

PS: Pour les suggestions j'en vois une seule dans mon cas, ce serait de réafficher l'icone de lecture à la fin de la vidéo, pour pouvoir la relire sans fermer la fenêtre et relancer
khaptain est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 21h54.


 
 
 
 
Partenaires

Hébergement Web