Android music garbled problem modification, android garbled

Source: Internet
Author: User

Android music garbled problem modification, android garbled

The following is a summary of the garbled modification of music names, albums, and music in the Android music player:

Method 1: In frameworks \ base \ media \ java \ android \ media \ MediaScanner. java, modify the handleStringTag function.

Add the character encoding conversion to this function;

<span style="font-family:KaiTi_GB2312;font-size:18px;">/*add by tanfusheng @20150110 start */        private boolean isEncoding(String value,String code) throws UnsupportedEncodingException{            return value.equals(new String(value.getBytes(code),code));        }         /*add by tanfusheng @20150110 end */        public void handleStringTag(String name, String value) {         /*add by tanfusheng @20150110  start */            try{                if(isEncoding(value,"ISO-8859-1")){                    value = new String(value.getBytes("ISO-8859-1"),"GBK");                }            }catch(UnsupportedEncodingException e){                e.printStackTrace();            }             /*add by tanfusheng @20150110  end */</span>

You can.

Method 2: modify it in frameworks \ av \ media \ libmedia \ MediaScannerClient. cpp:

<span style="font-family:KaiTi_GB2312;font-size:18px;">void MediaScannerClient::endFile(){if (mLocaleEncoding != kEncodingNone) {int size = mNames->size();+ int count = 0;uint32_t encoding = kEncodingAll;uint32_t tmpEncoding = kEncodingAll;uint32_t srcEncoding = kEncodingNone;for (int i = 0; i < mNames->size(); i++) {tmpEncoding = possibleEncodings(mValues->getEntry(i));// If no multibyte encoding is detected or GBK is the only possible multibyte encoding, just ignore- if( (kEncodingNone != tmpEncoding) && (kEncodingCP1252 != tmpEncoding)- && ((kEncodingGBK | kEncodingCP1252) != tmpEncoding) ) {- encoding &= tmpEncoding;+ if( (kEncodingNone == tmpEncoding) || ((kEncodingGBK | kEncodingCP1252) == tmpEncoding) ) {+ continue;}++ if( kEncodingCP1252 == tmpEncoding ) {+ ++count;+ continue;+ }++ encoding &= tmpEncoding;LOGV("value: %s, tmpEncoding: %x\n", mValues->getEntry(i), tmpEncoding);}++ if(count >= 2) {+ encoding = kEncodingAll;+ }LOGV("possibleEncodings: %x\n", encoding);...}</span>
"+" Indicates the code to be added and "-" indicates the code to be deleted.

I hope this garbled problem can be used. If it is changed like this, there will be garbled characters, which is the problem of a single music. I have to listen to it and modify the encoding method of the music, the method can be Baidu.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.