Comments (1)
先下载文件,然后读取文件,设置编码,然后loadLrc以字符串的形式加载,附设置编码方法:
fun convertFileCode(file: File): String {
var text = ""
var fis: FileInputStream? = null
var bis: BufferedInputStream? = null
var reader: BufferedReader? = null
try {
fis = FileInputStream(file)
bis = BufferedInputStream(fis)
bis.mark(4)
val first3bytes = ByteArray(3)
bis.read(first3bytes)
bis.reset()
if (first3bytes[0] == 0xEF.toByte() && first3bytes[1] == 0xBB.toByte() && first3bytes[2] == 0xBF.toByte()) {// utf-8
reader = BufferedReader(InputStreamReader(bis, "utf-8"))
} else if (first3bytes[0] == 0xFF.toByte() && first3bytes[1] == 0xFE.toByte()) {
reader = BufferedReader(InputStreamReader(bis, "unicode"))
} else if (first3bytes[0] == 0xFE.toByte() && first3bytes[1] == 0xFF.toByte()) {
reader = BufferedReader(InputStreamReader(bis, "utf-16be"))
} else if (first3bytes[0] == 0xFF.toByte() && first3bytes[1] == 0xFF.toByte()) {
reader = BufferedReader(InputStreamReader(bis, "utf-16le"))
} else {
reader = BufferedReader(InputStreamReader(bis, "GBK"))
}
var str = reader.readLine();
while (str != null) {
text = "$text$str/n"
str = reader.readLine()
}
} catch (e: Exception){e.printStackTrace()
} finally {
fis?.let {
try{
it.close()
}catch (e: IOException){e.printStackTrace() }
}
bis?.let {
try{
it.close()
}catch (e: IOException){e.printStackTrace() }
}
}
return text
}
from lrcview.
Related Issues (20)
- 请添加一个单击事件可以吗? HOT 8
- loadLrcByUrl方法异常 HOT 4
- 大哥,帮帮忙,怎么添加点击事件,急急急,现在就要。 HOT 3
- 老哥 什么时候有空可以出个教程吗?万分感谢 , 谢谢老哥 HOT 1
- 发现BUG 了 HOT 3
- 在initEntryList方法中增加一句 mLrcPaint.setTextSize(mCurrentTextSize);吧,否则切换歌词时候歌词的高度会变小 HOT 1
- 支持拖动切换进度 HOT 1
- 调整切换速度 HOT 2
- loadLrcByUrl概率性加载时间过长的问题 HOT 4
- 频繁切换歌词,换行失效,歌词超出屏幕 HOT 3
- 无法监听点击事件 HOT 3
- 对viewpager的适配 HOT 5
- jitpack.io上的包有bug HOT 2
- jitpack 下载出现http 401错误 HOT 1
- 切换上下曲后,再切到有歌词的歌曲,歌词无法换行,导致超出歌词控件宽度,在车机上使用 HOT 1
- 可以调整歌词时间吗 HOT 1
- 可以出kotlin版本么 HOT 1
- 能加上ktv那种效果吗大佬,从左到右均匀绘制颜色。并且总展示行数可配置,比如整个view只支持展示两行 HOT 1
- 字体
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lrcview.