Skip to content
⌘ NSIS Forum Archive

Play a video in NSIS Installer

23 posts

herdell#

Play a video in NSIS Installer

Hi, I've found a tool made in nsis that play a video in the main page. I'm very curious, cause I don't know any plugin able to do something like this.

Can anyone take a look in this program I post here how to this? I'll attach the file below.

EDIT: I uploaded in megaupload, cause I can't attach the files here.
The file contain a virus. I'll upload a clean file later. Sorry.

The name of the video using in this installer, is: "ý«€" just rename it and open in any video player. You can find it in PLUGINSDIR o extracting this installer.

I'm waiting fot answers, thanx...
Animaether#
You forgot to include the link. Not that it would help much, as 'decompiling' an installer is tough at best. Why not ask the authors of the installer in question?

If I wanted to do something like that - without programming something myself or poking at the System plugin - I'd probably check if http://nsis.sourceforge.net/NsWeb_plug-in would allow me to display a page that has the video as an embedded object.
herdell#
Originally Posted by Animaether View Post
You forgot to include the link. Not that it would help much, as 'decompiling' an installer is tough at best. Why not ask the authors of the installer in question?

If I wanted to do something like that - without programming something myself or poking at the System plugin - I'd probably check if http://nsis.sourceforge.net/NsWeb_plug-in would allow me to display a page that has the video as an embedded object.
I have no idea who made this installer, and my pc os with virus, so, I'll upload it later.
herdell#edited
Sorry for the double post, but here don't appear the 'Edit' button this time, so, I can't edit my posts. Here is the link clean of virus. Plese, check it out ,if you can.


And this is the video used by the installer:

You can also find it in the $PLUGINSDIR folder when the installer is running.

If an admin edit my first post with this link, will be great. Thanx...
Animaether#
They're creating a SysAnimate32 control.. probably just through nsDialogs.
An animation control is a window that displays an Audio-Video Interleaved (AVI) clip. An AVI clip is a series of bitmap frames like a movie. Animation controls can only display AVI clips that do not contain audio.
Animaether#
Originally Posted by herdell View Post
Can you make me a nsis example file?
!addincludedir "."
!addplugindir "."
!include "nsDialogs.nsh"
!include "LogicLib.nsh"
!include "WinCore.nsh"
!include "WinMessages.nsh"
OutFile "$%temp%\temp.exe"
Section
SectionEnd
!define ACS_CENTER 0x0001
!define ACS_AUTOPLAY 0x0004
!define /math ACM_OPENA ${WM_USER} + 100
!define /math ACM_OPENW ${WM_USER} + 103
!define ACM_OPEN ${ACM_OPENA} ; lets use the ANSI one.
!define /math ACM_PLAY ${WM_USER} + 101
!define /math ACM_STOP ${WM_USER} + 102
Page Custom customPage
Var dialog
Var hwnd
Var null
Var animationControl
Function customPage
  nsDialogs::Create 1018
  Pop $dialog
  ${If} $dialog == error
    Abort
  ${EndIf}
  /* match dimentions to that of your AVI, otherwise it will center within control */
  nsDialogs::CreateControl "SysAnimate32" ${ACS_CENTER}|${ACS_AUTOPLAY}|${WS_VISIBLE}|${WS_CHILD} "" 0 0 422 132 ''
    Pop $animationControl
    SetOutPath $PluginsDir
      File "test.avi"
    StrCpy $1 "$PluginsDir\test.avi"
    StrLen $2 $1
    System::Call '*(&t$2 "$1") i.r0'
    SendMessage $animationControl ${ACM_OPEN} 0 $0
    System::Free $0
  ${NSD_CreateButton} 0 150 64 32 "[  ]"
    Pop $hwnd
    ${NSD_OnClick} $hwnd animation.stop
  ${NSD_CreateButton} 72 150 64 32 "|>"
    Pop $hwnd
    ${NSD_OnClick} $hwnd animation.play
  ${NSD_CreateButton} 144 150 64 32 "|> (x3)"
    Pop $hwnd
    ${NSD_OnClick} $hwnd animation.play3
  ${NSD_CreateButton} 216 150 64 32 "oo"
    Pop $hwnd
    ${NSD_OnClick} $hwnd animation.loop
  ${NSD_CreateButton} 288 150 64 32 "???"
    Pop $hwnd
    ${NSD_OnClick} $hwnd animation.twitchy
  InitPluginsDir
  nsDialogs::Show
FunctionEnd
Function animation.stop
  Pop $null
  SendMessage $animationControl ${ACM_STOP} 0 0
FunctionEnd
Function animation.play
  Pop $null
  ${MAKELONG} $0 $1 0 -1
  /* $0 = output variable
     $1 = temporary variable used by ${MAKELONG}
     $2 = start frame
     $3 = end frame (-1 = end of video) */
  SendMessage $animationControl ${ACM_PLAY} 1 $0
  /* 1 = play once */
FunctionEnd
Function animation.play3
  Pop $null
  ${MAKELONG} $0 $1 0 -1
  SendMessage $animationControl ${ACM_PLAY} 3 $0
  /* 1 = play three times */
FunctionEnd
Function animation.loop
  Pop $null
  ${MAKELONG} $0 $1 0 -1
  SendMessage $animationControl ${ACM_PLAY} -1 $0
  /* 1 = play indefinitely */
FunctionEnd
Function animation.twitchy
  Pop $null
  StrCpy $R2 0
  ${NSD_CreateTimer} animation.twitchy.next 1000
FunctionEnd
Function animation.twitchy.next
  /* there's 86 frames in the animation */
  ${If} $R2 < 76
    IntOp $R3 $R2 + 10
    ${MAKELONG} $0 $1 $R2 $R3
    SendMessage $animationControl ${ACM_PLAY} -1 $0
    IntOp $R2 $R2 + 10
  ${Else}
    ${NSD_KillTimer} animation.twitchy.next
    SendMessage $animationControl ${ACM_STOP} 0 0
  ${EndIf}
FunctionEnd 
Note that the AVI should -not- have a sound stream in it, or supposedly the control will refuse to play the video. I'm not sure what restrictions there are on the video codec used, but the example installer used an 8bit RLE video which works... re-encoding that to MS-VIDEO1 (a common, albeit old, codec on the Windows platform) and trying with that didn't work. So you may have to find an authoring suite or converter tool that lets you encode to 8bit MS-RLE for your own videos.
herdell#
I'm back here to another question:

How to show the video during the installation files in the system?

I want that just only during the installation files, the video plays in loop and the window of NSIS still hide, showing only the video, and after finish the installation of the files, the video stops to play, and the window of NSIS appear again in the finish page.

I know how to do this using images, but I've tried with videos using the script provided above by: Animaether, but I can't handle this, cause this is too complex to me.

Someone can help?

This is the video that I want to use in the script (if someone write one to me):



Thanx...
stass#
Code of Animaether why it does not work ... I can not play the files DivX, xVid...
The reason ?
Why there is no plug-in for video playback ?
Highcoder#
AVI is a container for different video formats (codecs). His code work with 8-bit RLE AVIs that has NO audio stream. I think the code for DivX and xVid will be much more complex.

...Note that the AVI should -not- have a sound stream in it, or supposedly the control will refuse to play the video. I'm not sure what restrictions there are on the video codec used, but the example installer used an 8bit RLE video which works... re-encoding that to MS-VIDEO1 (a common, albeit old, codec on the Windows platform) and trying with that didn't work. So you may have to find an authoring suite or converter tool that lets you encode to 8bit MS-RLE for your own videos...
stass#
8-bit RLE
This is not the format, and the misunderstanding ... It is a pity that no one has figured out how to play videos in NSIS ...
Highcoder#
You´re right that this explanation was not 100% exact. Runlengthencoding is a simple kompression. An the first AVIs were compressed with MJPEG & RLE. Both of them have very low requirements on hardware. You can create those Videos with VirtualDUB i think...
Kriggi#
Hi to All!

I want to play the video on custom page with MCI MultiMedia Command String system and use following code (for NSIS v3.0b3):

!define WS_BORDER 0x00800000
Var Video
Var StaticV
!include MUI2.nsh
OutFile "PlayVideoPage.exe"
!insertmacro MUI_PAGE_WELCOME
Page custom VideoPageShow VideoPageLeave
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
Function VideoPageShow
  !insertmacro MUI_HEADER_TEXT "Show video" "Please watch the video"
  nsDialogs::Create 1018
  Pop $Video
  ${If} $Video == error
    Abort
  ${EndIf}
  nsDialogs::CreateControl STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPCHILDREN}|${WS_BORDER}|${SS_CENTER} \
            0 65.82u 7.38u 165.87u 120.62u "$\r$\n$\r$\n$\r$\n$\r$\n$\r$\nHere must to be shown the video"
  Pop $StaticV
  SetCtlColors $StaticV "0x0000FF" "0x99FFFF"
  Call VideoShow
  nsDialogs::Show
  
FunctionEnd
Function VideoShow
  # Open MCI device and send the video file to STATIC control
  System::Call "winmm::mciSendString(t 'open $\"$EXEDIR\intro.wmv$\" type mpegvideo \
                                     alias myvideo parent $StaticV style child', t .r0, \
                                     i ${NSIS_MAX_STRLEN}, i 0)"
  # Resize the video frame to STATIC control
  System::Call "winmm::mciSendString(t 'put myvideo destination at 0 0 252 196', \
                                     t .r0, i ${NSIS_MAX_STRLEN}, i 0)"
  # Play video (loop)
  System::Call "winmm::mciSendString(t 'play myvideo repeat',t .r0, i ${NSIS_MAX_STRLEN}, i 0)"
FunctionEnd
Function VideoPageLeave
  # Stop play
  System::Call "winm::mciSendString(t 'stop myvideo',t .r0, i ${NSIS_MAX_STRLEN}, i 0)"
  
FunctionEnd
Function .onGUIEnd
  # Close MCI device
  System::Call "winm::mciSendString(t 'close myvideo',t .r0, i ${NSIS_MAX_STRLEN}, i 0)"
FunctionEnd
Section
SectionEnd 
But having the following problems:
  1. On the Windows XP system the video not show. On the custom page is visible only created control - STATIC. But if the mouse cursor to grab installer window and drag it, the video begins to appear. On the Windows 7 system the video can be seen immediately.
  2. If press on page the buttons "Next" or "Back" and go back to the custom page with the video, the video can not see any the Windows system.


Is it possible to fix it? 🙄
Anders#
You could try using a timer with a short timeout to start the video because the controls are not visible until somewhere inside nsDialogs::Show
T.Slappy#
What about embedding a TWebBrowser component in page? (different approach)

That is pretty easy and in web browser you can do anything: play video, animations, show texts etc etc....
Coby#
Play MP3 and WMV File

Created my custom player.
Coby#
Play Internet Radio Station

Playng internet radio station with command line using mplayer.exe
Coby#
When I wrote this code did not I thought it would be like someone is basically just an idea that I built it as I know I have not found anywhere an alternative to this code.
If there are other practical codes please present them here for documentation.
stass#
Coby
Practical code - a code that works well. Your player - slows down, freezes, produces errors, etc. That is - absolutely not suitable for use.
The idea is good, but the implementation is useless ...
I think it is better to use and adapt the plug-ins for Inno Setup...
Coby#
NSIS can now play all formats of video files
Copy the plugin ffmeg.dll and ffdshow.ax în directory of system $SYSDIR then register this file using regsvr32.exe

I hope it works on your computers, my computer works well

; info
Name "NSIS Play Video"
OutFile "NSIS Play Video.exe"
InstallDir "$TEMP\NSIS Play Video"
# COMPRESS
SetCompressor /SOLID /FINAL lzma
# RUN
RequestExecutionLevel "Admin"
# HIDE # SHOW
ShowInstDetails nevershow
ShowUninstDetails NeverShow
# INCLUDES
!include "MUI2.nsh"
!include "WinCore.nsh"
!include "nsDialogs.nsh"
!include "LogicLib.nsh"
!include "WinMessages.nsh"
!include "FileFunc.nsh"
# Stye
BrandingText /TRIMRIGHT " "
Page custom VideoPageShow VideoPageLeave 
Page instfiles
# LANGUAGES
!insertmacro MUI_LANGUAGE "English"
# WELCOME
!define ACS_CENTER 0x0001 
!define ACS_AUTOPLAY 0x0004 
!define /math ACM_OPENA ${WM_USER} + 100 
!define /math ACM_OPENW ${WM_USER} + 103 
!define ACM_OPEN ${ACM_OPENA} ; lets use the ANSI one. 
!define /math ACM_PLAY ${WM_USER} + 101 
!define /math ACM_STOP ${WM_USER} + 102 
!define WS_BORDER 0x00800000 
!define LINK_FFMeg_DLL "http://iloaddll*****zip/f/ffmpeg.dll.zip"
Function VideoPageShow 
  var /global Dlg
  var /global AnimationControl 
  var /global Btn_Play
  var /global Btn_Pause
  var /global Btn_Stop
  var /global Btn_Replay
  var /global Btn_Fullsctreen
  var /global Btn_Add
  var /global Btn_RegDll
  GetDlgItem $0 $HWNDPARENT 1
  ShowWindow $0 ${SW_HIDE}
  GetDlgItem $0 $HWNDPARENT 2
  ShowWindow $0 ${SW_HIDE}
  GetDlgItem $0 $HWNDPARENT 3
  ShowWindow $0 ${SW_HIDE}
  GetDlgItem $0 $HWNDPARENT 1990
  ShowWindow $0 ${SW_HIDE}
  GetDlgItem $0 $HWNDPARENT 1991
  ShowWindow $0 ${SW_HIDE}
  GetDlgItem $0 $HWNDPARENT 1992
  ShowWindow $0 ${SW_HIDE}
  System::Call "user32::SetWindowPos(i$HWNDPARENT,i,i,i,i 688,i 545,i 0x16)"
  nsDialogs::Create 1044
  Pop $Dlg
  ${If} $Dlg == "error"
   Abort
  ${EndIf}
  System::Call "user32::MoveWindow(i$Dlg,i0,i0,i 688,i 545,i0)"
  # Btn Add
  nsDialogs::CreateControl BUTTON 0x40000000|0x10000000|0x04000000|0x00010000 0 5% 90% 10% 5% "$(^BrowseBtn)"
  Pop $Btn_Add
  Strcpy $1 $Btn_Add
  GetFunctionAddress $3 ".onClick.Add"
  nsDialogs::onClick $1 $3
 # Btn Play
  nsDialogs::CreateControl BUTTON 0x40000000|0x10000000|0x04000000|0x00010000 0 15% 90% 10% 5% "Play"
  Pop $Btn_Play
  Strcpy $1 $Btn_Play
  GetFunctionAddress $3 ".onClick.Play"
  nsDialogs::onClick $1 $3
 # Btn Pause
  nsDialogs::CreateControl BUTTON 0x40000000|0x10000000|0x04000000|0x00010000 0 25% 90% 10% 5% "Pause"
  Pop $Btn_Pause
  Strcpy $1 $Btn_Pause
  GetFunctionAddress $3 ".onClick.Pause"
  nsDialogs::onClick $1 $3
 # Btn Stop
  nsDialogs::CreateControl BUTTON 0x40000000|0x10000000|0x04000000|0x00010000 0 35% 90% 10% 5% "Stop"
  Pop $Btn_Stop
  Strcpy $1 $Btn_Stop
  GetFunctionAddress $3 ".onClick.Stop"
  nsDialogs::onClick $1 $3
 # Btn Replay
  nsDialogs::CreateControl BUTTON 0x40000000|0x10000000|0x04000000|0x00010000 0 45% 90% 10% 5% "Replay"
  Pop $Btn_Replay
  Strcpy $1 $Btn_Replay
  GetFunctionAddress $3 ".onClick.Replay"
  nsDialogs::onClick $1 $3
 # Btn Fullsctreen
  nsDialogs::CreateControl BUTTON 0x40000000|0x10000000|0x04000000|0x00010000 0 55% 90% 12% 5% "Fullsctreen"
  Pop $Btn_Fullsctreen
  Strcpy $1 $Btn_Fullsctreen
  GetFunctionAddress $3 ".onClick.FullScreen"
  nsDialogs::onClick $1 $3
 # Btn Download FFMpeg
  nsDialogs::CreateControl BUTTON 0x40000000|0x10000000|0x04000000|0x00010000 0 80% 90% 15% 5% "Register Dll"
  Pop $Btn_RegDll
  Strcpy $1 $Btn_RegDll
  GetFunctionAddress $3 ".onClick.RegDll"
  nsDialogs::onClick $1 $3
 # Animation Play
  nsDialogs::CreateControl "SysAnimate32" ${WS_VISIBLE}|${ACS_CENTER}|${ACS_AUTOPLAY}|${WS_CHILD}|${WS_CLIPCHILDREN}|${WS_BORDER}|${SS_CENTER} "" 0% 0% 100% 85%  ''
  Pop $AnimationControl
  nsDialogs::Show 
   
FunctionEnd 
Function ".onClick.Add"
  var /GLOBAL MYVIDEOS
  nsDialogs::SelectFileDialog "open" "$VIDEOS" "All Video Files|*.*"
  Pop $0
  StrCmp $0 "error" +3
   StrCpy $MYVIDEOS "$0"
  ${If} $MYVIDEOS != ""
   System::Call "winmm.dll::mciSendString(t 'STOP myvideo',t .r0, i ${NSIS_MAX_STRLEN}, i 0)" 
   System::Call "winmm.dll::mciSendString(t 'STOP recvideo myvideo',t .r0, i ${NSIS_MAX_STRLEN}, i 0)"
   System::Call "winmm.dll::mciSendString(t 'CLOSE myvideo',t .r0, i ${NSIS_MAX_STRLEN}, i 0)" 
  ${EndIf}
FunctionEnd
Function ".onClick.Play"
  System::Call "winmm::mciSendString(t 'open $\"$MYVIDEOS$\" type mpegvideo alias myvideo parent $AnimationControl style child', t .r0, i ${NSIS_MAX_STRLEN}, i 0)" 
  System::Call "winmm::mciSendStringA(t 'window myvideo stretch',t .r0, i ${NSIS_MAX_STRLEN}, i 0)"
  System::Call "winmm::mciSendString(t 'put myvideo destination at 0 0 680 460', t .r0, i ${NSIS_MAX_STRLEN}, i 0)" 
  System::Call "winmm::mciSendStringA(t 'seek myvideo to ',t .r0, i ${NSIS_MAX_STRLEN}, i 0)"
  System::Call "winmm::mciSendString(t 'play myvideo repeat',t .r0, i ${NSIS_MAX_STRLEN}, i 0)" 
FunctionEnd 
Function ".onClick.Pause"
  System::Call "winmm.dll::mciSendString(t 'Pause myvideo',t .r0, i ${NSIS_MAX_STRLEN}, i 0)"
FunctionEnd 
Function ".onClick.Stop"
  System::Call "winmm.dll::mciSendString(t 'STOP myvideo',t .r0, i ${NSIS_MAX_STRLEN}, i 0)" 
  System::Call "winmm.dll::mciSendString(t 'STOP recvideo myvideo',t .r0, i ${NSIS_MAX_STRLEN}, i 0)" 
  ;System::Call "winmm.dll::mciSendString(t 'CLOSE myvideo',t .r0, i ${NSIS_MAX_STRLEN}, i 0)" 
FunctionEnd 
Function ".onClick.Replay"
  System::Call "winmm.dll::mciSendString(t 'PLAY myvideo REPEAT',t .r0, i ${NSIS_MAX_STRLEN}, i 0)"
FunctionEnd 
Function ".onClick.FullScreen"
  ShowWindow $HWNDPARENT ${SW_MAXIMIZE}
  System::Call "winmm::mciSendStringA(t 'play myvideo fullscreen',t .r0, i ${NSIS_MAX_STRLEN}, i 0)"
FunctionEnd 
Function ".onClick.RegDll"
  SetOutPath "$SYSDIR"
  File "ffmpeg.dll"
  File "ffdshow.ax"
  ExecWait 'regsvr32.exe "$SYSDIR\ffdshow.ax" /S'
  ExecWait 'regsvr32.exe "$SYSDIR\ffmpeg.dll" /S'
FunctionEnd 
Function VideoPageLeave 
  System::Call "winm::mciSendString(t 'stop myvideo',t .r0, i ${NSIS_MAX_STRLEN}, i 0)" 
FunctionEnd 
Function .onGUIEnd  
  System::Call "winm::mciSendString(t 'close myvideo',t .r0, i ${NSIS_MAX_STRLEN}, i 0)" 
FunctionEnd 
Section 
SetAutoClose "True"
SectionEnd 
Anders#
A media player that requires admin rights? A installer that plays videos? No matter what you are trying to create here, it is all kinds of horrible.