开发者

Youtube video player in asp.net with c#

开发者 https://www.devze.com 2023-04-01 06:42 出处:网络
this is my first question in this site. I am designing and coding a new website nowadays. In asp.net with c#. My question is:

this is my first question in this site.

I am designing and coding a new website nowadays. In asp.net with c#. My question is:

I want to add a music player (youtube player) on default.aspx. In briefly, this website has 4 or 5 other pages and I want to play sounds without interrupting while browsing other page.

Is it possible or not ? And if it is possible, how ? Thanks.

I have researched this subject in this site, but I 开发者_运维知识库could not find a real answer.


You won't be able to do it with just C# or any other purely server side technology. Once you navigate to a new a page your embedded YouTube player will be trashed. To achieve the result, you have to do some work on the client side with JavaScript. The simplest (but possibly least elegant) approach is to have "default.aspx" be a page which contains the main navigation framework within an iframe. The navigation of the site then happens all within the iframe without refreshing "default.aspx".

A problem with this is that it doesn't update the URL in the URL bar, and the page history is not updated. So you can get around this (sort of) by navigating the container page to hash tag pages, such as "default.aspx#page1", "default.aspx#page2", etc. at the same time that you navigate the iframe'd page to the real content at say "page1.aspx", "page2.aspx". Your tool for this will be the JavaScript "window.location" object.

A much cooler and cutting edge approach is using something like the client side MVC technology that has just come out in YUI 3.4.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号