Embedding a VLC window in a Powershell GUI
Posted: 12 Jun 2015 09:58
Hi,
i'm writing a bit of code to display a slideshow on a windows 7 machine by using Powershell.
I was wondering if it's possible to trigger the vlc player in an embedded powershell gui. If possible i can opt between a standard slide show or show a video file.
At the moment i haven't found the appropriate code to use VLC. I've only got code to trigger wmp which i dislike ( otherwise i'd not be an avid VLC fan ).
Is there anyone who's already tried this & succeeded?
What i'd like is something that looks like this but with the possibility to define start / stop / pause & play again buttons in the window
The most basic code i have to trigger WMP is this
I've found other code but it requires i use XML
The code i'm trying to adapt comes from rakatechblog.wordpress.com
Any suggestions are welcome.
i'm writing a bit of code to display a slideshow on a windows 7 machine by using Powershell.
I was wondering if it's possible to trigger the vlc player in an embedded powershell gui. If possible i can opt between a standard slide show or show a video file.
At the moment i haven't found the appropriate code to use VLC. I've only got code to trigger wmp which i dislike ( otherwise i'd not be an avid VLC fan ).
Is there anyone who's already tried this & succeeded?
What i'd like is something that looks like this but with the possibility to define start / stop / pause & play again buttons in the window
The most basic code i have to trigger WMP is this
Code: Select all
$wmp = New-Object -ComObject WMPlayer.OCX
$wmp.openPlayer("c:\temp\test.mp4")
The code i'm trying to adapt comes from rakatechblog.wordpress.com
Code: Select all
#WPF Library for Playing Movie and some components
Add-Type -AssemblyName PresentationFramework
Add-Type -AssemblyName System.ComponentModel
#XAML File of WPF as windows for playing movie
[xml]$XAML = @"
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="PowerShell Video Player" Height="355" Width="553" ResizeMode="NoResize">
<Grid Margin="0,0,2,3">
<MediaElement Height="250" Width="525" Name="VideoPlayer" LoadedBehavior="Manual" UnloadedBehavior="Stop" Margin="8,10,10,61" />
<Button Content="Pause" Name="PauseButton" HorizontalAlignment="Left" Margin="236,283,0,0" VerticalAlignment="Top" Width="75"/>
<Button Content="Play" Name="PlayButton" HorizontalAlignment="Left" Margin="236,283,0,0" VerticalAlignment="Top" Width="75"/>
</Grid>
</Window>
"@
#Movie Path
[uri]$VideoSource = "C:UsersRakaDownloadsHiVi! - Orang Ke-3 Official MV HD.mp4"
#Devide All Objects on XAML
$XAMLReader=(New-Object System.Xml.XmlNodeReader $XAML)
$Window=[Windows.Markup.XamlReader]::Load( $XAMLReader )
$VideoPlayer = $Window.FindName("VideoPlayer")
$PauseButton = $Window.FindName("PauseButton")
$PlayButton = $Window.FindName("PlayButton")
#Video Default Setting
$VideoPlayer.Volume = 100;
$VideoPlayer.Source = $VideoSource;
$VideoPlayer.Play()
$PauseButton.Visibility = [System.Windows.Visibility]::Visible
$PlayButton.Visibility = [System.Windows.Visibility]::Hidden
#Button click event
$PlayButton.Add_Click({
$VideoPlayer.Play()
$PauseButton.Visibility = [System.Windows.Visibility]::Visible
$PlayButton.Visibility = [System.Windows.Visibility]::Hidden
})
$PauseButton.Add_Click({
$VideoPlayer.Pause()
$PauseButton.Visibility = [System.Windows.Visibility]::Hidden
$PlayButton.Visibility = [System.Windows.Visibility]::Visible
})
#Show Up the Window
$Window.ShowDialog() | out-null