Gracenote (GNSDK) on Android Wear

别等时光非礼了梦想. 提交于 2019-12-11 19:27:15

问题


I'm trying to develop an Android Wear app that can identify songs with Gracenote's GNSDK. I'm building upon their sample app.

I'm having trouble with the Wifi on the wearable device. The sample app is working in terms of a song identification attempt but misses an internet connection. (Although other apps work perfectly.)

So what happens: When the watch is in Wifi and not connected to the phone via bluetooth but solely via Wifi it works. Now connecting the phone to the watch via bluetooth the watch is supposed to connect to Wifi through the phone. And now a connection is no longer available. So identifying through the phone's internet is not working. Does anybody have a clue what can be the reason and how to troubleshoot?

If not:

Is there a way to, instead of making a full album identification via GnMic, grab only the fingerprint from the GnMusicIDStream object? And if so, how? The idea behind it is to listen to a song via GnMic on the wearable device, grab only the fingerprint and then send it to the mobile device. There, identify the song by doing an identification based on the fingerprint and send the result back on the watch.

Hope one of you has an idea how to solve the problem! Many thanks in advance! Any help is appreciated!

Best, dmkscr


回答1:


Due to limitations with accessing the internet directly from a Wear device, you must pass either raw audio bytes or a fingerprint to the handheld device via the DataItem or MessageApi. (See https://developer.android.com/training/wearables/data-layer/index.html for information on these Wear APIs.) Then, on the device you can produce a fingerprint and/or submit a MusicID query. You then need to again use the DataItem or MessageApi to pass result data back to the Wear device for display.

With either approach (passing audio bytes or a fingerprint to the handheld), you need to work with the GnMusicId class instead of GnMusicIdStream. The reason is that GnMusicIdStream automates multiple steps of workflow (capture audio, produce a fingerprint, perform a MusicID query based on the fingerprint), and doesn¹t provide hooks for performing them separately. GnMusicId is a lower level class that gives you more fine-grained control of this process.

If you choose to pass the audio data to the handheld, you can get the audio bytes on the Wear device using GnMic.getData(). Pass the audio data bytes to the handheld via DataItem or MessageApi. Then, on the handheld, use the following methods of GnMusicId to produce a fingerprint and perform a MusicID query:

  • fingerprintBegin(GnFingerprintType fpType, long audioSampleRate, long audioSampleSize, long audioChannels)
  • fingerprintWrite(byte[] audioData, long audioDataSize)
  • fingerprintEnd()
  • fingerprintDataGet()
  • findAlbums(java.lang.String fingerprintData, GnFingerprintType fpType)

Optionally, if you choose to generate the fingerprint on the Wear device, do the following

  • Call GnMusicId.fingerprintFromSource(IGnAudioSource audioSource, GnFingerprintType fpType) to generate the fingerprint, using an instance of GnMic as the IGnAudioSource.
  • Get the fingerprint data via GnMusicId.fingerprintDataGet()
  • Pass the fingerprint data to the handheld via DataItem or MessageApi
  • On the handheld, call GnMusicId.findAlbums(java.lang.String fingerprintData, GnFingerprintType fpType)


来源:https://stackoverflow.com/questions/31000227/gracenote-gnsdk-on-android-wear

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!