How do I display video in my view? - ASP.NET MVC - asp.net-mvc

I am using asp.net mvc, and I'd like to add media player control in my view page, so how do I do that?

My first three google finds:
1) A control (doesn't know if it works with mvc though)
http://www.beansoftware.com/free-asp.net-controls/asp.net-media-player-control.aspx
2) Silverlight Player
http://www.asp.net/aspnet-in-net-35-sp1/videos/introduction-to-the-aspnet-mediaplayer-control
3) Embed
if it doesnt matter which mediaplayer will be used:
<embed id="videocontent" width="550" height="480" type="video/avi" autstart="true" loop="false" runat="server" style="border: gray 1px solid"></embed>.
or in valid xhtml
<object classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" id="player" width="320" height="260">
<param name="url" value="<%= ViewData["src"] %>" />
<param name="src" value="<%= ViewData["src"] %>" />
<param name="showcontrols" value="true" />
<param name="autostart" value="true" />
<!--[if !IE]>-->
<object type="video/x-ms-wmv" data="<%= ViewData["src"] %>" width="320" height="260">
<param name="src" value="<%= ViewData["src"] %>" />
<param name="autostart" value="true" />
<param name="controller" value="true" />
</object>
<!--<![endif]-->
</object>

+1 to Christina, but #1 may not work in an MVC app.
Her answers, plus you'll want to create a controller action that returns a FileResult. Check this question (its about an image, but a file is a file all the web round):
Can an ASP.NET MVC controller return an Image?

Related

When I apply vlc on the web, my computer's CPU becomes 100%. What should I do?

We applied VLC with Object tag. Up to 10 object tags with the same RTSP are CPU stable. However, if the number of Object tags increases by 12 or more, the CPU becomes 100%. What should I do???
<div id="object_container">
<object type="application/x-vlc-plugin"
version="VideoLAN.VLCPlugin.2" id="vlc21" width="517"
height="388" classid="clsid:9BE31822-FDAD-461B-AD51-
BE1D1C159921">
<param name="MRL" id="mrlVideo" value="" />
<param name="volume" value="50" />
<param name="autoplay" value="True" />
<param name="loop" value="false" />
<param name="fullscreen" value="false" />
<param name="wmode" value="transparent" />
<param name="toolbar" value="true" />
<param name="windowless" value="true" />
</object>
</div>
<script>
var rtst_url = "rtsp://ID:password#ipcamera ip:554/H.264/media.smp";
var options = [":network-caching=80", ":file-caching=80", ":hevc-fps=-340282346638528859811704183484516925440.000000", ":prefetch-buffer-size=250000", ":postproc-q=1", ":goom-width=100", ":goom-height=100", ":sout-chromecast-conversion-quality=3", ":preferred-resolution=240"];
vlc10.playlist.clear();
vlc10.playlist.add(rtsp_url, null , options);
vlc10.audio.toggleMute();
vlc10.playlist.play();
</script>

How to embed VLC in zk's zul?

Using HTML, I can successfully embed VLC by object tag( please see the codes below).
Nevertheless, I couldn't see any video being played when I embed the same html inside zul.
This one has succeeded:
<!DOCTYPE html>
<html>
<body>
<object
classid='clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921'
codebase='http://download.videolan.org/pub/videolan/vlc/last/win32/axvlc.cab'
id='vlc'
name='vlc'
class='vlcPlayer'
events='True'>
<param name='Src' value='rtsp://10.1.21.228/stream/live?ch=1_0' />
<param name='ShowDisplay' value='True' />
<param name='AutoLoop' value='False' />
<param name='AutoPlay' value='True' />
<embed id='vlcEmb' type='application/x-google-vlc-plugin' version='VideoLAN.VLCPlugin.2' autoplay='yes' loop='no' width='640' height='480'
target='rtsp://10.1.21.228/stream/live?ch=1_0' ></embed>
</object>
</body>
</html>
The following fails:
<?page title="new page title" contentType="text/html;charset=UTF-8"?>
<zk>
<html><![CDATA[
<object
classid='clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921'
codebase='http://download.videolan.org/pub/videolan/vlc/last/win32/axvlc.cab'
id='vlc'
name='vlc'
class='vlcPlayer'
events='True'>
<param name='Src' value='rtsp://10.1.21.228/stream/live?ch=1_0' />
<param name='ShowDisplay' value='True' />
<param name='AutoLoop' value='False' />
<param name='AutoPlay' value='True' />
<embed id='vlcEmb' type='application/x-google-vlc-plugin' version='VideoLAN.VLCPlugin.2' autoplay='yes' loop='no' width='640' height='480'
target='rtsp://10.1.21.228/stream/live?ch=1_0' ></embed>
</object>
]]></html>
</zk>
Please help, thanks.

Grails and swf application

I want to execute a flash application from grails 2.3.1.
I have a probleme loading my swf file's dependencies from a gsp.
Firstly, I tried to put all file needed into my web-app folder, and it worked like a charm :
wab-app
css
flash
index.html // <- Use for my first test.
flash.swf
prefs.xml
data-flash-folder
video-folder
txt-folder
xml-folder
intro.swf
main.swf
prefs.xml
static.xml
When I go to this url : http://localhost:8080/application-name/flash/index.html, all work like a charm.
So I decided to call it from a controller :
class FrontFlashController {
def openFlash() {
}
}
Here is my gsp calling flash :
<g:applyLayout name="frontFlash">
<div id="flash-render">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="1000" height="700" title="myFlash" >
<param name="movie" value="flash/flash.swf" />
<param name="FLASHVARS" value="idSession=rffcu96vn6j4tq3o56j1bgn5o7&lang=fr&xmlPath=prefs.xml">
<param name="quality" value="high" />
<embed src="/application-name/flash/flash.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="1000" height="700" flashvars="idSession=rffcu96vn6j4tq3o56j1bgn5o7&module=module&maxchapter=6&gochapter=3&jeu=0&cumul=285"></embed>
</object>
</div>
</g:applyLayout>
When calling the action by this url : http://localhost:8080/application-name/frontFlash/openFlash, my file 'flash.swf' is correctly loaded but none of his dependencies.
Here my firebug stack :
"NetworkError: 404 Not Found - http://localhost:8080/application-name/frontFlash/data-folder/static.xml"
"NetworkError: 404 Not Found - http://localhost:8080/application-name/frontFlash/data-folder/textes/default_en.xml"
"NetworkError: 404 Not Found - http://localhost:8080/application-name/frontFlash/data-folder/prefs.xml"
"NetworkError: 404 Not Found - http://localhost:8080/application-name/frontFlash/data-folder/intro.swf"
"NetworkError: 404 Not Found - http://localhost:8080/application-name/frontFlash/data-folder/main.swf"
Seems to grails is looking directly into my folder view instead of swf file folder.
How can I fix it ?
More, later I want to link swf ressource outside of my grails application, how can I do that ?
Snite
Try to use g.createLinkTo in src, like
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" title="myFlash" >
<param name="movie" value="flash/flash.swf" />
<param name="FLASHVARS" value="idSession=rffcu96vn6j4tq3o56j1bgn5o7&lang=fr&xmlPath=prefs.xml">
<param name="quality" value="high" />
<embed src="${g.createLinkTo(dir: 'flash', file: 'flash.swf')}" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" flashvars="idSession=rffcu96vn6j4tq3o56j1bgn5o7&module=module&maxchapter=6&gochapter=3&jeu=0&cumul=285"></embed>
</object>
I fix the problem adding <base href="/application-name/flash/"> into my head.
Here my final version of openFlash.gsp :
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>FLASH</title>
<base href="/application-name/flash/">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
swfobject.registerObject("myId", "9.0.0", "expressInstall.swf");
</script>
</head>
<body>
<div>
<g:if test="${flash}">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="1000" height="700" title="Module">
<param name="movie" value="flash.swf" />
<param name="FLASHVARS" value="idSession=rffcu96vn6j4tq3o56j1bgn5o7&lang=fr&xmlPath=prefs.xml">
<param name="quality" value="high" />
<embed src="${g.createLinkTo(dir: 'flash', file: 'flash.swf')}" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="1000" height="700" flashvars="idSession=rffcu96vn6j4tq3o56j1bgn5o7&maxchapitre=6&gochapitre=3&jeu=0&cumul=285"></embed>
</object>
</g:if>
<g:else>
<g:if test="${flash.error}">
<br />
<div class="alert alert-error">${flash.error}</div>
</g:if>
</g:else>
</div>
</body>
</html>

Thymeleaf flash(swf)issue

<body>
<object type="application/x-shockwave-flash" data="file3.swf"
id="applicationID" style="margin:0 50px;width:auto;height:auto;">
<param name="movie" value="file3.swf" />
<param name="wmode" value="transparent" /> <!-- Or opaque, etc. -->
<param name="FlashVars" value="" />
<param name="quality" value="high" />
<param name="menu" value="false" />
</object>
</body>
This is my thymeleaf page here file3.swf is the file i want play .
But when i run the page the flash does not play..!
I dont know how to show flash file in bowser, I assume that its correctly done :p
Have you check the firebug to see how its rendered ?

navigation doesn't work in primefaces carousel

I need to set some values in my model and navigate page to another one but nothing happens on button click(neither page navigated nor method triggered)....My code works perfect outside the carousel but inside carousel its doesn't work(no page navigation)
<p:carousel value="#{catalog.getServices()}" var="s" rows="1">
<h:outputLabel for="id" value="Service ID " />
<h:outputText id="id" value="#{s.id}" />
<br></br>
<h:outputLabel for="name" value="Service Name" />
<h:outputText id="name" value="#{s.name}" />
<br />
<h:commandLink action="detail">
<f:setPropertyActionListener value="#{s}" target="#{sh.currentService}" />
<h:commandButton value="getService" style="float:right;" />
</h:commandLink>
</p:carousel>
And my navigation works perfect outside this carousel
<h:commandLink action="detail">
<f:setPropertyActionListener value="#{s}" target="#{sh.currentService}" />
<h:commandButton value="getService" style="float:right;" />
</h:commandLink>
Above code can make my page navigate and method which I want to trigger is also working fine
You should avoid nesting h:commandButton inside h:commandLink.
Simply use h:commandButton this way:
<h:commandButton value="getService" action="#{yourBean.yourActionMethod}">
<f:setPropertyActionListener .../>
</h:commandButton>
And in your backing bean return the navigation target as result from the action method:
public String yourActionMethod() {
// do your stuff here
return "detail";
}
Try to put the commandButton inside p:column. I had this issue and here http://forum.primefaces.org/viewtopic.php?f=3&t=16120 helped me.

Resources