TMediaPlayer
Classe: TMediaPlayer
Cria um objeto para reprodução de vídeos e áudios. Este componente utiliza tecnologia ActiveX, através do Windows Media Player®, desta forma estando homologado apenas para os sistema operacionas da Microsoft®, dentre eles:
Windows XP
Windows Vista
Windows 7
Windows 8
O Windows Media Player® pode depender de Codecs específicos para reprodução dos arquivos MP4, como teste basta executar este arquivo diretamente na ferramenta da Microsoft®, caso funcione nesta, a reprodução ocorrera sem problemas no TMediaPlayer.
Importânte: Este componente está disponível em versões superiores à 120420A.
TSrvObject -> TControl -> TMediaPlayer
New
Método construtor da classe.
TMediaPlayer(): New ( [ nRow], [ nCol], [ nWidth], [ nHeight], [ oWnd], [ cFile], [ nVolume], [ lShowBar] ) --> oObjeto
Nome | Tipo | Descrição | Obrigatório | Referência |
nRow | Numérico | Indica a coordenada vertical em pixels ou caracteres. | ||
nCol | Numérico | Indica a coordenada horizontal em pixels ou caracteres. | ||
nWidth | Numérico | Indica a largura em pixels do objeto. | ||
nHeight | Numérico | Indica a altura em pixels do objeto. | ||
oWnd | Objeto | Indica a janela ou controle visual onde o objeto será criado. | X | |
cFile | Caractere | Indica o nome do arquivo de mídia(MP4 ou MP3), que caso preenchido iniciara automaticamente a reprodução . | ||
nVolume | Numérico | Indica o volume de audio, de 0 a 100 | ||
lShowBar | Boleano | Se .T. indica que será exibida a barra de comandos do próprio Windows Media Palyer® |
- ()
- Retorna o objeto criado.
oMedia := TMediaPlayer():New(1, 1, 200, 200, oDlg, "c:/dir/file.mp4", 70, .T.)
OpenFile
Abre e inicia a reprodução de um arquivo de mídia.
TMediaPlayer(): Openfile([cFile]) -->
oMedia:OpenFile("c:/fir/file.mp3")
Nome | Tipo | Descrição | Obrigatório | Referência |
cFile | Caracter | Indica o nome do arquivo de mídia(MP4 ou MP3), que caso preenchido iniciara automaticamente a reprodução . | X |
SetShowBar
Habilita a exibição da barra de ferramentas do Windows Media Player®.
TMediaPlayer(): SetShowBar( <lShow> ) -->
Nome | Tipo | Descrição | Obrigatório | Referência |
lShow | Boleano | Se .T. indica que será exibida a barra de comandos do próprio Windows Media Palyer® | X |
oMedia:SetShowBar(.T.)
SetVolume
Ajusta a altura do volume de áudio.
TMediaPlayer(): SetColume([nVolume] ) -->
oMedia:SetVolume(70)
Nome | Tipo | Descrição | Obrigatório | Referência |
nVolume | Numérico | Indica o volume de audio, de 0 a 100 | X |
Play
Inicia reprodução.
TMediaPlayer():Play() -->
#include "TOTVS.CH"
User Function TMedia()
local nLeft := 1
local nTopBtn := 202
local lShowBar:= .F.
local nVolume := 70
local cFile := "c:/dir/file.mp3"
DEFINE MSDIALOG oDlg TITLE "TMediaPlayer" FROM 0,0 TO 424,404 PIXEL
oMedia := TMediaPlayer():New(1,nLeft,200,200,oDlg,cFile,nVolume,lShowBar)
TButton():New( nTopBtn, nLeft, "Open", oDlg,;
{|| oMedia:openFile( FWInputBox("Escolha o arquivo", "c:/garbage/") ) },28,010,,,.F.,.T.,.F.,,.F.,,,.F. )
TButton():New( nTopBtn, nLeft+=28, "Play", oDlg,;
{|| oMedia:play() },28,010,,,.F.,.T.,.F.,,.F.,,,.F. )
TButton():New( nTopBtn, nLeft+=28, "Pause", oDlg,;
{|| oMedia:pause() },28,010,,,.F.,.T.,.F.,,.F.,,,.F. )
TButton():New( nTopBtn, nLeft+=28, "Stop", oDlg,;
{|| oMedia:stop() },28,010,,,.F.,.T.,.F.,,.F.,,,.F. )
TButton():New( nTopBtn, nLeft+=28, "SetVolume", oDlg,;
{|| oMedia:setVolume( Val( FWInputBox("Escolha a altura do volume [0-100]", cValToChar(oMedia:nVolume)) ) ) },28,010,,,.F.,.T.,.F.,,.F.,,,.F. )
TButton():New( nTopBtn, nLeft+=28, "GetVolume", oDlg,;
{|| MsgAlert( oMedia:nVolume ) },28,010,,,.F.,.T.,.F.,,.F.,,,.F. )
TButton():New( nTopBtn, nLeft+=28, "ShowBar", oDlg,;
{|| lShowBar:=!lShowBar, oMedia:setShowBar( lShowBar ) },28,010,,,.F.,.T.,.F.,,.F.,,,.F. )
ACTIVATE MSDIALOG oDlg CENTERED
return