{"action":"created","issue":{"url":"https://api.github.com/repos/chris-rudmin/opus-recorder/issues/158","repository_url":"https://api.github.com/repos/chris-rudmin/opus-recorder","labels_url":"https://api.github.com/repos/chris-rudmin/opus-recorder/issues/158/labels{/name}","comments_url":"https://api.github.com/repos/chris-rudmin/opus-recorder/issues/158/comments","events_url":"https://api.github.com/repos/chris-rudmin/opus-recorder/issues/158/events","html_url":"https://github.com/chris-rudmin/opus-recorder/issues/158","id":329381342,"node_id":"MDU6SXNzdWUzMjkzODEzNDI=","number":158,"title":"iOS recording fails second time","user":{"login":"igorosabel","id":633864,"node_id":"MDQ6VXNlcjYzMzg2NA==","avatar_url":"https://avatars0.githubusercontent.com/u/633864?v=4","gravatar_id":"","url":"https://api.github.com/users/igorosabel","html_url":"https://github.com/igorosabel","followers_url":"https://api.github.com/users/igorosabel/followers","following_url":"https://api.github.com/users/igorosabel/following{/other_user}","gists_url":"https://api.github.com/users/igorosabel/gists{/gist_id}","starred_url":"https://api.github.com/users/igorosabel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/igorosabel/subscriptions","organizations_url":"https://api.github.com/users/igorosabel/orgs","repos_url":"https://api.github.com/users/igorosabel/repos","events_url":"https://api.github.com/users/igorosabel/events{/privacy}","received_events_url":"https://api.github.com/users/igorosabel/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-06-05T09:49:24Z","updated_at":"2018-06-05T15:32:28Z","closed_at":null,"author_association":"NONE","body":"Hi!\r\n\r\nI already saw an issue regarding this topic ([this](https://github.com/chris-rudmin/opus-recorder/issues/141)) , but the same thing happens to me.\r\n\r\nI've tried the example you gave there on an iPhone 6S with iOS 11.4 and it works... so I don't know where my problem is coming from.\r\n\r\nI'm using a different approach and I'd like some help as I've been stuck for days.\r\n\r\nI ask for the navigator.getUserMedia as soon as the user comes into the recording page, to test if the user has microphone, to present him with a message explaining the permission dialog... And when the user agrees with the permission I show him the recorder interface. The flow is something like this:\r\n\r\nI initialize the recorder:\r\n```\r\nvar recorder = new Recorder({\r\n  encoderPath: '/js/lib/encoderWorker.min.js',\r\n  leaveStreamOpen: true // as the user can make several recordings until he is happy with it\r\n});\r\nrecorder.ondataavailable = uploadRecording; // A function just to upload the recording\r\n```\r\nThen I ask for the getUserMedia:\r\n```\r\nnavigator.mediaDevices.getUserMedia({ audio: true })\r\n.then(onSuccess)\r\n.catch(onError);\r\n```\r\n\r\nThe onsuccess function does this:\r\n```\r\nfunction onSuccess(stream) {\r\n  var AudioContext = window.AudioContext || window.webkitAudioContext;\r\n  var audioCtx = new AudioContext();\r\n  sourceNode = audioCtx.createMediaStreamSource( stream ); // sourceNode is a global variable\r\n  recorder.stream = stream;\r\n  // ... show the recorder interface\r\n}\r\n```\r\nThe record button launches this function:\r\n```\r\nfunction startRecording(){\r\n  numRecordings++; // numRecordings is previously initialized to 0\r\n  if (numRecordings==1){\r\n    // The first time I pass the sourceNode variable as it is not initialized\r\n    recorder.start(sourceNode).catch(function(e){ console.log(e); });\r\n  }\r\n  else{\r\n    // Next times I don't pass the sourceNode since it is already initialized\r\n    recorder.start().catch(function(e){ console.log(e); });\r\n  }\r\n}\r\n```\r\n\r\nThe stop button basically does this:\r\n```\r\nfunction stopRecording(){\r\n  recorder.stop();\r\n}\r\n```\r\n\r\nIt works perfectly on Firefox (win and mac), Chrome (win and mac), Edge (win10). But on Safari (both on iOS and macOS) the second, third and so on recordings are just blank recordings.\r\n\r\nAny help? Maybe I should do things in another way?\r\n\r\nThank you very much, I think it is a great library :)\r\n\r\nIñigo"},"comment":{"url":"https://api.github.com/repos/chris-rudmin/opus-recorder/issues/comments/394754992","html_url":"https://github.com/chris-rudmin/opus-recorder/issues/158#issuecomment-394754992","issue_url":"https://api.github.com/repos/chris-rudmin/opus-recorder/issues/158","id":394754992,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NDc1NDk5Mg==","user":{"login":"igorosabel","id":633864,"node_id":"MDQ6VXNlcjYzMzg2NA==","avatar_url":"https://avatars0.githubusercontent.com/u/633864?v=4","gravatar_id":"","url":"https://api.github.com/users/igorosabel","html_url":"https://github.com/igorosabel","followers_url":"https://api.github.com/users/igorosabel/followers","following_url":"https://api.github.com/users/igorosabel/following{/other_user}","gists_url":"https://api.github.com/users/igorosabel/gists{/gist_id}","starred_url":"https://api.github.com/users/igorosabel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/igorosabel/subscriptions","organizations_url":"https://api.github.com/users/igorosabel/orgs","repos_url":"https://api.github.com/users/igorosabel/repos","events_url":"https://api.github.com/users/igorosabel/events{/privacy}","received_events_url":"https://api.github.com/users/igorosabel/received_events","type":"User","site_admin":false},"created_at":"2018-06-05T15:32:28Z","updated_at":"2018-06-05T15:32:28Z","author_association":"NONE","body":"Hi, thanks for the fast response.\r\n\r\n`The recorder will ask for mic permissions on start`\r\n\r\nThat's precissely what I am trying to avoid. When the user goes into the page, there is a message explaining that it has to click on \"allow\", a screenshot of the permission dialog... And when the user allows microphone access, I hide the message and show the recorder.\r\n\r\nSo asking for permission on start is no good for me.\r\n\r\n`Also you can pass the source node to start() instead of assigning it to the recorder instance.`\r\n\r\nThat is what I do, on the first recording click I pass the sourceNode variable to the start method, and on the next calls I just call start since it is already initialized.\r\n\r\nThanks again."}}
{"actor":{"display_login":"igorosabel"}}