I am doing the same thing as you, the difference is that I show my modal
popup when a link is/was clicked.
My solution was have a basic aspx that only had the SWFObect suff and
JavaScript.
My HTML or this page is:
</head>
<body>
<form id="form1" runat="server">
<table>
<tr><td><div id="ytapiplayer">You need Flash player 8+ and JavaScript
enabled to view this video.</div></td></tr>
</table>
</form>
</body>
</html>
The code behind this page:
public partial class YouTubeVideo : System.Web.UI.Page
{
private string videoID;
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
this.Title = SiteConfig.SiteName + " : YouTube Video";
}
protected void Page_Load(object sender, EventArgs e)
{
if (!this.ClientScript.IsClientScriptIncludeRegistered("swfobject"))
this.ClientScript.RegisterClientScriptInclude("swfobject",
this.ResolveUrl("~/Scripts/swfobject.js"));
if (Request.QueryString["VideoID"] != null)
videoID = Request.QueryString["VideoID"].ToString();
else //Load Default Video
videoID = "Piltd4hh7pY";
StringBuilder sb = new StringBuilder();
sb.AppendLine("<script type=\"text/javascript\">");
sb.AppendLine("var params = { allowScriptAccess: \"always\" };");
sb.AppendLine("var atts = { id: \"" + SiteConfig.YouTubePlayerID + "\" };");
string ytUrl = SiteConfig.YouTubeUrl.Replace("PLAYER_ID",
SiteConfig.YouTubePlayerID).Replace("VIDEO_ID", videoID);
sb.AppendLine("swfobject.embedSWF(\"" + ytUrl + "\",");
sb.AppendLine("\t\t\"ytapiplayer\", \"853\", \"510\", \"8\", null, null,
params, atts);");
sb.AppendLine("function ytStop() {");
sb.AppendLine("\tvar player = document.getElementById(\""+
SiteConfig.YouTubePlayerID +"\");");
sb.AppendLine("\tplayer.stopVideo();");
sb.AppendLine("\tplayer.clearVideo();");
sb.AppendLine("}");
sb.AppendLine("</script>");
this.ClientScript.RegisterClientScriptBlock(typeof(Page), "jsYouTube",
sb.ToString());
}
}
See it at http://mazuma360.com/youtubevideo.aspx
Then on page which shows the video in the modal popup, inside the panel that
pops up I have an iframe and a close button.
<asp:Panel ID="pnYouTubeVideos" runat="server" cssclass="modalPopup" >
<table border="1" width="860">
<tr><td>
<iframe id="frmYT" name="frmYT" align="middle" runat="server"
frameborder="0" height="530" width="860" scrolling="no"></iframe></td></tr>
<tr align="center"><td><table align="center"><tr><td><asp:LinkButton
ID="lnkClose" runat="server" CssClass="button" OnClientClick="ytClose();
return false;"><span>Close
Window</span></asp:LinkButton></td></tr></table></td></tr>
</table>
</asp:Panel>
Note the panel can't have a style="display:none;" or the iframe won't been
seen by javascript. The iframes src can't be set at page load, ie9 has
issues.
The following javascript is used to show the video
function ytPopUp(videoID) {
var frameYT = document.getElementById('mainContents_frmYT');
frameYT.src = "/YouTubeVideo.aspx" + "?VideoID=" + videoID;
var modalPopupBehavior = $find('mpeYouTubeVideosBehavior');
modalPopupBehavior.show();
}
The following javascript stop and clears the video ytStop on the
youtubeVideo.aspx page. Then the modal popup is hidden.
function ytClose() {
document.getElementById('mainContents_frmYT').contentWindow.ytStop();
var modalPopupBehavior = $find('mpeYouTubeVideosBehavior');
modalPopupBehavior.hide();
}
See here: http://mazuma360.com/games.aspx?ConsoleID=1&GameID=1
Hope this helps.

On Tue, May 3, 2011 at 7:03 PM, Aran Rhee <[email protected]> wrote:

> I am wondering if this is a cross post in regards to the site:
> http://mazuma360.com/games.aspx?ConsoleID=1&GameID=1 ?
>
> (notice the same stop code from that thread).
>
> If so, I noticed that the YouTube player was actually throwing a runtime
> error:
>
> TypeError: Error #1009: Cannot access a property or method of a null object
> reference.
> at com.google.ads.templates.overlay::OverlayFlashTemplate/destroy()
>  at AbstractOverlayTemplate/stopAd()
> at com.google.ads.templates::TemplateLoader/destroy()
> at com.google.ads.templates::TemplateContainer/destroy()
>  at com.google.ads.templates::TemplateContainer/stopAd()
> at com.google.ads.templates::TemplateContainer/onStopAdRequest()
>  at flash.events::EventDispatcher/dispatchEventFunction()
> at flash.events::EventDispatcher/dispatchEvent()
>  at
> com.google.ads.instream.formats.templates.ui::TemplateAdUi/fireTemplateSharedEvent()
> at
> com.google.ads.instream.formats.templates.ui::TemplateAdUi/disposeContainer()
>  at com.google.ads.instream.formats.templates.ui::TemplateAdUi/dispose()
> at
> com.google.ads.instream.formats.common.ui::AbstractAdSenseVPAIDAdUi/stopAd()
>  at com.google.ads.instream.formats.common::VPAIDAdImpl/stopAd()
> at com.google.ads.instream.formats.common::VPAIDAdsManagerImpl/unload()
>  at AdsManagerWrapper/unload()
> at
> com.google.youtube.modules.ad.display::AfvInvideoAdDisplayState/destroy()
>  at com.google.youtube.modules.ad::AdSlot/destroyDisplayState()
> at com.google.youtube.modules.ad::AdSlot/destroy()
>  at com.google.youtube.modules.ad::AdBreak/destroyAdSlot()
> at com.google.youtube.modules.ad::AdBreak/destroyAdSlots()
>  at com.google.youtube.modules.ad::AdBreak/destroy()
> at com.google.youtube.modules.ad::AdPlaylist/destroyBreak()
>  at com.google.youtube.modules.ad::AdPlaylist/destroy()
> at com.google.youtube.modules.ad::AdModule/destroy()
>  at com.google.youtube.modules::ModuleHost/unload()
> at com.google.youtube.modules::ModuleHost/unregisterAll()
>  at com.google.youtube.application::VideoApplication/unloadModules()
> at
> com.google.youtube.application::WatchPageVideoApplication/unloadModules()
>  at com.google.youtube.application::VideoApplication/prepareVideo()
> at com.google.youtube.application::VideoApplication/stopVideo()
>  at Function/http://adobe.com/AS3/2006/builtin::apply()
>  at flash.external::ExternalInterface$/_callIn()
> at Function/<anonymous>()
>
> This could cause the audio not to stop if it is not killing off processes
> as it should.
>
> Regardsless, you should first ensure your method is actually being called
> by IE by putting in a alert or something at the beginning of your JS
> function. At least you can then verify you are getting "out of Flash" and
> "into js"...
>
> Basically, try to reduce the scope of your issue.
>
>
> Aran
>
> On Tue, May 3, 2011 at 3:24 PM, jb <[email protected]> wrote:
>
>> Aran,
>>
>> Thanks so much, but same thing happens.  Works great in Firefox, IE 7
>> & 8 continue to play the audio after closing the popup.
>>
>> jb
>>
>> On May 2, 11:08 am, Aran Rhee <[email protected]> wrote:
>> > Hmmm.
>> >
>> > Now I am not 100% on this (been a while since I did any EI work), but I
>> > think you might need to set both the name AND id in the attributes
>> values
>> > for ExternalInterface methods to work cross browser.
>> >
>> > (here is an example of all working communication methods using
>> swfobject:
>> http://www.bobbyvandersluis.com/swfobject/testsuite_2_2/test_dynamic_...)
>> >
>> > - I'd also set the div id for replacement in embedswf to the id name
>> > you actually want for EI (just to be sure)
>> > - I'd pass vars as part of the flashvars object for caching and
>> cleanliness
>> > reasons
>> > - I'd do some extra checking on the availability of the methods as
>> wellas
>> > the object in your stopVideo function
>> >
>> > <script type="text/javascript">
>> > var flashvars = {enablejsapi: 1, playerapiid: "myytplayer"};
>> > var params = { allowScriptAccess: "always" };
>> > var atts = { id: "myytplayer", name: "myytplayer" };
>> > swfobject.embedSWF("http://www.youtube.com/e/GtHDrLngXlc";,
>> "myytplayer",
>> > "425", "344", "8", false, flashvars, params, atts);
>> >
>> > function stopVideo()
>> > {
>> > var playerObj = document.getElementById("myytplayer");
>> >         if (playerObj && playerObj.stopVideo != "undefined" &&
>> > playerObj.clearVideo != "undefined")
>> > {
>> >             playerObj.stopVideo();
>> >           playerObj.clearVideo();}
>> > }
>> >
>> > </script>
>> >
>> > Cheers,
>> > Aran
>> >
>> >
>> >
>> > On Mon, May 2, 2011 at 9:16 AM, jb <[email protected]> wrote:
>> > > I'm using asp.net and am trying to have a modalPopupExtender box
>> > > appear and when someone clicks on an image, a YouTube video will play
>> > > in that modalPopup.  Have that all working great - loads video, etc.
>> > > I added the enablejsapi=1&version=3&playerapiid=ytplayer to the movie
>> > > and embed parameters and then added the following in javascript (also
>> > > tried just separately).  Now it will close in Netscape, but IE 7 and 8
>> > > ignore it.  Any ideas for IE - your help is appreciated?
>> >
>> > >    function stop() {
>> > >        var playerObj = document.getElementById("ytPlayer");
>> > >        if (playerObj) {
>> > >            playerObj.stopVideo();
>> > >            playerObj.clearVideo();
>> > >        }
>> > >    }
>> >
>> > > I then thought I had to add the whole swfObject to get this to work,
>> > > so I downloaded and referenced as follows - same thing.
>> >
>> > >  <script src="../swfObject/swfobject.js" type="text/javascript"></
>> > > script>
>> >
>> > >  <script type="text/javascript">
>> >
>> > >      var params = { allowScriptAccess: "always" };
>> > >      var atts = { id: "myytplayer" };
>> > >      swfobject.embedSWF("http://www.youtube.com/e/GtHDrLngXlc?
>> > > enablejsapi=1&playerapiid=myytplayer",
>> > >                       "ytapiplayer", "425", "344", "8", null, null,
>> > > params, atts);
>> >
>> > >  </script>
>> > > <script type="text/javascript" language="javascript">
>> > >    function stopVideo() {
>> > >        var playerObj = document.getElementById("myytplayer");
>> > >        if (playerObj) {
>> > >            playerObj.stopVideo();
>> > >            playerObj.clearVideo();
>> >
>> > >        }
>> > >    }
>> >
>> > >        <asp:ImageButton ID="imgBtnAmanda" runat="server"
>> > > ImageAlign="Middle" ImageUrl="~/media/quality/devMedAmanda.jpg" />
>> > >            <asp:Panel ID="pnlAmanda" runat="server"
>> > > CssClass="modalPopup">
>> > >            <asp:ImageButton ID="imgBtnCloseAmanda" runat="server"
>> > > ImageUrl="~/images/icon-x.gif" ImageAlign="Right" /><br /><p
>> > > align="center">
>> >
>> > >              <div id="ytapiplayer" style="width:425px; height:
>> > > 344px;">
>> > >                You need Flash player 8+ and JavaScript enabled to
>> > > view this video.
>> > >              </div>
>> > >                        <br /><br />Amanda Levesque's performance of
>> "To
>> > > Dream the
>> > > Impossible Dream"</p></asp:Panel>
>> > >            <ajaxToolkit:ModalPopupExtender ID="modalAmanda"
>> > > runat="server" TargetControlID="imgBtnAmanda"
>> > > PopupControlID="pnlAmanda" BackgroundCssClass="modalBackground"
>> > > CancelControlID="imgBtnCloseAmanda" OkControlID="imgBtnCloseAmanda"
>> > > OnOkScript="stopVideo;" onCancelScript="stopVideo;" />
>> >
>> > > --
>> > > You received this message because you are subscribed to the Google
>> Groups
>> > > "SWFObject" group.
>> > > To post to this group, send email to [email protected].
>> > > To unsubscribe from this group, send email to
>> > > [email protected].
>> > > For more options, visit this group at
>> > >http://groups.google.com/group/swfobject?hl=en.- Hide quoted text -
>> >
>> > - Show quoted text -
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "SWFObject" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/swfobject?hl=en.
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "SWFObject" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/swfobject?hl=en.
>



-- 
------------------------------------------------------------
mazuma360
Offical Site - http://mazuma360.com

-- 
You received this message because you are subscribed to the Google Groups 
"SWFObject" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/swfobject?hl=en.

Reply via email to