Précédent   Forum des professionnels en informatique > Webmasters - Développement Web > Flash/Flex > Flex
Flex Forum d'entraide sur la programmation Adobe Flex : applications Internet riches (RIA)
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 06/06/2011, 15h11   #1
Invité régulier
 
Homme
Étudiant
Inscription : mai 2011
Messages : 12
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France

Informations professionnelles :
Activité : Étudiant

Informations forums :
Inscription : mai 2011
Messages : 12
Points : 6
Points : 6
Par défaut Relire un enregistrement vidéo à la place du flux webcam

Bonjour à tous et toutes.

J'ai créé un projet sous flex et red5 qui permet d'enregistrer une vidéo depuis la webcam en streaming puis de l'envoyer sur le serveur pour la sauvegarder.

Cependant, je cherche à pouvoir relire la vidéo que je viens de faire dans le cadre de ma webcam, autrement dis à la place du flux de la webcam avant de l'envoyer sur mon serveur.

Si jamais un ou une d'entre vous avez une petite idée, elle sera la bienvenue surtout vu le peu de temps qu'il me reste pour y parvenir.

à vous.

Je vous fais parvenir mon code :

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
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
			   xmlns:s="library://ns.adobe.com/flex/spark" 
			   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
			   creationComplete="init()">
 
	<fx:Script>
		<![CDATA[
			/**
			 * 
			 * Script pour la gestion de la caméra depuis le serveur red5.
			 *  
			 */
 
			import mx.controls.Alert;
 
			private var _resolutionWidth:int = 1024;
			private var _resolutionHeight:int = 960;
			private var _fps:int = 24;
			private var _cameraQuality:int = 100;
 
			private var _netConnect:NetConnection;
			private var _netStream:NetStream;
			private var _webcam:Camera;
			private var _mic:Microphone;
			private var _video:Video;
 
			/**
			 * Initialise la caméra avec le server red5
			 */
			public function init():void{
 
				/**
				 * Connection
				 */
				this._read.visible = false;
				this._netConnect = new NetConnection();		// Instanciation d'une nouvelle connection
				this._netConnect.connect("rtmp://localhost/oflaDemo");
				this._netConnect.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
				this._netConnect.client = this;
 
			}
 
 
			/**
			 * Stopper l'enregistrement de la caméra 
			 * @param event
			 */
			public function stop(event:Event):void{
				Alert.show('Stop call');
			}
 
			public function onNetStatus(event:NetStatusEvent):void {
				 if ( event.info.code == "NetConnection.Connect.Success" ) {
					 this._webcam = Camera.getCamera();
					 this._webcam.setMode(this._resolutionWidth,this._resolutionHeight,this._fps,true);
					 this._webcam.setQuality(0,this._cameraQuality);
					 this._mic = Microphone.getMicrophone();
					 this._netStream = new NetStream(this._netConnect);
					 this._netStream.attachCamera(this._webcam);
					 this._netStream.attachAudio(this._mic);
					 this._videoDisplay.attachCamera(this._webcam);
 
				 }
				 else{
				 	Alert.show('Error');
				 }
 			}
 
 
			public function publishCamera(e:Event):void {
				 if (this._rec.label=="Enregistrer") {
					 this._rec.label="Stopper";
					 this._netStream.publish("enregistrement", "record");
				 } else {
				 	this._netStream.close();
				 	this._videoDisplay.stop();
				 	this._read.visible = true;
			     	this._rec.visible=false;
 
				 }
 			}
 
 			public function displayPublishingVideo(e:Event):void {
 
 			}
 
			public function onBWDone():void {}
 
			public function isEnd():void{
				Alert.show('Fini');
			}
 
		]]>
	</fx:Script>
 
	<s:Panel width='322' height='275'>
		<mx:VideoDisplay id="_videoDisplay" width="320" height="240"/>
		<s:controlBarContent>
			<s:Button label="Enregistrer" id='_rec' height="35" click='publishCamera(event)'/>
			<s:Button label="Lire" id="_read" height="35" click="displayPublishingVideo(event)" />
		</s:controlBarContent>
 
 
	</s:Panel>
 
 
</s:Application>
iziitoms est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 10/06/2011, 16h40   #2
Invité régulier
 
Homme
Étudiant
Inscription : mai 2011
Messages : 12
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France

Informations professionnelles :
Activité : Étudiant

Informations forums :
Inscription : mai 2011
Messages : 12
Points : 6
Points : 6
J'ai trouvé la solution. Je vous partage la fonction qui me permet de relire la vidéo à la place du flux webcam.

Code :
1
2
3
4
5
6
7
	public function displayPublishingVideo(e:Event):void {
 				this._videoDisplay.removeChild(this._video);
 				this._lecteur = new Video(400,320);
 				this._lecteur.attachNetStream(this._netStream);
				this._netStream.play(this._parrain);
				this._videoDisplay.addChild(this._lecteur);
 			}
Alors:
_videoDisplay est un objet videoDisplay qui contient l'objet _video.
_video est un objet video qui contient le flux de la webcam(via netstream).
_lecteur est un autre objet video qui contient lui la vidéo qui a été enregistrée.

En espérant que ça puisse servir.

Merci à vous de votre lecture de mon post
iziitoms est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 19h02.


 
 
 
 
Partenaires

Hébergement Web