Hi there,
I have a simple book application where each page contains a video player (Framework Player). It works ok with 5 or less pages, but when the number of pages is more than 5, it drops (or unload) the excess pages in FIFO basis.
My question is: Is there any place to configure for more than 5 players?
The following is the code used.
I have a simple book application where each page contains a video player (Framework Player). It works ok with 5 or less pages, but when the number of pages is more than 5, it drops (or unload) the excess pages in FIFO basis.
My question is: Is there any place to configure for more than 5 players?
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 Microsoft.SilverlightMediaFramework.Player; |
using Microsoft.Web.Media.SmoothStreaming; |
using Telerik.Windows.Controls; |
namespace TestPlayer |
{ |
public partial class MainPage : UserControl |
{ |
public MainPage() |
{ |
InitializeComponent(); |
int NumberOfPages = 5; |
setBook(NumberOfPages); |
} |
private void setBook(int numOfPages) |
{ |
//same source for all players |
string BigBunny = "http://video3.smoothhd.com.edgesuite.net/ondemand/Big%20Buck%20Bunny%20Adaptive.ism/Manifest"; |
//Create book |
RadBook myBook = new RadBook(); |
myBook.Margin = new Thickness(10, 10, 10, 10); |
myBook.Width = LayoutRoot.Width; |
myBook.Height = LayoutRoot.Height; |
myBook.PageChanged += new Telerik.Windows.RadRoutedEventHandler(myBook_PageChanged); |
int pageNumber = 1; |
for (int i = 0; i < numOfPages; i++) |
{ |
Grid myGrid = new Grid(); |
TextBlock myText = new TextBlock(); |
myText.Text = "Page " + pageNumber++.ToString(); |
myText.HorizontalAlignment = HorizontalAlignment.Center; |
myText.VerticalAlignment = VerticalAlignment.Top; |
myGrid.Children.Add(myText); |
Player myPlayer = new Player(); |
myPlayer.Name = "player_" + i.ToString(); |
myPlayer.PlayControlClicked += new RoutedEventHandler(myPlayer_PlayControlClicked); |
myPlayer.Width = 600; |
myPlayer.Height = 400; |
myPlayer.Margin = new Thickness(10, 15, 10, 10); |
myPlayer.VerticalAlignment = VerticalAlignment.Top; |
CoreSmoothStreamingMediaElement myMediaElement = new CoreSmoothStreamingMediaElement(); |
myMediaElement.AutoPlay = false; |
myMediaElement.SmoothStreamingSource = new Uri(BigBunny, UriKind.Absolute); |
myPlayer.MediaElement = myMediaElement; |
myGrid.Children.Add(myPlayer); |
myBook.Items.Add(myGrid); |
} |
//Add book to LayoutRoot |
LayoutRoot.Children.Add(myBook); |
} |
void myBook_PageChanged(object sender, Telerik.Windows.RadRoutedEventArgs e) |
{ |
pausePlayers(); |
} |
void myPlayer_PlayControlClicked(object sender, RoutedEventArgs e) |
{ |
pausePlayers(); |
Player myPlayer = (Player)sender; |
myPlayer.MediaElement.Play(); |
} |
private void pausePlayers() |
{ |
RadBook myBook = (RadBook)LayoutRoot.FindChildByType<RadBook>(); |
for (int i = 0; i < myBook.Items.Count; i++) |
{ |
Grid myGrid = (Grid)myBook.Items[i]; |
Player myPlayer = (Player)myGrid.FindChildByType<Player>(); |
myPlayer.MediaElement.Pause(); |
} |
} |
} |
} |