|
|
Hello,
Is there a way to integrate the video player in an already existing page.xaml?
I don't want to have two different .xap files one for the video player and one for the application
Thanks
|
|
|
|
I'd like to know this as well. I added the project to my solution and added a reference from my Silverlight app to the video player project, but I can't figure out how to use the control from within my application. It seems like too much of the player
is tied to the application - a control version would be very useful.
|
|
Oct 9, 2008 at 11:18 PM
Edited Oct 9, 2008 at 11:29 PM
|
Using the source code I have been able to do this with a few minor changes. Here's the steps I followed:
1. Created a subfolder on my project called "VideoPlayer" and copied all the source code (EXCEPT for the App.xaml.xs) from the VideoPlayer (or VideoProject- min) project here.
2. Copy the Application_Startup "foreach" code block and FormatUri() methods from the player's App.xaml.cs to my App.xaml.cs. I don't think the
HtmlPage.RegisterScriptableObject line is needed since the only scriptable method (Player.SeekPlayback) isn't called from a script that I can see.
3. Copy\set the initParams in my HTMLtag:
4. To avoid confusion with my Page I renamed the VideoPlayer's Page to Player
* Renamed Page.xaml to Player.xaml (renames .xaml.xs as well).
* Changed x:Class="VideoPlayer.Page" to x:Class="VideoPlayer.Player" in Player.xaml
* Changed Page : UserControl to VideoPlayer : UserControl in Player.xaml.cs
* Changed Page() to VideoPlayer() in Player.xaml.cs
* After doing the above and compiling I was able to add a "Player" custom control to my page via Expression Blend, which nicely adds in the xmlns declaration.
5. Changed all references from "App" to "Application" in Player.xaml.cs, otherwise I had compile errors.
6. In order to make this control more usuable for my project, I added a few utility methods, shown below. I think all the media control functionality could\should be exposed, but that's just my opinion.
Play\Stop is so my application can start\stop the video programatically.
Mediacontrol.xaml.cs
public void Play() { btnPlay.IsChecked = true; }
public void Stop() {
btnPlay.IsChecked = false;
_media.Position = new TimeSpan(0);
}
Player.xaml.cs
public void Play() { mediaControls.Play(); }
public void Stop() { mediaControls.Stop(); }
MediaReady event is so to enable\disable an external play button (initially the video player is hidden in my application).
public event EventHandler MediaReady;
private void mediaPlayer_MediaOpened(object sender, RoutedEventArgs e) {
if (this.MediaReady != null)
MediaReady(this, new EventArgs());
}
in Player.Page_Loaded() I added:
mediaPlayer.MediaOpened += new RoutedEventHandler(mediaPlayer_MediaOpened);
|
|
|
|
Thanks a bunch for this. It saved me a lot of time.
Helen
|
|
|
|
Thanks a bunch for this. It saved me a lot of time.
Helen
|
|
|
|
Hi,
Thanks for the code.
But i am getting some errors like
Error 1
The type name 'MediaSlider' does not exist in the type 'VideoPlayer.VideoPlayer'
C:\bala\Silverlight\2\PhotoBrowserWebSource\PhotoBrowser\obj\Debug\VideoPlayer\mediaControl.g.cs
85 49
PhotoBrowser
Error 2
The type name 'spinner' does not exist in the type 'VideoPlayer.VideoPlayer'
C:\bala\Silverlight\2\PhotoBrowserWebSource\PhotoBrowser\obj\Debug\VideoPlayer\mediaControl.g.cs
87 42
PhotoBrowser
Error 3
The name 'InitializeComponent' does not exist in the current context
C:\bala\Silverlight\2\PhotoBrowserWebSource\PhotoBrowser\VideoPlayer\Player.xaml.cs
30 13
PhotoBrowser
Error 4
The name 'LayoutRoot2' does not exist in the current context
C:\bala\Silverlight\2\PhotoBrowserWebSource\PhotoBrowser\VideoPlayer\Player.xaml.cs
40 13
PhotoBrowser
Error 5
The name 'LayoutRoot' does not exist in the current context
C:\bala\Silverlight\2\PhotoBrowserWebSource\PhotoBrowser\VideoPlayer\Player.xaml.cs
41 13
PhotoBrowser
around 51 errors
do we need to change the namespace also, i have done all the chagnes mentioned in the above post
Regards,
Bala
|
|
|
|
Hi, i have succeeded in integrating the project into .XAML , building it with no error. And then what to do? how to set the media source for the video to play? I tried something like this:
<vid:mediaControl Media="http://www.sonypictures.com/movies/21/video/trailer/21_trailer_high.asx" EnableMarkers="True" width="400" height="300"/>
But it won't work. Should i go with <vid:Player /> instead? Or maybe set the source from code-behind?
Thanks a bunch!
|
|
Coordinator
Aug 20, 2009 at 8:07 PM
|
It wasn't designed to work as a control within an existing app. It can be done, but you'd have to change some things as most params are driven by the InitParams of the <object> tag.
-th
On Wed, Aug 19, 2009 at 8:43 PM, ume <notifications@codeplex.com> wrote:
From: ume
Hi, i have succeeded in integrating the project into .XAML , building it with no error. And then what to do? how to set the media source for the video to play? I tried something like this:
<vid:mediaControl Media="http://www.sonypictures.com/movies/21/video/trailer/21_trailer_high.asx" EnableMarkers="True" width="400" height="300"/>
But it won't work. Should i go with <vid:Player /> instead? Or maybe set the source from code-behind?
Thanks a bunch!
|
|
|
|
hi anyone has been able to integrate the dll in your xaml?
I have extracted the XAP in a dll:
-VideoPlayer.dll
How I can use it in a user control?
|
|
Feb 17, 2012 at 8:05 AM
Edited Feb 17, 2012 at 8:06 AM
|
hzhkx4 wrote:
Using the source code I have been able to do this with a few minor changes. Here's the steps I followed:
1. Created a subfolder on my project called "VideoPlayer" and copied all the source code (EXCEPT for the App.xaml.xs) from the VideoPlayer (or VideoProject- min) project here.
2. Copy the Application_Startup "foreach" code block and FormatUri() methods from the player's App.xaml.cs to my App.xaml.cs. I don't think the
HtmlPage.RegisterScriptableObject line is needed since the only scriptable method (Player.SeekPlayback) isn't called from a script that I can see.
3. Copy\set the initParams in my HTMLtag:
4. To avoid confusion with my Page I renamed the VideoPlayer's Page to Player
* Renamed Page.xaml to Player.xaml (renames .xaml.xs as well).
* Changed x:Class="VideoPlayer.Page" to x:Class="VideoPlayer.Player" in Player.xaml
* Changed Page : UserControl to VideoPlayer : UserControl in Player.xaml.cs
* Changed Page() to VideoPlayer() in Player.xaml.cs
* After doing the above and compiling I was able to add a "Player" custom control to my page via Expression Blend, which nicely adds in the xmlns declaration.
5. Changed all references from "App" to "Application" in Player.xaml.cs, otherwise I had compile errors.
6. In order to make this control more usuable for my project, I added a few utility methods, shown below. I think all the media control functionality could\should be exposed, but that's just my opinion.
Play\Stop is so my application can start\stop the video programatically.
Mediacontrol.xaml.cs
public void Play() { btnPlay.IsChecked = true; }
public void Stop() {
btnPlay.IsChecked = false;
_media.Position = new TimeSpan(0);
}
Player.xaml.cs
public void Play() { mediaControls.Play(); }
public void Stop() { mediaControls.Stop(); }
MediaReady event is so to enable\disable an external play button (initially the video player is hidden in my application).
public event EventHandler MediaReady;
private void mediaPlayer_MediaOpened(object sender, RoutedEventArgs e) {
if (this.MediaReady != null)
MediaReady(this, new EventArgs());
}
in Player.Page_Loaded() I added:
mediaPlayer.MediaOpened += new RoutedEventHandler(mediaPlayer_MediaOpened);
I know that this thread is quite old, but maybe somebody can help me... I have integrated the control into my Silverlight 3 Application following this instructions. Everything seems to work OK (I can see the player on my app), but when I try to set the Source
property of the mediaPlayer, MediaFailed event is fired with this exception message "AG_E_NETWORK_ERROR".
Any idea?
|
|
|
|
Finally I found the solution in this post: http://forums.silverlight.net/t/29237.aspx/1
I was facing an issue while binding Image URL to an Image in Silverlight app. I solved it by publishing the application to IIS instead of running it from the file system . Refer to my blog for more details
http://nileshgule.blogspot.com/2011/06/ngtweet-part-5-big-bang-refactoring.html
|
|