企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
下面总结一下媒体扫描的工作流程,它并不复杂,就是有些绕,如图10-2所示: :-: ![](http://img.blog.csdn.net/20150802165346186?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center) 图10-2 MediaScanner扫描流程图 通过上图可以发现,MS扫描的流程还是比较清晰的,就是四渡赤水这一招,让很多初学者摸不着头脑。不过读者千万不要像我当初那样,觉得这是垃圾代码的代表。实际上这是码农有意而为之,在MediaScanner.java中通过一段比较详细的注释,对整个流程做了文字总结,这段总结非常简单,这里就不翻译了。 **MediaScanner.java** ~~~ //前面还有一段话,读者可自行阅读。下面是流程的文件总结。 * In summary: * JavaMediaScannerService calls * JavaMediaScanner scanDirectories, which calls * JavaMediaScanner processDirectory (native method), which calls * nativeMediaScanner processDirectory, which calls * nativeMyMediaScannerClient scanFile, which calls * JavaMyMediaScannerClient scanFile, which calls * JavaMediaScannerClient doScanFile, which calls * JavaMediaScanner processFile (native method), which calls * nativeMediaScanner processFile, which calls * nativeparseMP3, parseMP4, parseMidi, parseOgg or parseWMA, which calls * nativeMyMediaScanner handleStringTag, which calls * JavaMyMediaScanner handleStringTag. * OnceMediaScanner processFile returns, an entry is inserted in to the database. ~~~ 看完这么详细的注释,想必你也会认为,码农真是故意这么做的。但他们为什么要设计成这样呢?以后会不会改呢?注释中也说明了目前设计的流程是这样,估计以后有可能改。