Solved – Unable to retrieve audio/video file recorded and saved in Ionic 2 App

AgilizTech works on exciting web and mobile app projects for customers around the globe. We develop both native and hybrid apps for our customers.

Recently, while building a hybrid app on the Ionic 2 Framework, our developers encountered an issue in coding an audio/video file record and retrieval. The initial functionality seemed simple, but that’s where Cordova threw spanner in the works. We had researched extensively online and weren’t able to find any solution. So, when our developers toiled for a few hours, and successfully solved it, we decided to share the solution and let others benefit from it.

For this project, our team had used the Cordova plugin – cordova-plugin-media-capture. This plugin provides access to the device’s audio, image, and video capture capabilities.

It is super easy to use. So, to record a video, we used the code:


navigator.device.capture.captureVideo(
	(result) => {
		console.log(result);
		console.log(“Video captured Successfully”);
		// Your code goes here.
	} ,
	(error) => {
		console.log(error);
		console.log(“Video captured failed”);
	}
);

Everything looked pretty simple. The video was getting recorded using the device’s recording application. On Android, the code worked like a charm. However, the team ran into issues in the iOS device, as the saved file was not getting played.

While debugging the issue, we observed the Media Capture object in captureSuccess.
In Android, the file was getting stored in a persistent location, so the code worked fine when we tried to retrieve the saved file.

But in iOS device, the file got stored in a temporary location!
Result, we were unable to play the saved file in the application.

Solution?

Once we figured out the issue, the solution was simple. We just had to copy the file from this temporary location to a persistent location.

We chose a persistent location that covered both Android and iOS. The File plugin provided such an alias: cordova.file.dataDirectory

navigator.device.capture.captureVideo(
	(result) => {
	  console.log(“Video captured Successfully”);
	  var fileName = result[0].name;
	  var dir = result[0].localURL.split(“/”);
	  dir.pop();
	  var fromDirectory = dir.join(“/”);
	  var toDirectory = cordova.file.dataDirectory;
	  File.copyFile (fromDirectory , fileName , toDirectory , fileName).then( res =>{
			console.log(“File successfully copied”);
			// Your code goes here.
		});
     	  } ,
	(error) => {
		console.log(error);
		console.log(“Video captured failed”);
	}
);

Everything fell into place after that.

Summarising, to make the recording and retrieval possible, just save the file in a persistent location that’s common to both Android and iOS.

Have you faced a similar issue while building an app in Ionic 2? Do let us know in the comments!

AgilizTech is working on some pretty cool Hybrid Apps powered by Ionic 2. Would you like to know more?

Contact Us

Guess who turned two? Inside AgilizTech’s Second Anniversary Bash

Birthdays are always special, right? There’s cake, party hats, streamers and an endless stream of friendly banter. Age is just a number, and all that matters are the precious memories created and shared with the ones you love. On Saturday, Jun 10, 2017, AgilizTech turned two. Since we are a bunch of early birds (and had weekend plans we couldn’t sneak out of), we decided to celebrate it on Friday, at the office premises.

While the event started on a formal note, with a brief introduction from Ganesh, CEO AgilizTech, it steadily took on a celebratory mood. We had an employee-made 7-minute short film, a rather creative way of showcasing AgilizTech’s journey from its infancy till now. The video effectively depicted how a start-up of two transformed into today’s 30+ strong team. The air was filled with nostalgia and cheers as the video rolled to an end.

AgilizTech's Second Anniversary Bash

Ganesh then took us through the present status of AgilizTech in terms of new logo wins, ongoing projects and successfully completed ones, providing everyone a platform to give feedback and learn more about the inner workings of the organization. Also, he presented the next set of goals AgilizTech will undertake to sustain its growth momentum, while in our third year of operation. The goals were three-fold.

  • Increase employee and customer experience

Promoting an employee-first approach to ensure that employees, who are the business’ prime ambassadors, have an enriched work atmosphere, thereby contributing to higher levels of customer satisfaction.

  • Focus on New Customer Acquisitions

Helping more businesses in newer markets and different industries to deliver superior customer experiences, by developing top-notch digital solutions.

  • Strive to be Agile and Lean in Delivery

Ensure faster delivery of high-quality solutions that are adaptive to customer’s changing expectations.

AgilizTech’s fun committee then took over the proceedings to distribute the personalized motivation cards. These cards consisted of the individual achievements and goals for each employee, with quirky and customized designs. Each team lead was asked to hand over the cards to the members, with a few words on how their work contributes to AgilizTech’s work environment and the company goals. Yes, the CEO got one too!

Can a celebration ever be complete without a cake being cut? Of course not! And so, we got to devour on White Forest deliciousness.

AgilizTechs Second Anniversary Bash

AgilizTech may have just turned two, but we have covered hundreds of miles in our journey towards business excellence and exceptional customer experience. And there are a thousand more miles, with each step taking us forward on the path to success. On this occasion, our many thanks to all our well-wishers who have made our journey a memorable one with their constant support.

Here’s to newer summits and exciting opportunities that the future beholds.

 

AgilizTech Turns Two

AgilizTech Turns Two!

A journey of a thousand miles starts with a single step.

On June 10, 2017, AgilizTech’s journey reached an important milestone, as we completed two years and stepped into our third. What started as an idea has now attained fruition as a successful, upcoming IT services company that delivers top-notch digital solutions and helps businesses provides superior customer experiences.

The year that was…

Over the past year we have had much to cheer for – be it our forays into new markets, new logo wins, awards and recognitions from various industry quarters. Here’s a brief snapshot of our key achievements in 2016:

  • Became a NASSCOM Member
  • Opened office in US to facilitate market expansion
  • Listed among the Top 25 Agile Service Providers in APAC region
  • Named among the Top 10 Most Valuable IT Service Providers
  • Received the Future of India Award for Business Excellence in Technology
  • Adjudged Best SME – Technology

What’s next for AgilizTech?

We have had a successful run so far and in order to sustain this growth momentum, we’ve identified the following as the key focus areas:

  • Increase Employee & Customer Experience
  • Focus on New Customer Acquisitions
  • Strive to be Agile & Lean in Delivery

We have newer summits to conquer and higher altitudes to reach. And we are sure that with the continued support of all our friends and well-wishers, we will cross many more milestones successfully.