| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1256 人关注过本帖
标题:[求助]我这个播放器怎么不能放文件名含空格的音乐文件???
只看楼主 加入收藏
VB爱上我
Rank: 6Rank: 6
等 级:贵宾
威 望:25
帖 子:478
专家分:52
注 册:2005-10-14
收藏
得分:0 
版主我今天在网上找到了一点关于短文件的文章了。
Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long

Private Function ShortName(LName As String) As String
'取得短文件名
Dim s As String, i As Long
i = 512
s = Space$(i)
GetShortPathName LName, s, i
ShortName = Left$(s, InStr(1, s, vbNullChar) - 1)
End Function

IT618资讯网 提供服务端开发,前端开发,网页特效,热门开源系统研究,软件下载,站长建站,淘宝开店等学习资料.
2005-11-22 09:51
VB爱上我
Rank: 6Rank: 6
等 级:贵宾
威 望:25
帖 子:478
专家分:52
注 册:2005-10-14
收藏
得分:0 
GetTempPath取得的是一个DOS名称,当文件名长度大于8时,长文件名格式“C:\Documents and Settings\Administrator\Local Settings\Temp”会显示成“C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp”的短文件名格式,如何根据自己需要取得系统临时目录的途径,下面是一个新写的函数,调用两个API 实现,相信许多朋友可能用得到。

Option Explicit
Private Declare Function GetLongPathName Lib "kernel32" Alias "GetLongPathNameA" (ByVal lpszShortPath As String, ByVal lpszLongPath As String, ByVal cchBuffer As Long) As Long
Private Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long


Sub GetTEMPfolder(Optional ByVal showlong As Boolean = True)

Dim longname As String, shortname As String

shortname = Space(256)
GetTempPath Len(shortname), shortname

longname = Space(1024)
GetLongPathName shortname, longname, Len(longname)



MsgBox "Tempfolder : " & IIf(showlong = True, longname, shortname)

End Sub

Private Sub Command1_Click()
GetTEMPfolder '长文件名
GetTEMPfolder False '短文件名
End Sub


IT618资讯网 提供服务端开发,前端开发,网页特效,热门开源系统研究,软件下载,站长建站,淘宝开店等学习资料.
2005-11-22 10:12
leon2
Rank: 3Rank: 3
等 级:新手上路
威 望:7
帖 子:731
专家分:0
注 册:2005-3-18
收藏
得分:0 

歌词同步!你可以这样做:
1、定义一个歌词类型 lyric,内含每条歌词的开始、结束、文字信息;
2、读取歌曲和歌词文件,并分析歌词文件,把歌词填充到 lyrics();
3、在 MediaPlayer 控件中不断检测播放位置,如果达到某位置就显示那个位置的歌词。

2005-11-22 12:11
VB爱上我
Rank: 6Rank: 6
等 级:贵宾
威 望:25
帖 子:478
专家分:52
注 册:2005-10-14
收藏
得分:0 
谢谢版主 我回去试试,可是我用的是MCI函数做的播放器.

IT618资讯网 提供服务端开发,前端开发,网页特效,热门开源系统研究,软件下载,站长建站,淘宝开店等学习资料.
2005-11-22 14:40
VB爱上我
Rank: 6Rank: 6
等 级:贵宾
威 望:25
帖 子:478
专家分:52
注 册:2005-10-14
收藏
得分:0 

Dim tianjia As Integer '判断是否从新添加音乐文件
Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long
Private Sub Command1_Click()
Dim lujing As String
If tianjia = 1 Then
MP3.List1.Clear
MP3.List2.Clear
Dim n As Integer
Dim m As Integer
n = File1.ListCount - 1
For m = 0 To n
If File1.Selected(m) = True Then
lujing = File1.Path & "\" & File1.List(m)
MP3.List1.AddItem File1.List(m)
MP3.List2.AddItem ShortName(lujing)
MP3.List1.Refresh
End If
Next
Unload Me
Else
n = File1.ListCount - 1
For m = 0 To n
If File1.Selected(m) = True Then
lujing = File1.Path & "\" & File1.List(m)
MP3.List1.AddItem File1.List(m)
MP3.List2.AddItem ShortName(lujing)
MP3.List1.Refresh
End If
Next
'播放器.MediaPlayer1.Stop
Unload Me
End If
End Sub

Private Sub Command2_Click()
Unload Me
End Sub

Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub

Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
Private Sub del_Click()
MP3.del_Click
End Sub

Private Sub Form_Load()
tianjia = 1
End Sub

Private Sub Option1_Click()
If Option1.Value = True Then
tianjia = 1
Else
tianjia = 0
End If
End Sub

Private Sub Option2_Click()
If Option2.Value = True Then
tianjia = 0
Else
tianjia = 1
End If
End Sub

Public Function ShortName(LName As String) As String
'取得短文件名
Dim s As String, i As Long
i = 512
s = Space$(i)
GetShortPathName LName, s, i
ShortName = Left(s, InStr(1, s, vbNullChar) - 1)
End Function

我终于做出来了.哈哈^多谢版主们提示.


IT618资讯网 提供服务端开发,前端开发,网页特效,热门开源系统研究,软件下载,站长建站,淘宝开店等学习资料.
2005-11-22 19:09
tiantian
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2005-12-15
收藏
得分:0 
麻烦楼主能不能把源代码也附上?
2005-12-15 12:57
palaking
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2007-5-19
收藏
得分:0 

原来是这样啊
最近有没有更新的版本啊

2007-05-19 02:00
快速回复:[求助]我这个播放器怎么不能放文件名含空格的音乐文件???
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014766 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved