Hello all, i have a theoretical question.
With flash you can dynamically load flashvars to a video or audio flashobject.
But: I would already have a flash video which loads the flashvars like that. But i want to create html5 code (either audio/video) around it. Can i use the flash vars outside of the element/flash object?
Like loading the flash source (mp3) also to the HTML5 audio element, which surrounds the flash element?
To make it more visual:
HTML(5) Page.
Contains a flash object, nested within a HTML5 audio/video element.
C# page.
Dynamically loads the flashvars & params to the flash object. For example mp3source.
Problem:
Can i also load the mp3source flashvar/param to the HTML5 video/audio in some way?
To load the vars i would use htmlgenericcontrols. If someone has an idea about how/if i could create something like this... Please share it! :)
Thanks for the answers!
PS: Some Code (!Not working, just to give you a clue!)
C# Param
var mp3param = new HtmlGenericControl("param");
mp3param.Attributes.Add("name", "thevars");
var thevars= "mp3=" + src;
HTML Output
<audio id="htmlaudio" controls="">
<source src="thisshouldbetheflashmp3source" type="audio/mpeg">
<object type="application/x-shockwave-flash" data="audioplayer.swf" width="xx" height="xx" id="flashaudio" style="visibility: visible;">
<param name="thevars" value="mp3=Theflashmp3sourcethatdoesworkbutshouldalsobeusedinhtmlaudio">
</object>
</audio>
Lets assume, this is your object tag
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="550" height="400" id="movie_name" align="middle">
<param name="movie" value="<%=MovieName%>"/>
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="<%=MovieName%>" width="550" height="400">
<param name="movie" value="<%=MovieName%>"/>
<!--<![endif]-->
<a href="http://www.adobe.com/go/getflash">
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player"/>
</a>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
You can now create a property in the code behind to grab the data dynamically. Sample code below
public string MovieName{
get { return "Movie_name.swf"; }
}
Related
I want to play some sounds in my web page once I click a button. This is my code but it shows an error.
SoundPlayer x = new SoundPlayer();
x.SoundLocation = "WindowsBalloon.wav";
//x.Play();
x.PlaySync();
error:
Please be sure a sound file exists at the specified location.
but the file exists in my project and I'm sure that the address is correct.
You cannot play a file on a web page using the System.Media.Soundplayer class !!!
Reason
It will play sound on server-side not client-side.
As mentioned as in below links
- Problem With The C# System.Media.SoundPlayer Class On A Web Host
- What is the most “compatible” way of autoplaying sound ?
Solution
Other SO Answer over this same requirements.
Use Any other Flash or Silverlight based plugins.
Use html embed tag or html5 audio tag. Examples can be seen on w3schools
Html5-based audio solutions (works on modern browsers only)
<embed> tag: The <embed> tag defines a container for external (non-HTML) content. (It is an HTML5 tag, invalid in HTML 4, but works in all browsers).
<embed height="100" width="100" src="horse.mp3" />
<object> tag: The <object> tag can also define a container for external (non-HTML) content.
<object height="100" width="100" data="horse.mp3"></object>
<audio> tag: The <audio> element is an HTML5 element, invalid in HTML 4, but it works in all browsers.
<audio controls="controls" height="100" width="100">
<source src="horse.mp3" type="audio/mp3" />
<source src="horse.ogg" type="audio/ogg" />
<embed height="100" width="100" src="horse.mp3" />
</audio>
Please note the problems with html5-based solutions you must convert your videos to different formats.
- The <audio> element does not validate as HTML 4 and XHTML.
- The <embed> element does not validate as HTML 4 and XHTML.
- The <embed> element cannot "fall-back" to display an error.
You need to use <object> or <embed> html tags.
<object data="WindowsBalloon.wav"></object>
Or HTML5 tag
<audio src="WindowsBalloon.wav">
<p>Your browser does not support the audio element.</p>
</audio>
This works in HTML5 :
protected void Button1_Click(object sender, EventArgs e)
{
Response.Write("<embed height='0' width='0' src='Sound.wav' />");
}
This is what I think you want:
Server.MapPath(string path);
Returns the physical file path that corresponds to the specified virtual path on the Web server.
Parameters: path: The virtual path of the Web server.
Returns: The physical file path that corresponds to path.
SoundPlayer s = new SoundPlayer();<br>
s.SoundLocation = **Server.MapPath("WindowsBalloon.wav");**<br>
s.PlaySync();
Given full path i.e. c:\wavfiles\WindowsBalloon.wav
'wavfiles' above is a user privileged folder.
use x.PlayLooping()
function if you want to play sound file continuously
BE CAREFUL!
use one button to exit loop else sound file will run continuously. I suggest you to exit the loop: -
Code
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
x.Stop()
End Sub
If you need to play an ALARM sound programmatically you can do it this way:
<asp:Panel runat="server" ID="panBuzz" style="visibility:hidden">
<audio runat="server" id="Buzz" src="http://.....mp3" type="audio/mp3"/>
</asp:Panel>
Code behind (visual basic):
Dim cBuzz As HtmlControl = DirectCast(panBuzz.FindControl("Buzz"), HtmlControl)
cBuzz.Attributes.Add("autoplay", "autoplay")
Code behind (C#):
HtmlControl cBuzz = (HtmlControl)panBuzz.FindControl("Buzz");
cBuzz.Attributes.Add("autoplay", "autoplay");
try adding the drive letter to the path, such as "C:/WindowsBalloon.wav". But this would not play it on the client side. I would recomend trying HTML5 for the client side.
SoundPlayer s = new SoundPlayer();
s.SoundLocation = Server.MapPath("WindowsBalloon.wav");
s.PlaySync();
I'm new in ASP.Net.
Recently I tried to create a window control library and to use it in aspx web page but it seem like cannot recognize as user control in the page.
I tried to use the user control from the sample web site "http:// www.4guysfromrolla.com/articles/052604-1.aspx" and it work!
Then when i try to debug and notice the different:
Sample user control from www.4guysfromrolla.com:
WinControl
. The user control i created:
objtest
My user control appear as {Object} instead of {ControlAxSourcingSite}.
and when i alert the parameter it only show me "undefined".
I'm not sure what am I missing or do wrong. I try to find out why but end up no clue...not even Google can help. It's really frustrated.
Hope there are some one can help me.
Sorry if I'm for asking stupid question.
sample code in aspx:
<object id="objtest" height="0" width="0" classid="uscControl/uscTest.dll#uscTest.uscTest" VIEWASTEXT>
<param name="Response" value="test" />
</object>
<object id="MyWinControl1" height="200" width="240" classid="uscControl/WinControls.dll#WinControls.WinTreeview" VIEWASTEXT>
<param name="sCode" value="My Code1"/>
</object>
to call:
<input type="button" value="CallTest" onclick="CallTest();" />
...
function CallTest() {
alert(window.document.getElementById("objtest").Response);
alert(window.document.getElementById("MyWinControl1").sCode);
}
Thanks God..finally i found out the answer by myself.
The main cause is when I create the window control library I did not modify the "AssemblyInfor.cs" to set [assembly: ComVisible(true)]. This is the main cause the object return undefined in aspx.
Hope it help the others as well :)
I'm trying the code below but its not working..
<object width="425" height="344">
<embed src="C:\Users\fortress\Desktop\AppointmentApp.swf" type="application/x-shockwave-flash" width="425" height="344"></embed>
</object>
Also tried this. Not working also.
<object width="425" height="344">
<embed src="~/Styles/Images/AppointmentApp.swf" type="application/x-shockwave-flash" width="425" height="344"></embed>
</object>
Problem:
The swf is not displaying.
I saw an error when I open the designer saying that "A control type was not specified or the specified type could not be found." I already import the shockwave-player for flash but still this error appeared..
I want also that the .swf will be fullscreen played in .aspx.
I'm newbie in ASP.net.. SO yeah, please explain also the code if its okay...
Here's the output in client-side:
Here's the whole code for my client-side:
Thanks!
This isn't ASP.NET, this is HTML. It might be served to the client by an ASP.NET server-side application, but that makes no difference to the client.
As far as HTML goes, your paths are broken. In both cases:
C:\Users\fortress\Desktop\AppointmentApp.swf
~/Styles/Images/AppointmentApp.swf
In the first case you're referencing a file system path. This wouldn't work on any client computer which doesn't have that file. If the file is on the web server then no client will be able to access the web server's C: drive. In the second case you're using a server-side relative path with a ~, and no client will be able to make sense of that.
When the page renders, the path needs to reference the file from the client's perspective. Something like this:
/Styles/Images/AppointmentApp.swf
Or perhaps:
../../Styles/Images/AppointmentApp.swf
Or whatever the path is from the rendered page to the SWF file.
I'm not 100% sure if this works well for object/embed tags, but you might be able to use the ~ path reference if you make the tag a server-side control. That should just be as easy as adding runat="server" to the tag:
<embed runat="server" src="~/Styles/Images/AppointmentApp.swf" type="application/x-shockwave-flash" width="425" height="344"></embed>
This would indicate to the ASP.NET application that the control needs some server-side processing before it's rendered to the client, and that processing would include evaluating relative paths.
You need both <param> movie tag and <embed>. Try this:
<object type="application/x-shockwave-flash" width="425" height="344">
<param name="movie" value="/Styles/Images/AppointmentApp.swf">
<embed src="/Styles/Images/AppointmentApp.swf" type="application/x-shockwave-flash" width="425" height="344"></embed>
</object>
Good luck!
I'll do my best to convey my situation as the date I can give you is limited.
There is this button inside a webpage when clicked creates a new tab whose HTML source is somewhat like below.
<HTML><HEAD><META content="IE=5.0000" http-equiv="X-UA-Compatible">
<TITLE>Report Viewer Webpage</TITLE>
<META content="text/html; charset=windows-1252" http-equiv=Content-Type>
<SCRIPT src="javascript1.js"></SCRIPT>
<SCRIPT src="javascript2.js"></SCRIPT>
<SCRIPT src="anotherJavascript.js"></SCRIPT>
</HEAD>
<BODY onload="CallInit('ABC_DEFG_HIJKL_1_',''); window_onload();" onhelp=common_ShowHelp() leftMargin=0 topMargin=0 bgColor=#c6c6c6 currJsHelpVar="help_reports_viewer_dlg">
<OBJECT id=CRViewer codeBase="/viewer/activeXViewer/activexviewer.cab#Version=9,2,0,442" classid=CLSID:1123452WDUIHED:1325726GDUJBEA:12R432VD width="100%" height="99%" VIEWASTEXT>
<PARAM NAME="lastProp" VALUE="500">
<!--Bunch of other params go here-->
<PARAM NAME="_cx" VALUE="26987">
<SCRIPT language=VBScript>
<!--Some Business Logic-->
</SCRIPT>
<OBJECT id=ReportSource codeBase="/viewer/activeXViewer/activexviewer.cab#Version=9,2,0,442" classid=CLSID:1123452WDUIHED:1325726GDUJBEA:12R432VD width="1%" height="1%"></OBJECT>
<OBJECT id=ViewHelp codeBase="/viewer/activeXViewer/activexviewer.cab#Version=9,2,0,442" classid=CLSID:1123452WDUIHED:1325726GDUJBEA:12R432VD width="1%" height="1%"></OBJECT>
</BODY>
</HTML>
And the page content look something like this:
And of course this is a Crystal Report.
All I want to do is click on the neat little Export button sitting right beside Print button above the text preview.
And I am using Selenium to automate all this. But the problem is, selenium only works with HTML elements and I believe the buttons in the page are ActiveX controls or something else. And they are only loaded after the call to <Body> tag's onLoad call.
One of the biggest constraint is that this application only works in IE and the power of IE developer tools is not enabling me to inspect the button element. IE developer tools just doesn't see those buttons as HTML elements. They don't exist to IE developer tools. I am using IE 9 by the way.
What would help me in automating the clicking of that Export button ? Any javascript would help ??
When I inspected this webpage, the first <Object> right after the <Body> is taking all the space of the view. And I think that randomly generated elements are going inside it dynamically.
You can try FluentAutomation. It is written on top of Selenium and has Click on (x, y) coordinate function. I've managed to get it working for Crystal report. Please let me know if you have any problem.
Cheers,
Given the HTML code you're showing, it seems that the content of the page is an ActiveX.
As a result, there is no way for you to do any kind of automation with Selenium as you said it yourself, Selenium only works with HTML.
I've created a windows application with a WebBrowser control and trying to play youtube videos.. I've installed Adobe Shockwave Player, and tried to watch video on my windows application, but it doesn't show any videos. When I hit play button the screen looks like this
My code for playing video is
StreamWriter sw = new StreamWriter("utube.html");
string PlayString = currentVideoUrl.Trim().Replace("watch?v=", "v/");
string Finalplaycode = "<embed src=" + PlayString + "&hl=en&fs=1& type=application/x-shockwave-flash allowscriptaccess=always allowfullscreen=true width=425 height=344></embed>";
sw.Write(Finalplaycode);
sw.Close();
string PathToNavigate = Directory.GetParent(Application.ExecutablePath) + #"\utube.html";
webBrowser1.Navigate(PathToNavigate);
and my example video link is : http://www.youtube.com/watch?v=oZdnezj9Dfg&feature=BFa&list=PLD3E900BFF6534896&lf=plpp_video
can anyone help me about this issue? Did I missing any plug-in or something? I am using .NetFramework 4.0
One problem I see is that you're not quoting the parameters in the embed. Your embed will generate as:
<embed src=http://www.youtube.com/v/video_id...>
You need to quote those parameters:
<embed src="http://www.youtube.com/v/video_id...">
For example, here's an embed that works on my site:
<embed type="application/x-shockwave-flash" width="425" height="344"
src="http://www.youtube.com/v/UejelYnVI3U&hl=en&fs=1"></embed>
You might be interested in reading the official YouTube documentation. They've moved away from using embeds, in favor of iframes. That lets them use the HTML5 video player if it's available, or otherwise fall back to Flash. See http://www.google.com/support/youtube/bin/answer.py?answer=171780 for details.
Update:
The HTML file below embeds the same video in two ways: once using the iframe and once using the standard embed. It works find when I navigate to it with the WebBrowser control:
<html>
<body>
<iframe class="youtube-player" type="text/html" width="640" height="385"
src="http://www.youtube.com/embed/oZdnezj9Dfg" frameborder="0">
</iframe>
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0">
<param name="src" value="http://www.youtube.com/v/oZdnezj9Dfg&hl=en&fs=1" />
<embed type="application/x-shockwave-flash" width="425" height="344"
src="http://www.youtube.com/v/oZdnezj9Dfg&hl=en&fs=1">
</embed>
</object>
</body>
<html>
Try copying that and navigating to it in your application. Make sure that your program is creating the embed just like that.
Also, you can remove the outer <object> tag if you already have Flash installed. Then, the Flash embed looks just like what I showed originally.
And, there's no requirement that you have the HTML wrapper around it. It works fine if I just include the embed without the <html> and other tags.