ASP. NET WP - Using Videos
Asp.net wp tutorial
ASP.NET WP - Working with Videos
In this chapter, we will explain how to display a video on your web page. In ASP.NET, you can easily play Flash (* .swf), Media Player (* .wmv), and Silverlight (* .xap) videos.
Sometimes you may need to post a video on your website.
You can display a video by linking to a site that already contains the video, like YouTube, Dailymotion, etc. .
To embed video from these sites directly into your own pages, you will need to get the site's HTML markup and then copy it to your page.
How to embed a video?
Let's take a look at a simple example where we'll embed a video from YouTube. To start, we need to create a new CSHTML file.
Enter EmbededVideo.cshtml in the name field and cclick OK.
< charset = "utf-8 " /> Sample embedded video
Sample embedded video
The following video provides an introduction to WebMatrix:
Let's launch the application and specify the following url - http: // localhost: "" 36905 / embededvideo then you will see the next output.
You can just play the video now.
Choose a drive
If you want play a video that is available on your own website. You can play videos from your site using th e Video Assistant, which makes a media player directly into a page.
As you know, there are many formats for video files, and each format usually requires different player and different way to configurge the reader.
In ASP.NET Razor pages, you can play a video in a web page using the video assistant.
Video wizard simplifies the process of embedding videos into a web page as it automatically generates the object and embeds HTML elements that are normally used for add video to the page.
The video assistant supports the following media players -
Display d 'a video using Windows Media Player
Let's take a look at a simple example where we will display a video on our webpage using Windows Media Player. To get started, we'll create a new CSHTML file.
Enter MediaPlayer.cshtml in the name field and click Ok.
Now let's create a new folder on your website and name it Media , then add the video file you want to play on your webpage as shown in the following screenshot.
Now replace the following code in the FlashPlayer file .cshtml.
Flash Video @ Video.Flash (path: "Media / Intro_WebMatrix.swf ", width: "400 ", height: "600 ", play: true, loop: true, menu: false, bgColor: "red ", quality: "medium ", scale: "exactfit ", windowMode: "transparent ")
When you run this application and specify the following url - http: // localhost: " "36905 / MediaPlayer then you will see the following error.
This is because we didn 't have the web wizard installed. To do so, let's open the NuGet from WebMatrix.
Find ASP.NET Web Helpers Library , then click Install. Once the installation is successful, you can run at new your app by specifying the same url and you will see that it will play the video using Windows Media Player.
Similarly, you can also use Silverlight player and Flash player to display videos on your web page.