flash flv player with an AJAX playlist

flash flv player with an AJAX playlist

am 29.01.2008 01:01:01 von M1iS

I'm trying to create a playlist control using AJAX to be used with a flash
video player. I have created the playlist control out of a 2 GridView
controls in an update panel. The first GridView is my list of playlists and
the second GridView is a list of playlist items for the selected playlist.
When a playlist item is selected the html for the flash video player is
generated and inserted into a DIV and the video begins playing. My problem
is that when a new playlist is clicked to be browsed and before another
playlist item is selected my video starts over. I've included my code below.
Any help would be greatly appreciated. Thanks,
--
Scott W.


Markup:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Player.aspx.cs"
Inherits="Player" %>

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



Playlist Demo














Playlist:

AutoGenerateColumns="False" DataKeyNames="PlaylistID"
EmptyDataText="No records found" ShowHeader="False"
AutoGenerateSelectButton="True"
OnSelectedIndexChanged="grdPlaylists_SelectedIndexChanged">

HeaderText="Playlist" ReadOnly="True" ShowHeader="False" />




Items:

AutoGenerateColumns="False" DataKeyNames="ItemUrl"
EmptyDataText="No records found" ShowHeader="False"
OnRowCommand="grdItems_RowCommand">

HeaderText="Name" ReadOnly="True" ShowHeader="False" />


CommandName="Play" Text="Play" CommandArgument='<%# Eval("ItemUrl") %>' />













Code behind:

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Player : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
grdPlaylists.DataSource = PlaylistController.GetPlaylists();
grdPlaylists.DataBind();
}
}

protected void grdPlaylists_SelectedIndexChanged(object sender,
EventArgs e)
{
grdItems.DataSource =
PlaylistController.GetPlaylistItems(Convert.ToInt32(grdPlayl ists.SelectedValue));
grdItems.DataBind();
}

protected void grdItems_RowCommand(Object sender,
GridViewCommandEventArgs e)
{
if (e.CommandName == "Play")
{
displayPlayer(e.CommandArgument.ToString());
}

}

private void displayPlayer(string mediaUrl)
{
Web20.Players.FlowPlayer121.Clip media = new
Web20.Players.FlowPlayer121.Clip();
media.Url = mediaUrl;

Web20.Players.FlowPlayer121 p = new Web20.Players.FlowPlayer121();
p.AutoPlay = true;
p.Loop = false;
p.InitialScale =
Web20.Players.FlowPlayer121.InitialScaleOptions.scale;
p.Playlist.Add(media);

divPlayer.InnerHtml = p.Html;
}
}