using System;
using
System.Collections.Generic;
using
System.Linq;
using System.Net;
using
System.Windows;
using
System.Windows.Controls;
using
System.Windows.Documents;
using
System.Windows.Input;
using
System.Windows.Media;
using
System.Windows.Media.Animation;
using
System.Windows.Shapes;
using
HelnixPlayerUControl;//<<==Add player UserControl
library
namespace
TestPlayerLibrary
{
public partial class MainPage : UserControl
{
//Add This line to Create Object of the Player
HSPlayer
myHSPlayer = null;
public
MainPage(IDictionary<string, string>
_initParam)
{
InitializeComponent();
//Add this Loading event to LayoutRoot
LayoutRoot.Loaded += new RoutedEventHandler(LayoutRoot_Loaded);
}
void
LayoutRoot_Loaded(object sender, RoutedEventArgs e)
{
//These are video control you can use in any of your fucntions
//myHSPlayer.Play();
//myHSPlayer.Pause();
//myHSPlayer.Stop();
//myHSPlayer.Forward();
//myHSPlayer.Backward();
//Add this event to fire on Full Screen Changed
Application.Current.Host.Content.FullScreenChanged +=
new EventHandler(Content_FullScreenChanged);
// Add This line to Create Object Of initParams Options class
initParamsOptions
ipo = new
initParamsOptions();
//Sets the overall height of the control.
ipo.height = "420";
//Sets the overall width of the control.
ipo.Width = "530";
//Sets the location of the file to play
ipo.srcfile = "http://www.helnix.com/ClientBin/Clips/ClipShow.mp4";
//is the video source iis media smooth stream.default false
ipo.isSmoothStream = "false;";
//If you play a movie, set video header name.
ipo.srcname = "Iron man 2";
//If you play a movie, set video information
ipo.srcinfo = "The world is aware that billionaire inventor Tony Stark is
the armored Super Hero Iron Man. Under pressure from the government, the press
and the public to share his technology with the military, Tony is unwilling to
divulge the secrets behind the Iron Man armor because he fears the information
will slip into the wrong hands. With Pepper Potts, and James Rhodey Rhodes at
his side, Tony forges new alliances and confronts powerful new forces.\n\n"
+ "Production Status: In Production/Awaiting
Release\n"
+ "Genres: Action/Adventure, Science
Fiction/Fantasy, Adaptation and Sequel\n"
+ "Release Date: May 7th, 2010 (wide)\n"
+ "Distributors: Paramount Pictures\n"
+ "Production Co.: Marvel Studios\n"
+ "Studios: Paramount Pictures\n"
+ "Filming Locations: Manhattan Beach, California
USA\n"
+ "Manhattan Beach, California, USA\n"
+ "Produced in: United States\n";
//If you play a movie, set this to the url of a preview image.
ipo.srcimage = "http://www.helnix.com/ClientBin/Clips/IronManImage.png";
//Sets the location of the video list xml file.
ipo.videolist = "vMapClips.xml";
//only apply when you use UserControl.Set userControl background Color
ipo.backcolor = new
SolidColorBrush(Colors.Black);
//Set this to true to automatically start playing when the page loads
ipo.autostart = true;
//Sets how to stretch movies to make them fit the display. The default stretches
to fit the display.
//Set this to Fill, Uniform, UniformToFill or None.
ipo.stretch = vStretch.Fill;
//Set this to true to automatically repeat playback of the file (an infinite
loop).
ipo.repeat = false;
//Set this to true to mute the player on startup.
ipo.mute = false;
//Set true to hide video list if you don't have a video list.
ipo.HideVideolistButton = false;
//Set true to hide video info if you don't have a video info.
ipo.HideVideoInfoButton = false;
//sets the startup volume for playback of sounds and movies. set scale 1-10.
ipo.volume = 5;
//Add the initParam to userControl
myHSPlayer = new HSPlayer(ipo);
//Add this event to fire on video ended
myHSPlayer.VideoEnded += new HSPlayer.VideoEndedHandler(myHSPlayer_VideoEnded);
//Add User Control to Canvas
PlayerBox.Children.Add(myHSPlayer);
//<=== Add This line to Add player Control to your
application.
}
//The use of this event in case you had a list of videos and you
//want them to play in seq or you want to do something when the video ended.
void
myHSPlayer_VideoEnded(object sender, EventArgs e)
{
//is the video source iis media smooth stream.default false.this
is a must when you change source.
myHSPlayer.isSourceSmoothStream = false;
//Change to next video location.
myHSPlayer.ChangeSource("http://www.helnix.com/ClientBin/Clips/Clashofthetitan.mp4");
//Play the video
myHSPlayer.Play();
}
private
void Content_FullScreenChanged(object sender, EventArgs
e)
{
try
{
if
(!Application.Current.Host.Content.IsFullScreen)
{
Application.Current.Host.Content.IsFullScreen
= false;
RepositionNormalScreen();
}
else
{
Application.Current.Host.Content.IsFullScreen =
true;
RepositionOnFullScreen();
}
}
catch
(Exception ex)
{
;
}
}
private
void RepositionOnFullScreen()
{
try
{
// Alignment of Control
PlayerBox.HorizontalAlignment =
HorizontalAlignment.Left;
PlayerBox.VerticalAlignment = VerticalAlignment.Top;
PlayerBox.SetValue(Canvas.LeftProperty, 0.0);
PlayerBox.SetValue(Canvas.TopProperty, 0.0);
}
catch
(Exception ex)
{
;
}
}
private
void RepositionNormalScreen()
{
try
{
// Alignment of Control back the way it's was
PlayerBox.HorizontalAlignment =
HorizontalAlignment.Center;
PlayerBox.VerticalAlignment = VerticalAlignment.Center;
PlayerBox.SetValue(Canvas.LeftProperty, 16.0);
PlayerBox.SetValue(Canvas.TopProperty, 85.0);
}
catch
(Exception ex)
{
;
}
}
}
}