質問するログイン新規登録

質問編集履歴

3

タイトルの修正

2015/06/28 06:46

投稿

webri
webri

スコア19

title CHANGED
@@ -1,1 +1,1 @@
1
- MediaRecorderで取得したBlobPHPで受け取
1
+ MediaRecorderで取得したBlobPHPで受け取れない
body CHANGED
File without changes

2

MediaRecorderで取得したBlobがPHPで受け取れない

2015/06/28 06:46

投稿

webri
webri

スコア19

title CHANGED
File without changes
body CHANGED
File without changes

1

コードの改善

2015/06/28 06:46

投稿

webri
webri

スコア19

title CHANGED
File without changes
body CHANGED
@@ -25,6 +25,11 @@
25
25
  <script>
26
26
  var video1 = document.getElementById('video1');
27
27
  var my_stream = null;
28
+
29
+ navigator.getUserMedia = ( navigator.getUserMedia ||
30
+ navigator.webkitGetUserMedia ||
31
+ navigator.mozGetUserMedia ||
32
+ navigator.msGetUserMedia);
28
33
  var mediaConstraints = {
29
34
  video: true
30
35
  };
@@ -39,21 +44,41 @@
39
44
 
40
45
  var recorder = null;
41
46
  function startRecording() {
47
+ // MediaStreamRecorder
42
48
  recorder = new MediaStreamRecorder(my_stream);
43
-
44
49
  recorder.mimeType = 'video/webm';
45
50
  recorder.ondataavailable = function(blob) {
46
- var fileName = 'test.webm';
47
- var fileType = 'video';
48
51
  var formData = new FormData();
49
- formData.append(fileType + '-filename', fileName);
52
+ formData.append('filename', 'test.webm');
50
- formData.append(fileType + '-blob', blob);
53
+ formData.append('blob', blob);
51
54
 
52
55
  xhr('upload.php', formData, function (data) {
53
56
  console.log(data);
54
57
  });
55
58
  }
56
59
 
60
+ // MediaRecorder (in Firefox)
61
+ /*
62
+ recorder = new MediaRecorder(my_stream);
63
+ recorder.mimeType = 'video/webm';
64
+ recorder.ondataavailable = function(evt) {
65
+ var formData = new FormData();
66
+ formData.append('filename', 'test.webm');
67
+ formData.append('blob', new Blob([evt.data], { type: evt.data.type }));
68
+
69
+ $.ajax({
70
+ type: 'POST',
71
+ url: '/upload.php',
72
+ data: formData,
73
+ processData: false,
74
+ contentType: false,
75
+ success: function(data) {
76
+ console.log(data);
77
+ },
78
+ });
79
+ }
80
+ */
81
+
57
82
  // 録画開始
58
83
  recorder.start(1000 * 5);
59
84
  }