好友
阅读权限10
听众
最后登录1970-1-1
|
本帖最后由 ffzy2023 于 2024-2-5 21:20 编辑
前言:越来越多视频需要referer才能播放,而大部分播放器不能自动设置,导致无法播放,所以我开发这个简易的迅雷播放器。
最新的SDK
完整解码库
增加酷狗音乐,酷狗MV、直播支持。
增加抖音视频,直播。
增加快手直播,视频。
增加虎牙直播。
增加B站直播,视频。
增加YY直播。
增加电视直播。
增加搜索央视视频。
修复:
1、酷狗MV默认解析最高分辨率的。(1080P)
2、绝大部分酷狗音乐可以播放。
3、B站直播尽量解析最高分辨率的。
4、默认以系统最高权限运行,自动注册组件。
5、使用FFMPEG作为视频录制引擎,随时可以停止录制。
解析FLV格式视频源而不是m3u8视频源的主要原因:
录制m3u8的视频源,容易造成视频和音频不同步,特别是边看边录制。
使用FLV格式的视频源,视频和音频可以同步。
蓝凑云下载完整版。
V2.6
https://wwcb.lanzn.com/iK0Pd1lg0yib
v2.8
https://wwt.lanzn.com/iVg4B1mwehli
V3.0
https://wwt.lanzn.com/i5TU41ngtbhi
[Shell] 纯文本查看 复制代码 #pragma compile(Icon, H:\QXTOOLS\1.ico)
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <APIDiagConstants.au3>
#include <StringConstants.au3>
#include <WinAPIReg.au3>
#include <GuiStatusBar.au3>
#include <GUIListView.au3>
#include <File.au3>
#include <Crypt.au3>
#include <IE.au3>
#include <GDIPlus.au3>
#RequireAdmin
$APlayerGUI = GUICreate("迅雷播放器", 800, 750, -1, -1, BitOR($GUI_SS_DEFAULT_GUI,$WS_MAXIMIZEBOX,$WS_SIZEBOX,$WS_THICKFRAME,$WS_TABSTOP))
GUISetBkColor(0x99B4D1)
_WinAPI_DllInstall ( "APlayerUI.dll" )
_WinAPI_DllInstall ( "APlayer.dll" )
$APlayerUI = ObjCreate("APlayerUI.Player.1")
$APlayer_ctrl = GUICtrlCreateObj($APlayerUI, 0, 0, 600, 500)
GUICtrlSetResizing($APlayer_ctrl, $GUI_DOCKAUTO)
GUICtrlSetState ( $APlayer_ctrl, $GUI_ONTOP )
$APlayer = $APlayerUI.GetAPlayerObject
$Edit1 = GUICtrlCreateEdit("", 10, 520, 780, 30,$ES_AUTOVSCROLL + $WS_VSCROLL)
Local $idLocOpen = GUICtrlCreateButton("打开", 10, 570, 80, 30)
Local $idWEBPLAY = GUICtrlCreateButton("播放", 100, 570, 80, 30)
Local $idVideo2Pic = GUICtrlCreateButton("视频截图", 190, 570, 80, 30)
Local $idRecordMP4 = GUICtrlCreateButton("视频录制", 280, 570, 80, 30)
Local $idStopRecord = GUICtrlCreateButton("停止录制", 370, 570, 80, 30)
$flipH = GUICtrlCreateCheckbox("水平翻转", 480, 570, 80, 30)
$flipV = GUICtrlCreateCheckbox("垂直翻转", 570, 570, 80, 30)
$Loopplay = GUICtrlCreateCheckbox("循环播放", 660, 570, 80, 30)
$idmedia = GUICtrlCreateListView("参数|信息", 610, 0, 190,300)
_GUICtrlListView_SetExtendedListViewStyle ( $idmedia, $LVS_REPORT,$LVS_EX_GRIDLINES)
_GUICtrlListView_JustifyColumn($idmedia, 0, 2)
_GUICtrlListView_JustifyColumn($idmedia, 1, 2)
$idKugouList = GUICtrlCreateListView("序号|艺术家|标题|唱片集|hash|mvhash", 10, 620, 780,100)
_GUICtrlListView_SetExtendedListViewStyle ( $idKugouList, $LVS_REPORT,$LVS_EX_GRIDLINES)
$idKugouListMenu = GUICtrlCreateContextMenu($idKugouList)
$PlayKogouMusic = GUICtrlCreateMenuItem("播放酷狗音乐", $idKugouListMenu)
$PlayKogouMV = GUICtrlCreateMenuItem("播放酷狗MV", $idKugouListMenu)
$Inputmusic =GUICtrlCreateInput("邓紫棋", 610, 320, 180, 20,$ES_CENTER)
Local $idFindKugou = GUICtrlCreateButton("搜索", 610, 350, 80, 30)
$oIE = _IECreateEmbedded ()
$oIEActive = GUICtrlCreateObj($oIE,610, 400, 100, 100)
GUICtrlSetState($oIEActive,$GUI_HIDE)
$StatusBar = _GUICtrlStatusBar_Create($APlayerGUI)
Dim $StatusBar_PartsWidth[2] = [400, -1]
_GUICtrlStatusBar_SetParts($StatusBar, $StatusBar_PartsWidth)
_GUICtrlStatusBar_SetMinHeight($StatusBar, 30)
_GUICtrlStatusBar_SetText($StatusBar,@TAB & "界面版本:" & $APlayerUI.GetVersion, 0)
_GUICtrlStatusBar_SetText($StatusBar,@TAB & "内核版本:" & $APlayer.GetVersion, 1)
GUISetState(@SW_SHOW)
GUIRegisterMsg($WM_SIZE, "WM_SIZE")
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Func APlayerGetInfo()
$wh = $APlayer.GetVideoWidth & " X " & $APlayer.GetVideoHeight
$Videocodec = StringUpper($APlayer.GetConfig (220))
$Audiocodec = $APlayer.GetConfig (410)
$samplerate = $APlayer.GetConfig (412)
$samplebit = $APlayer.GetConfig (413)
;$Readspeed = $APlayer.GetConfig (41) & " KB/s"
_GUICtrlListView_DeleteAllItems ( $idmedia )
Local $APlayerInfo[0][2]
_ArrayAdd($APlayerInfo, "分辨率|"&$wh&"")
_ArrayAdd($APlayerInfo, "视频编码器|"&$Videocodec&"")
_ArrayAdd($APlayerInfo, "音频编码器|"&$Audiocodec&"")
_ArrayAdd($APlayerInfo, "采样率|"&$samplerate&"")
_ArrayAdd($APlayerInfo, "采样位数|"&$samplebit&"")
;_ArrayAdd($APlayerInfo, "读取速度|"&$Readspeed&"")
_GUICtrlListView_AddArray($idmedia, $APlayerInfo)
_GUICtrlListView_SetColumnWidth($idmedia, 0, $LVSCW_AUTOSIZE)
_GUICtrlListView_SetColumnWidth($idmedia, 1, $LVSCW_AUTOSIZE)
EndFunc
Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam)
#forceref $hWnd, $iMsg, $wParam, $lParam
_GUICtrlStatusBar_Resize($StatusBar)
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_SIZE
Case $idLocOpen
$sFileOpenDialog = FileOpenDialog("请选择影音文件", @ScriptDir, "影音文件 (*.mp3;*.flac;*.mp4;*.ts;*.flv;*.mov;*.mpg;*.avi)", 4)
If @error Then
MsgBox(64, "迅雷播放器", "请重新选择影音文件!")
Else
$sFileOpenDialog = StringReplace($sFileOpenDialog, "|", @CRLF)
GUICtrlSetData($Edit1, $sFileOpenDialog)
PlayMedia()
GetMusicInfo()
EndIf
Case $idWEBPLAY
PlayMedia()
GetMusicInfo()
Case $idVideo2Pic
SavePic()
Case $idRecordMP4
RecordMP4()
Case $idStopRecord
$APlayer.SetConfig (2609,"7200000")
$APlayer.Close
Case $flipH
If BitAND(GUICtrlRead($flipH), $GUI_CHECKED) = $GUI_CHECKED Then
$APlayer.SetConfig (302,"1")
Else
$APlayer.SetConfig (302,"0")
EndIf
Case $flipV
If BitAND(GUICtrlRead($flipV), $GUI_CHECKED) = $GUI_CHECKED Then
$APlayer.SetConfig (303,"1")
Else
$APlayer.SetConfig (303,"0")
EndIf
Case $Loopplay
If BitAND(GUICtrlRead($Loopplay), $GUI_CHECKED) = $GUI_CHECKED Then
$APlayer.SetConfig (119,"1")
Else
$APlayer.SetConfig (119,"2")
EndIf
Case $idFindKugou
_GUICtrlListView_DeleteAllItems($idKugouList)
_GUICtrlListView_JustifyColumn($idKugouList, 1, 2)
_GUICtrlListView_JustifyColumn($idKugouList, 2, 2)
_GUICtrlListView_JustifyColumn($idKugouList, 3, 2)
_GUICtrlListView_JustifyColumn($idKugouList, 4, 1)
_GUICtrlListView_JustifyColumn($idKugouList, 5, 1)
Local $aArray_Base[0][6]
$aArray = $aArray_Base
Local $num = 1
Local $name = GUICtrlRead($Inputmusic)
Local $GBname = _StringToEncode4 ($name)
Local $url = "http://mobilecdn.kugou.com/api/v3/search/song?format=json&keyword="&$GBname&"&page=1&pagesize=30&showtype=1"
$oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1")
$oHTTP.Open("get", $url, False)
$oHTTP.setRequestHeader("Connection", "Keep-Alive")
$oHTTP.Send("")
Local $json = $oHTTP.responsetext
Global $oScript
_InitJsonData($json)
For $i = 0 To 29 Step 1
$songname = _GetJsonData($json, 'data.info['&$i&'].songname')
$singername = _GetJsonData($json, 'data.info['&$i&'].singername')
Local $album_name = _GetJsonData($json, 'data.info['&$i&'].album_name')
$hash = _GetJsonData($json, 'data.info['&$i&'].hash')
$mvhash = _GetJsonData($json, 'data.info['&$i&'].mvhash')
$sFill = ""&$num&"|"&$singername&"|"&$songname&"|"&$album_name&"|"&$hash&"|"&$mvhash&""
_ArrayAdd($aArray, $sFill)
$num = $num + 1
Next
_GUICtrlListView_AddArray ($idKugouList, $aArray)
_GUICtrlListView_SetColumnWidth($idKugouList, 1, $LVSCW_AUTOSIZE)
_GUICtrlListView_SetColumnWidth($idKugouList, 2, $LVSCW_AUTOSIZE)
_GUICtrlListView_SetColumnWidth($idKugouList, 3, $LVSCW_AUTOSIZE)
_GUICtrlListView_SetColumnWidth($idKugouList, 4, 0)
_GUICtrlListView_SetColumnWidth($idKugouList, 5, 0)
Case $PlayKogouMusic
Local $hash = _GUICtrlListView_GetItemText($idKugouList,_GUICtrlListView_GetSelectionMark($idKugouList) ,4)
Local $URL = "https://m.kugou.com/app/i/getSongInfo.php?cmd=playInfo&hash="&$hash&""
$oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1")
$oHTTP.Open("get", $url, False)
$oHTTP.setRequestHeader("Connection", "Keep-Alive")
$oHTTP.Send("")
Local $sData = $oHTTP.responsetext
Global $oScript
_InitJsonData($sData)
$KuGouurl = _GetJsonData($sData, 'url')
GUICtrlSetData($Edit1, $KuGouurl)
GetKuGouAddr($hash)
PlayMedia()
Local $Path = _PathFull(@ScriptDir)
$APlayer.SetConfig(1305,""&$Path&"\Music\MP3\"&$song_name&"-"&$author_name&".lrc")
$APlayer.SetConfig(1308,""&$Path&"\Music\MP3\"&$song_name&"-"&$author_name&".jpg")
Func GetKuGouAddr($KuGouHash)
Local $Path = _PathFull(@ScriptDir)
If Not FileExists (""&$Path&"\Music\MP3") Then
DirCreate (""&$Path&"\Music\MP3")
EndIf
_IENavigate($oIE, "https://www.kugou.com/")
_IELoadWait($oIE)
Local $sURL = 'https://wwwapi.kugou.com/yy/index.php?r=play/getdata&callback&hash='&$KuGouHash&'&appid=1014&platid=4'
$dData = InetRead($sURL )
Local $sData = BinaryToString($dData,4)
Global $oScript
_InitJsonData($sData)
$album_id = _GetJsonData($sData, 'data.album_id')
Local $sURL2 = 'https://wwwapi.kugou.com/yy/index.php?r=play/getdata&callback&hash='&$KuGouHash&'&appid=1014&platid=4&album_id='&$album_id&''
$dData2 = InetRead($sURL2 )
Local $sData2 = BinaryToString($dData2,4)
_InitJsonData($sData2)
Global $play_url = _GetJsonData($sData, 'data.play_url')
Global $album_name = _GetJsonData($sData, 'data.album_name')
Global $author_name = _GetJsonData($sData, 'data.author_name')
Global $song_name = _GetJsonData($sData, 'data.song_name')
Global $lyrics = _GetJsonData($sData, 'data.lyrics')
Global $img = _GetJsonData($sData, 'data.img')
If $KuGouurl = "" Then
GUICtrlSetData($Edit1, $play_url)
EndIf
If Not FileExists (""&$Path&"\Music\MP3\"&$song_name&"-"&$author_name&".lrc") Then
Local $testclean = StringInStr ($lyrics,"[00:00.00]")
If $testclean = 0 Then
FileWrite (""&$Path&"\Music\MP3\"&$song_name&"-"&$author_name&".lrc",$lyrics)
Else
FileWrite (""&$Path&"\Music\MP3\"&$song_name&"-"&$author_name&".lrc",StringTrimLeft ($lyrics,$testclean-1))
EndIf
EndIf
If Not FileExists (""&$Path&"\Music\MP3\"&$song_name&".jpg") Then
FileWrite (""&$Path&"\Music\MP3\"&$song_name&".jpg",InetRead($img))
_GDIPlus_Startup()
$hImage = _GDIPlus_ImageLoadFromFile(""&$Path&"\Music\MP3\"&$song_name&".jpg")
Local $hBitmap_Scaled = _GDIPlus_ImageResize ($hImage,440,440)
_GDIPlus_ImageSaveToFile($hBitmap_Scaled, ""&$Path&"\Music\MP3\"&$song_name&"-"&$author_name&".jpg")
_GDIPlus_BitmapDispose($hImage)
_GDIPlus_BitmapDispose($hBitmap_Scaled)
_GDIPlus_Shutdown()
FileDelete ( ""&$Path&"\Music\MP3\"&$song_name&".jpg" )
EndIf
EndFunc
Case $PlayKogouMV
Local $mvhash = _GUICtrlListView_GetItemText($idKugouList,_GUICtrlListView_GetSelectionMark($idKugouList) ,5)
local $sPassword=""&$mvhash&"kugoumvcloud"
$a = StringToBinary($sPassword,4)
$b = _Crypt_HashData($a, $CALG_MD5)
$c = StringTrimLeft($b,2)
$kugoumvkey = StringLower($c)
Local $URL = "http://trackermv.kugou.com/interface/index/cmd=100&hash="&$mvhash&"&key="&$kugoumvkey&"&pid=6&ext=mp4&ismp3=0"
$oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1")
$oHTTP.Open("get", $url, False)
$oHTTP.setRequestHeader("Connection", "Keep-Alive")
$oHTTP.Send("")
Local $sData = $oHTTP.responsetext
Global $oScript
_InitJsonData($sData)
$url = _GetJsonData($sData, 'mvdata.sq.downurl')
If $url = "" Then $url = _GetJsonData($sData, 'mvdata.hd.downurl')
GUICtrlSetData($Edit1, $url)
PlayMedia()
Func PlayMedia()
$dyurl = GUICtrlRead($Edit1)
If $dyurl = "" Then
MsgBox(64,"迅雷播放器","无法播放!")
Else
Local $testbili = StringInStr ($dyurl,"bilivideo")
Local $testhaokan = StringInStr ($dyurl,"haokan")
Local $testweburl = StringInStr ($dyurl,"http")
If $testbili > 0 Then
$APlayer.SetConfig(1106,"https://live.bilibili.com/")
ElseIf $testhaokan > 0 Then
$APlayer.SetConfig(1106,"https://haokan.baidu.com/")
ElseIf $testweburl > 0 Then
$surl = StringSplit ($dyurl,"/")
$referer = $surl[1] & "//" & $surl[3]
$APlayer.SetConfig(1106,$referer)
Else
$APlayer.SetConfig(1106,"")
EndIf
$APlayer.open ($dyurl)
Do
$APlayerState = $APlayer.GetState
Until $APlayerState = 5
APlayerGetInfo()
EndIf
EndFunc
Func SavePic()
Local $Path = _PathFull(@ScriptDir)
$Snapshotusable = $APlayer.GetConfig (701)
If $Snapshotusable = 0 Then
MsgBox(64,"迅雷播放器","还没有加载视频,无法截屏!")
Else
Local $sFileSaveDialog = FileSaveDialog("保存视频截图", @ScriptDir, "图片文件 (*.jpg)|动画图片 (*.gif)", $FD_PATHMUSTEXIST)
If @error Then
MsgBox(64,"迅雷播放器", "请重新选择本机路径!")
Else
Local $sDrive = "", $sDir = "", $sFileName = "", $sExtension = ""
Local $aPathSplit = _PathSplit($sFileSaveDialog, $sDrive, $sDir, $sFileName, $sExtension)
If $sExtension = ".gif" Then
$orgWidth = $APlayer.GetVideoWidth
$orgHeight = $APlayer.GetVideoHeight
$newWidth = 320
$newHeight = $orgHeight/($orgWidth/320)
$APlayer.SetConfig (703,$newWidth)
$APlayer.SetConfig (704,$newHeight)
$APlayer.SetConfig (709,"length=6000;cutinterval=500;playinterval=200")
$APlayer.SetConfig (707,"4")
$APlayer.SetConfig (702,$sFileSaveDialog)
Else
$APlayer.SetConfig (707,"2")
$APlayer.SetConfig (708,"100")
$APlayer.SetConfig (702,$sFileSaveDialog)
EndIf
EndIf
EndIf
EndFunc
Func RecordMP4()
Local $Path = _PathFull(@ScriptDir)
$Recordusable = $APlayer.GetConfig (2601)
If $Recordusable = 0 Then
MsgBox(64,"迅雷播放器","还没有加载视频,无法录制!")
Else
Local $sFileSaveDialog = FileSaveDialog("保存视频录像", @ScriptDir, "视频文件 (*.mp4)", $FD_PATHMUSTEXIST)
If @error Then
MsgBox(64,"迅雷播放器", "请重新选择本机路径!")
Else
$mVideoWidth = $APlayer.GetVideoWidth
$mVideoHeight = $APlayer.GetVideoHeight
Do
$APlayer.GetVideoWidth
Until $APlayer.GetVideoWidth > 0
If $mVideoWidth > $mVideoHeight Then
$APlayer.SetConfig (2602,"1280")
Else
$APlayer.SetConfig (2602,"720")
EndIf
$APlayer.SetConfig (2604,"2000")
$APlayer.SetConfig (2605,"128")
$APlayer.SetConfig (2606,"mp4")
$APlayer.SetConfig (2607,$sFileSaveDialog)
$APlayer.SetConfig (2608,"0")
EndIf
EndIf
EndFunc
Func GetMusicInfo()
$MusicUrl = GUICtrlRead($Edit1)
Local $testweburl = StringInStr ($MusicUrl,"http")
If $testweburl > 0 Then
Else
Local $ShellInfo[0][2]
Local $sDrive = "", $sDir = "", $sFileName = "", $sExtension = ""
Local $aPathSplit = _PathSplit($MusicUrl, $sDrive, $sDir, $sFileName, $sExtension)
If $sExtension = ".mp3" Or $sExtension = ".flac" Then
$s = ObjCreate("Shell.Application")
Local $fullpath = ""&$sDrive&""&$sDir&""
Local $fullname = ""&$sFileName&""&$sExtension&""
$a = $s.NameSpace($fullpath)
$b = $a.ParseName($fullname)
For $i = 1 To 28 Step 1
$c = $a.GetDetailsOf($a, $i)
$d = $a.GetDetailsOf($b, $i)
If $i = 1 Then _ArrayAdd($ShellInfo, "大小|"&$d&"")
If $i = 13 Then _ArrayAdd($ShellInfo, "艺术家|"&$d&"")
If $i = 14 Then _ArrayAdd($ShellInfo, "唱片集|"&$d&"")
If $i = 21 Then _ArrayAdd($ShellInfo, "标题|"&$d&"")
If $i = 27 Then _ArrayAdd($ShellInfo, "时长|"&$d&"")
If $i = 28 Then
$size = StringTrimLeft($d,1)
_ArrayAdd($ShellInfo, "比特率|"&$size&"")
EndIf
Next
EndIf
_GUICtrlListView_AddArray($idmedia, $ShellInfo)
_GUICtrlListView_SetColumnWidth($idmedia, 0, $LVSCW_AUTOSIZE)
_GUICtrlListView_SetColumnWidth($idmedia, 1, $LVSCW_AUTOSIZE)
EndIf
EndFunc
Func _StringToEncode4($str, $Encode = 4, $AllFlag = 0, $sPrefix = '%')
Local $str_s = StringRegExpReplace($str, '^\s*(?i)(http://).+', '$1')
If Not @extended Then $str_s = ''
If @extended Then $str = StringRegExpReplace($str, '^\s*(?i)http://', '')
Local $sOut, $i, $sS2B, $aSR
If $AllFlag Then
$sS2B = StringTrimLeft(StringToBinary($str, $Encode), 2)
$sOut = StringRegExpReplace($sS2B, '..', $sPrefix & '$0')
Else
$sOut = $str
$aSR = StringRegExp($str, '\W+', 3)
If Not @Error Then
For $i = 0 To UBound($aSR) - 1
$sS2B = StringTrimLeft(StringToBinary($aSR[$i], $Encode), 2)
$sOut = StringReplace($sOut, $aSR[$i], StringRegExpReplace($sS2B, '..', $sPrefix & '$0'), 1)
Next
EndIf
EndIf
If $sPrefix = ' ' Then $sOut = StringRegExpReplace($sOut, '^\h+|\h+$', '')
;$sOut = StringReplace($sOut, '%20', '+')
Return $str_s & $sOut
EndFunc ;==>_StringToEncode4
Func _InitJsonData($sJson)
$oScript= ObjCreate('ScriptControl')
$oScript.Language = 'JScript'
$oScript.AddCode('var JsonData = ' & $sJson & ';')
EndFunc
Func _GetJsonData($sJson, $key)
Return $oScript.Eval('JsonData.' & $key)
EndFunc
EndSwitch
WEnd
|
免费评分
-
查看全部评分
|