triniwiz / nativescript-videorecorder

:video_camera: NativeScript plugin for Video Recording . :video_camera:
Apache License 2.0
43 stars 29 forks source link

recorder.on('finished') not always called. #62

Closed mrwrighty closed 4 years ago

mrwrighty commented 5 years ago

Which platform(s) does your issue occur on?

Please, provide the following version numbers that your issue occurs with:

Take or retake video does not always call:

recorder.on('finished', args => { clearInterval(interval); var vidfile = args.object.get('file'); alert(vidfile); page.bindingContext.set('selectedVideo', args.object.get('file')); appSettings.setString("vidfile", vidfile); durationlabel.text = "Video Length "+recorder.duration+" Secs"; });

Is there any code involved?

`"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var appSettings = require("tns-core-modules/application-settings"); var dialogs = require("tns-core-modules/ui/dialogs"); var main_view_model_1 = require("./video-view-model"); //var nativescript_videorecorder_1 = require("nativescript-videorecorder"); var Advanced_1 = require("nativescript-videorecorder/advanced"); var frame_1 = require("tns-core-modules/ui/frame"); var progress = require("tns-core-modules/ui/progress"); var page; var recorder; var interval; var videoplayer; var stoprecordingbutton; var recordvideobutton; var completesigninbutton; var retakevideobutton; var recorderstack; var completestack; var durationlabel; var vm = new main_view_model_1.HelloWorldModel(); function navigatingTo(args) {

} exports.navigatingTo = navigatingTo;

function loaded(args) { page = args.object; page.bindingContext = vm; vm.set('selectedVideo', ''); appSettings.setString("vidfile",""); appSettings.setNumber("duration", 0); Advanced_1.AdvancedVideoView.requestPermissions(); recorder = args.object.page.getViewById("recorderView"); vm.set('duration', recorder && recorder.duration ? recorder.duration : 0); // vm.set('duration', recorder && recorder.duration ? recorder.duration : appSettings.getNumber("duration")); recorder.on('started', args => { interval = setInterval(() => { vm.set('duration', recorder.duration); // if (recorder.duration > 9){ //Set to 44 for maximum 45 seconds of video // clearInterval(interval); // // alert("You have reached the 45 second video limit");
// stoprecordingbutton.notify({eventName: "tap", object: stoprecordingbutton});
// } }, 1000); }); recorder.on('finished', args => { clearInterval(interval); var vidfile = args.object.get('file'); alert(vidfile); page.bindingContext.set('selectedVideo', args.object.get('file')); appSettings.setString("vidfile", vidfile); durationlabel.text = "Video Length "+recorder.duration+" Secs"; }); videoplayer = args.object.page.getViewById("videoplayer"); videoplayer.className="hideObject"; recorder.className="showObject"; stoprecordingbutton = args.object.page.getViewById("stoprecordingbutton"); recordvideobutton = args.object.page.getViewById("recordvideobutton"); retakevideobutton = args.object.page.getViewById("retakevideobutton"); durationlabel = args.object.page.getViewById("durationlabel"); durationlabel.class = "showObject"; completestack = args.object.page.getViewById("completestack"); completestack.className="hideObject"; recorderstack = args.object.page.getViewById("recorderstack"); recorderstack.className="showObject"; } exports.loaded = loaded;

function recordVideo(){ // var duration = appSettings.getNumber("duration"); // if (duration >= 0 ){ // dialogs.confirm({ // title: "Warning", // message: "Are you sure you want to retake the video!", // okButtonText: "Yes", // cancelButtonText: "No" // }).then(function (result){; // if (result == false) { // return; // } // else { videoplayer.className="hideObject"; recordvideobutton.isEnabled=false; recordvideobutton.className="fadeObject"; recorder.startRecording(); //} // }); // } } exports.recordVideo = recordVideo;

function retakeVideo(args){ var duration = appSettings.getNumber("duration"); if (duration >= 0 ){ dialogs.confirm({ title: "Warning", message: "Are you sure you want to retake the video?\nIf Yes, the video will start recording after dismissing this messaage.", okButtonText: "Yes", cancelButtonText: "No" }).then(function (result){; if (result == false) { return; } else { vm.set('duration', 0); appSettings.setNumber("duration",0); recorder.className="showObject"; videoplayer.className="hideObject"; recorderstack = args.object.page.getViewById("recorderstack"); completestack = args.object.page.getViewById("completestack"); durationlabel = args.object.page.getViewById("durationlabel"); //durationlabel.class = "showObject"; //durationlabel.class="videotime"; durationlabel.text = "Video Length 0 Secs"; recorderstack.className="showObject"; completestack.className="hideObject"; page.bindingContext.set('selectedVideo', ''); videoplayer.className="hideObject"; recordvideobutton.isEnabled=false; recordvideobutton.className="fadeObject"; recorder.startRecording(); } }); }
} exports.retakeVideo = retakeVideo;

function stopRecording(args){ // if (recorder.duration > 4){ recorder.stopRecording(); appSettings.setNumber("duration", recorder.duration); recorder = args.object.page.getViewById("recorderView"); recorderstack = args.object.page.getViewById("recorderstack"); completestack = args.object.page.getViewById("completestack"); //durationlabel = args.object.page.getViewById("durationlabel"); //durationlabel.text = "Video Length "+recorder.duration+" Secs"; //durationlabel.class = "hideObject"; recordvideobutton.isEnabled = true; recordvideobutton.className="unfadeObject"; retakevideobutton = args.object.page.getViewById("retakevideobutton"); retakevideobutton.isEnabled = true; recorder.className="hideObject"; videoplayer.className="showObject"; recorderstack.className="hideObject"; completestack.className="showObject";

// } } exports.stopRecording = stopRecording;

function goToVideoRecorder(event){ frame_1.goBack(); } exports.goToVideoRecorder = goToVideoRecorder;

function saveVideo(){ var vidfile = appSettings.getString("vidfile"); if (vidfile == ""){ dialogs.confirm({ title: "Warning", message: "You must take a video of the vehicle to complete the sign in process!", okButtonText: "OK", }); return; } const movetosigninloc = { moduleName: "signinloc/signinloc-page", animated: true, clearHistory: false, transition: { name: "flip", duration: 380, curve: "easeIn" } }; frame_1.topmost().navigate(movetosigninloc); } exports.saveVideo = saveVideo;`

mrwrighty commented 5 years ago

this is very unpredictable, sometimes I can record and retake up to 10 or more videos then it hangs, sometimes it hangs after one video. Once it is hung and I try to stop video I get the following error:-

Apr 16 11:03:02 iPhone-5c myRecorder(NativeScript)[510] : 31 0xee99d5 JSC::JSModuleLoader::evaluate(JSC::ExecState*, JSC::JSValue, JSC::JSValue, JSC::JSValue) Apr 16 11:03:02 iPhone-5c myRecorder(NativeScript)[510] : JavaScript stack trace: Apr 16 11:03:02 iPhone-5c myRecorder(NativeScript)[510] : 1 copyCGImageAtTimeActualTimeError@file:///app/tns_modules/nativescript-videorecorder/advanced/advanced-video-view.js:253:772 extractThumbnails@file:///app/tns_modules/nativescript-videorecorder/advanced/advanced-video-view.js:253:77 Apr 16 11:03:02 iPhone-5c myRecorder(NativeScript)[510] : JavaScript error: Apr 16 11:03:02 iPhone-5c myRecorder(NativeScript)[510] : file:///app/tns_modules/nativescript-videorecorder/advanced/advanced-video-view.js:253:77: JS ERROR NSErrorWrapper: The requested URL was not found on this server. Apr 16 11:03:02 iPhone-5c myRecorder(NativeScript)[510] : Fatal JavaScript exception - application has been terminated. Apr 16 11:03:02 iPhone-5c myRecorder(NativeScript)[510] : Native stack trace: Apr 16 11:03:02 iPhone-5c myRecorder(NativeScript)[510] : 1 0xe13ecf NativeScript::reportFatalErrorBeforeShutdown(JSC::ExecState, JSC::Exception, bool)

Also get the following error:

Apr 16 11:22:49 iPhone-5c mediaserverd(AudioToolbox)[42] : 194: AQME device AQDefaultDevice: client starting: <RemoteIOClient@0x1640d400(@0x1640d448); input; sid:0x2a760, myRecorder(536), 'prim'>; running count now 1 Apr 16 11:22:49 iPhone-5c mediaserverd(CoreMedia)[42] : -CMSessionMgr- cmsSetDiscoveryMode: CMSession: 'FigAssetImageGeneratorServer' com.codeworx.myRecorder(pid = 536) requesting to set the discovery mode to DiscoveryMode_None Apr 16 11:22:50 iPhone-5c watchlistd[125] : Now playing app did change to 'com.codeworx.myRecorder' (playing: 1) from '(null)' Apr 16 11:22:52 iPhone-5c myRecorder(CFNetwork)[536] : TIC TCP Conn Cancel [2:0x195991e0] Apr 16 11:22:52 iPhone-5c myRecorder(NativeScript)[536] : CONSOLE LOG file:///app/tns_modules/nativescript-videoplayer/videoplayer.js:49:20: set native player source! Apr 16 11:22:52 iPhone-5c myRecorder(CFNetwork)[536] : NSURLConnection finished with error - code -1002 Apr 16 11:22:52 iPhone-5c mediaserverd(AudioToolbox)[42] : 4030: sid:0x2a760, myRecorder(536), 'prim', playerref=0x16b9c400, modes=Output(2), state=Stopped Apr 16 11:22:54 iPhone-5c myRecorder(NativeScript)[536] : CONSOLE LOG file:///app/main/main-view-model.js:39:24: [eveactivitychangent] - still 0 Apr 16 11:22:59 iPhone-5c mediaserverd(AudioToolbox)[42] : 376: AQME device AQDefaultDevice: client stopping: <RemoteIOClient@0x1640d400(@0x1640d448); input; sid:0x2a760, myRecorder(536), 'prim'>; running count now 0 Apr 16 11:22:59 iPhone-5c mediaserverd(AudioToolbox)[42] : 4030: sid:0x2a760, myRecorder(536), 'prim', playerref=0x1640d400, modes=Input(1), state=Stopped Apr 16 11:22:59 iPhone-5c mediaserverd(CoreMedia)[42] : -CMSessionMgr- cmsSetIsPlaying: CMSession: 'sid:0x2a760, myRecorder(536), 'prim'' with category/mode PlayAndRecord_NoBluetooth_DefaultToSpeaker/VideoRecording stopping playing Apr 16 11:22:59 iPhone-5c mediaserverd(CoreMedia)[42] : -CMSessionMgr- _CMSessionSetProperty: CMSession: Client sid:0x2a760, myRecorder(536), 'prim' has stopped recording Apr 16 11:22:59 iPhone-5c mediaserverd(CoreMedia)[42] : -CMSessionMgr- cmsSetIsActive: CMSession: 'sid:0x2a760, myRecorder(536), 'prim'' with category/mode PlayAndRecord_NoBluetooth_DefaultToSpeaker/VideoRecording going inactive Apr 16 11:22:59 iPhone-5c myRecorder(AVFAudio)[536] : AVAudioSession.mm:338:HandleRouteChange: Posting AVAudioSessionRouteChangeNotification. Reason: 3 Apr 16 11:23:00 iPhone-5c watchlistd[125] : Now playing app did change to 'com.codeworx.myRecorder' (playing: 0) from '(null)' Apr 16 11:23:01 iPhone-5c myRecorder(NativeScript)[536] : Fatal JavaScript exception - application has been terminated. Apr 16 11:23:01 iPhone-5c myRecorder(NativeScript)[536] : Native stack trace: Apr 16 11:23:01 iPhone-5c myRecorder(NativeScript)[536] : 1 0xe8cecf NativeScript::reportFatalErrorBeforeShutdown(JSC::ExecState, JSC::Exception, bool) Apr 16 11:23:01 iPhone-5c myRecorder(NativeScript)[536] : 2 0xeb7c63 NativeScript::FFICallback::ffiClosureCallback(ffi_cif, void, void, void) Apr 16 11:23:01 iPhone-5c myRecorder(NativeScript)[536] : 3 0x1512d79 ffi_closure_inner_SYSV Apr 16 11:23:01 iPhone-5c myRecorder(NativeScript)[536] : 4 0x15140b8 ffi_closure_SYSV Apr 16 11:23:01 iPhone-5c myRecorder(NativeScript)[536] : 5 0x21da21ff Apr 16 11:23:01 iPhone-5c myRecorder(NativeScript)[536] : 6 0x21da2233 Apr 16 11:23:01 iPhone-5c myRecorder(NativeScript)[536] : 7 0x1ab19797 Apr 16 11:23:01 iPhone-5c myRecorder(NativeScript)[536] : 8 0x1ab19783 Apr 16 11:23:01 iPhone-5c myRecorder(NativeScript)[536] : 9 0x1ab1dd05 _dispatch_main_queue_callback_4CF Apr 16 11:23:01 iPhone-5c myRecorder(NativeScript)[536] : 10 0x1b407d69 Apr 16 11:23:01 iPhone-5c myRecorder(NativeScript)[536] : 11 0x1b405e19 Apr 16 11:23:01 iPhone-5c myRecorder(NativeScript)[536] : 12 0x1b3591af CFRunLoopRunSpecific Apr 16 11:23:01 iPhone-5c myRecorder(NativeScript)[536] : 13 0x1b358fd1 CFRunLoopRunInMode Apr 16 11:23:01 iPhone-5c myRecorder(NativeScript)[536] : 14 0x1cb03b41 GSEventRunModal Apr 16 11:23:01 iPhone-5c myRecorder(NativeScript)[536] : 15 0x206e1a53 UIApplicationMain Apr 16 11:23:01 iPhone-5c myRecorder(NativeScript)[536] : 16 0x151402c ffi_call_SYSV Apr 16 11:23:01 iPhone-5c myRecorder(NativeScript)[536] : 17 0x1512aa7 ffi_call Apr 16 11:23:01 iPhone-5c myRecorder(NativeScript)[536] : 18 0xe5e675 NativeScript::FunctionWrapper::call(JSC::ExecState) Apr 16 11:23:01 iPhone-5c myRecorder(NativeScript)[536] : 19 0x1511e93 llint_entry Apr 16 11:23:01 iPhone-5c myRecorder(NativeScript)[536] : 20 0x1511621 llint_entry Apr 16 11:23:01 iPhone-5c myRecorder(NativeScript)[536] : 21 0x1511621 llint_entry Apr 16 11:23:01 iPhone-5c myRecorder(NativeScript)[536] : 22 0x150b311 vmEntryToJavaScript Apr 16 11:23:01 iPhone-5c myRecorder(NativeScript)[536] : 23 0x136dd1f JSC::Interpreter::executeCall(JSC::ExecState, JSC::JSObject, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) Apr 16 11:23:01 iPhone-5c myRecorder(NativeScript)[536] : 24 0x14d82d1 JSC::call(JSC::ExecState, JSC::JSValue, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&, WTF::NakedPtr&) Apr 16 11:23:01 iPhone-5c myRecorder(NativeScript)[536] : 25 0xe71b7d NativeScript::GlobalObject::moduleLoaderEvaluate(JSC::JSGlobalObject, JSC::ExecState, JSC::JSModuleLoader, JSC::JSValue, JSC::JSValue, JSC::JSValue) Apr 16 11:23:01 iPhone-5c myRecorder(NativeScript)[536] : 26 0xf629d5 JSC::JSModuleLoader::evaluate(JSC::ExecState, JSC::JSValue, JSC::JSValue, JSC::JSValue) Apr 16 11:23:01 iPhone-5c myRecorder(NativeScript)[536] : 27 0xf64a35 JSC::moduleLoaderEvaluate(JSC::ExecState) Apr 16 11:23:01 iPhone-5c myRecorder(NativeScript)[536] : 28 0x1511da3 llint_entry Apr 16 11:23:01 iPhone-5c myRecorder(NativeScript)[536] : 29 0x1511621 llint_entry Apr 16 11:23:01 iPhone-5c myRecorder(NativeScript)[536] : 30 0x1511621 llint_entry Apr 16 11:23:01 iPhone-5c myRecorder(NativeScript)[536] : 31 0x150b311 vmEntryToJavaScript Apr 16 11:23:01 iPhone-5c myRecorder(NativeScript)[536] : JavaScript stack trace: Apr 16 11:23:01 iPhone-5c myRecorder(NativeScript)[536] : 1 captureOutputDidFinishRecordingToOutputFileAtURLFromConnectionsError@file:///app/tns_modules/nativescript-videorecorder/advanced/advanced-video-view.js:20:322 UIApplicationMain@[native code] Apr 16 11:23:01 iPhone-5c myRecorder(NativeScript)[536] : JavaScript error: Apr 16 11:23:01 iPhone-5c myRecorder(NativeScript)[536] : file:///app/tns_modules/nativescript-videorecorder/advanced/advanced-video-view.js:20:32: JS ERROR TypeError: undefined is not an object (evaluating 'this._owner.get') Apr 16 11:23:01 iPhone-5c myRecorder[536] : ** JavaScript call stack:( Apr 16 11:23:01 iPhone-5c myRecorder(CoreFoundation)[536] : Terminating app due to uncaught exception 'NativeScript encountered a fatal error: TypeError: undefined is not an object (evaluating 'this._owner.get') at Apr 16 11:23:01 iPhone-5c mediaserverd(AudioToolbox)[42] : 94: sid:0x2a760, myRecorder(536), 'prim'

I have changed the name of the App to myRecorder as I don't want this detail published at the moment.

Tronix117 commented 5 years ago

Got the same issue, only solution I found was reverting to tns-ios@5.1.1

mrwrighty commented 5 years ago

Got the same issue, only solution I found was reverting to tns-ios@5.1.1

Thanks Tronix117, very frustrating that the developer has failed to respond to requests for support. He has a good product and I've yet to find an alternative, but bugs like this drive me crazy.

Tronix117 commented 5 years ago

Yes @triniwiz has good stuff, but maybe too much, and he is alone on those, so support is kind of eratic... But he is open to Pull Requests ;)

triniwiz commented 5 years ago

I'll look into this and as @Tronix117 I have a lot of stuff to maintain so any pr will be appreciated ❤️

mreall commented 4 years ago

@mrwrighty I'm having similar issues right now where the "finished" event isn't triggered after I call .stopRecording(). Did you figure out a workaround?