kartsims / vue-cordova

Vue.js plugin for Cordova
http://kartsims.github.io/vue-cordova
328 stars 71 forks source link

Adds dB Meter plugin. #5

Closed strixy closed 7 years ago

strixy commented 7 years ago

It's an interesting little effect that uses the microphone to calculate the ambient noise levels. Let me know if this is acceptable.

kartsims commented 7 years ago

Thanks for the PR ! Yes it is probably not the most popular plugin but why not !

I think the plugin file is missing though ?..

strixy commented 7 years ago

Apologies. First timer here. So much for rookie luck!

strixy commented 7 years ago

I've added it in now.

kartsims commented 7 years ago

Thanks for the updated code

I am reviewing and testing right now

I'll probably change the example so that it reflects the usual example type and I have to update the vue-cordova-demo repository as well I'll let you know when it's done

kartsims commented 7 years ago

Your code seems OK but I can't get the demo to work, could you please help me out ? I may have missed something...

Code is here : https://github.com/kartsims/vue-cordova-demo/tree/dbmeter-plugin

Here are the steps to make it work on your setup :

Now because I haven't published to NPM yet the plugin, best would be to remove rm -rf node_modules/vue-cordova and run npm install kartsims/vue-cordova#dbmeter-plugin

Then try to build the app with npm run build and test it on your favorite platform... In my setup I didn't have anything (the number 23 should be updated with the value of db, I'll remove the hard-coded value 23)

Thanks for your feedback, it is important that the demo is fully working, that really helps newcomers

strixy commented 7 years ago

Quick note on my lunch break... I'm using Android, and haven't tested it in iOS. Totally opposite of your workflow. Everything works in Android. Are you able to access DBMeter in the global scope? I'll get the demo setup tonight after work and debug/test this as well as all the other plugins in Android so you can remove the warning about 'not testing in Android' while I'm at it. 2 birds, one stone.

strixy commented 7 years ago

Are you building with Swift 3? That might be part of the issue. The dbmeter plugin doesn't yet support swift 3.

https://github.com/akofman/cordova-plugin-dbmeter#installation

The iOS part is written in Swift so the Swift support plugin is configured as a dependency in plugin.xml.

:warning: Because this plugin doesn't support Swift 3 at the moment, the following preference has to be added in your project :

<preference name="UseLegacySwiftLanguageVersion" value="true" />

kartsims commented 7 years ago

Yes I have added this tag to config.xml but I forgot to re-prepare the ios platform (rm -rf platforms/ios and cordove prepare ios)

Now that it is done, I can't build the demo app... I get this error :

** BUILD FAILED **

The following build commands failed:
        CompileSwift normal i386 /Users/simon/dev/vue-cordova-demo/platforms/ios/VueCordovaDemo/Plugins/cordova-plugin-dbmeter/DBMeter.swift
        CompileSwiftSources normal i386 com.apple.xcode.tools.swift.compiler
(2 failures)
Error: Error code 65 for command: xcodebuild with args: -xcconfig,/Users/simon/dev/vue-cordova-demo/platforms/ios/cordova/build-debug.xcconfig,-project,VueCordovaDemo.xcodeproj,-target,VueCordovaDemo,-configuration,Debug,-sdk,iphonesimulator,-destination,platform=iOS Simulator,build,CONFIGURATION_BUILD_DIR=/Users/simon/dev/vue-cordova-demo/platforms/ios/build/emulator,SHARED_PRECOMPS_DIR=/Users/simon/dev/vue-cordova-demo/platforms/ios/build/sharedpch

I am investigating it

kartsims commented 7 years ago

Could you provide me your config.xml file ? That might help me debug better

kartsims commented 7 years ago

I tried adding <preference name="UseLegacySwiftLanguageVersion" value="true" /> both in the root tag <widget> or in the <platform name="ios">. Didn't change a thing

kartsims commented 7 years ago

OK it is working now, for some reason I had to remove the plugins/ folder and run cordova prepare again... I don't really understand why but it is OK now

I still have a problem with displaying the data, I'll let you know when it's ready

strixy commented 7 years ago

I can't help with the iOS part, but for showing data try getting at the DBMeter in the global scope first. See if this works.

Example:

<template>
  <div>
    <div id="level">{{ meterLevel }}dB</div>
  </div>
<template>
export default {
  data () {
    return {
      meterLevel: 40
    };
  },
  mounted () {
    if("DBMeter" in window){
        DBMeter.start(function(dB){
          this.$set(this, 'meterLevel', ave);
        }.bind(this));
    }
  }
};
strixy commented 7 years ago

Hey @kartsims where are we on this PR? What do I need to do to get this closed?

kartsims commented 7 years ago

I can't get the demo working and I don't know why...

https://github.com/kartsims/vue-cordova-demo/tree/dbmeter-plugin

I won't merge this until demo is working, users really like to have a fully working demo.

kartsims commented 7 years ago

@strixy want to get this merged or should I close it ?