⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dlgmain.asm

📁 bass radibass radio 1.0o 1.0
💻 ASM
字号:
.386
.model flat, stdcall  ;32 bit memory model
option casemap :none  ;case sensitive

include DlgMain.inc

.code

start:

	invoke GetModuleHandle,NULL
	   mov hInstance,eax
    invoke InitCommonControls
	invoke DialogBoxParam,hInstance,IDD_DIALOG,NULL,addr DlgProc,NULL
	invoke ExitProcess,0

;########################################################################

DlgProc proc hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
mov eax,hWnd
mov hMain,eax

	.if uMsg==WM_INITDIALOG
            invoke BASS_Init, -1, 44100, 0, hWnd, 0               ; BASS_Init
              test eax,eax                                            
                jz error                                                
        	invoke BASS_SetConfig,BASS_CONFIG_NET_PLAYLIST,1      ; // enable playlist processing
			invoke BASS_SetConfig,BASS_CONFIG_NET_PREBUF,0        ; // minimize automatic pre-buffering, so we can do it (and display it) instead

            invoke SendDlgItemMessage,hWnd,1011,WM_SETTEXT,0,addr szNoSteam 
error:

 
    .elseif uMsg==WM_TIMER

                  push esi
                  push ebx
                  push edx
                invoke BASS_StreamGetFilePosition,chan,BASS_FILEPOS_END
                   mov _len ,eax
                   mov esi, eax
                invoke BASS_StreamGetFilePosition,chan,BASS_FILEPOS_DOWNLOAD
                   mov progress,eax
                   mov ebx, eax
                invoke BASS_StreamGetFilePosition,chan,BASS_FILEPOS_CURRENT
                   sub ebx, eax
                   lea eax, [ebx+ebx*4]
                   lea eax, [eax+eax*4]
                   shl eax, 2
                   xor edx, edx
                   div esi
                   mov ebx, eax
                invoke BASS_StreamGetFilePosition,chan,BASS_FILEPOS_CONNECTED
             
               .if(ebx>75 || !eax)
	                   invoke KillTimer,hWnd,0
	                   invoke wsprintf,addr progress,addr szBuffering,100
                       invoke SetDlgItemText,hWnd,1002,addr progress
loc_401904:
                       invoke BASS_ChannelGetTags,chan,BASS_TAG_ICY
                          mov esi,eax
                         test esi, esi
                          jnz @F
                       invoke SetDlgItemText,hWnd,1001,addr szNoInfo
                          jmp @Play
                    @@:
                       invoke Icy_Tag,esi
                 @Play: 
	                   invoke ReadMeta
	                   
                       invoke BASS_ChannelSetSync ,chan,BASS_SYNC_META,szDoubleQ,offset MetaSync,0
                       invoke BASS_ChannelSetSync ,chan,BASS_SYNC_END,szDoubleQ,offset EndSync,0


                       invoke BASS_ChannelPlay, chan, FALSE
                       
                        .if eax==TRUE
                       	   invoke SendDlgItemMessage,hWnd,1011,WM_SETTEXT,0,addr szPlayingStream
                       .endif
                       
                          invoke StatusTime,hWnd,0,0
	                         mov ElapsedTime,0
	                      invoke GetTickCount
	                         mov StartTime,eax
                          invoke SetTimer,hWnd,100,1000,offset CalcElapsedTime
	            .else
		              invoke wsprintf,addr progress,addr szBuffering,ebx
                      invoke SetDlgItemText,hWnd,1002,addr progress
              .endif            
                          pop edx
                          pop ebx
                          pop esi

	.elseif uMsg==WM_COMMAND
         .if wParam ==100
   
         invoke BASS_StreamFree  ,chan
         invoke BASS_StreamCreateURL, Addr url, 0, BASS_STREAM_STATUS or BASS_STREAM_AUTOFREE, 0, 0
           test eax, eax
            jnz @F
            
         invoke SetDlgItemText,hWnd,1011,addr aCanTPlayTheStr ; "Can't play the stream"
            jmp @out
       
         @@:
            mov chan,eax
         invoke SetTimer,hWnd,0,50,0; // start prebuffer monitoring
         
    @out:

            .elseif wParam==1009
            	invoke BASS_ChannelStop,chan
            	invoke KillTimer,hMain,100
          invoke SendDlgItemMessage,hWnd,1011,WM_SETTEXT,0,addr szSteamStopped


         .endif
     
	.elseif uMsg==WM_CLOSE
	    invoke BASS_Free
		invoke EndDialog,hWnd,0
	.else
		mov		eax,FALSE
		ret
	.endif
	mov		eax,TRUE
	ret

DlgProc endp

EndSync Proc handle:DWORD,channel:DWORD,data:DWORD,user:DWORD 
  invoke SendDlgItemMessage,hMain,1011,WM_SETTEXT,0,offset szNotPlaying
  invoke KillTimer,hMain,100
  invoke BASS_StreamFree,chan
             ret
EndSync endp

MetaSync Proc handle:DWORD,channel:DWORD,data:DWORD,user:DWORD
  call ReadMeta
   ret
MetaSync endp

ReadMeta proc uses ebx 

invoke  BASS_ChannelGetTags,chan, BASS_TAG_META
mov esi,eax
.if (esi != 0)

   invoke StrStr,esi,addr aStreamtitle ; "StreamTitle="
   mov ebx, eax
   .if ebx != 0
      lea eax, [ebx+0Dh]
      invoke StrDup,eax         ;duplicate
      mov ebx, eax

      invoke StrChr ,ebx,";"
       .if eax != 0
             mov byte ptr [eax-1], 0
       .endif
      invoke SendDlgItemMessage,hMain,1001,WM_SETTEXT,0,ebx
      invoke LocalFree,ebx

   .endif   
.endif   
ret
ReadMeta endp

Icy_Tag Proc lpIcy:DWORD
	
@Back:   
      invoke StrCmpNI,esi,offset aIcyName,9
        test eax, eax
         jnz @F
       
         lea eax, [esi+9]
      invoke SetDlgItemText,hMain,1004,eax
      
   @@:
      invoke StrCmpNI,esi,offset aIcyBr ,7
        test eax,eax
         jnz @F
         
         lea eax, [esi+7]
      invoke lstrcat, offset hBitrate,eax
      invoke lstrcat, offset hBitrate,addr szKbs
      invoke SetDlgItemText,hMain,1005,addr  hBitrate
      invoke RtlZeroMemory,addr  hBitrate,sizeof hBitrate
   @@:
         mov edi, esi
         mov al, 0
         cld
         mov ecx, -1
       repne scasb
         not ecx
         add esi, ecx
         cmp byte ptr [esi], 0
         jnz @Back
   @out:
	     ret
Icy_Tag endp

StatusTime PROC hWnd:DWORD, Min:DWORD,Sec:DWORD
	invoke wsprintf,offset szStatusElapsedTime,
		            offset szElapsedTime,Min,Sec
    invoke SetDlgItemText,hWnd,1010,offset szStatusElapsedTime
	ret
StatusTime ENDP

CalcElapsedTime PROC hWnd:DWORD

	invoke GetTickCount
	mov ecx,StartTime	;Time=EndTime-StartTime
	mov StartTime,eax
	sub eax,ecx		;eax=Time


	add eax,ElapsedTime
	xor edx,edx
	mov ElapsedTime,eax	;eax=ElapsedTime in miliseconds

	mov ecx,1000*60		;convers miliseconds to minutes & seconds
	xor edx,edx
	div ecx			;eax=seconds
	push eax		;eax=minutes, save it

	mov eax,edx		;calc seconds
	mov ecx,1000
	xor edx,edx
	div ecx
	pop ecx			;restore minutes
	invoke StatusTime,hWnd,ecx,eax
	ret
CalcElapsedTime ENDP
end start

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -