views:

276

answers:

4

Is it possible to embed an audio object (mp3, wma, whatever) in a web-enabled InfoPath form ?

If it is, how do you do it ?

A: 

Edit: My apologies, I missed that the question was about Web forms - for which the below does not work. Must learn to read the question fully!

  1. Go to menu View
  2. Click on Design Tasks
  3. Select Controls in the 'Design Tasks' Task pane
  4. Click on the 'add or remove custom controls' button to install your custom control
  5. Click on the Add button and select ActiveX Control
  6. Select the Windows Media Player control
  7. Select the necessary properties for databinding and finish the wizard.

After you have added the control, you can drag and drop the control on your screen. Right-Click on the control and select the 'Windows Media Player properties' Fill in the URL to automatically embed the file to play.

Martin
+1  A: 

@Martin

That works for local forms that open in InfoPath. Nathan was asking about web-enabled forms. ActiveX controls are disabled for web forms, as evidenced by the informational label at the bottom of the design controls when the form compatability has been set to the web.

Now, I will admit that I know nothing about the HTML tags to play audio in a browser, but I have something else that might work. I had an InfoPath form that I needed to dynamically load an image into for a web-enabled form. Similar to the ActiveX issue, the Picture control was also disabled. What I did was put some managed code behind the form and execute the following when the form loaded.

public void FormEvents_Loading(object sender, LoadingEventArgs e)
{
    string imgPath = "http://yoursite/yourimage.jpeg";

    XPathNodeIterator xpni = MainDataSource.CreateNavigator().SelectSingleNode("/my:FormName/my:RichTextControlName", NamespaceManager).SelectChildren(XPathNodeType.All);
    xpni.Current.InnerXml = "<img xmlns=\"http://www.w3.org/1999/xhtml\" src=\"" + filePath + "\" width=\"200px\" height=\"55px\" />";    
}

I don't see why you couldn't take the same approach and load audio rather than an image.

Jason Z
+1  A: 

It looks like you can't embed <object> tags in a richtext field. I'm getting nothing when I do it. But thanks anyway Jason. Any other ideas?

Nathan DeWitt
A: 

Have you tried manually modifying the XSL in order to generate HTML which embedds your audio file?

I don't think there is a way to do this using the InfoPath Designer, but if it ends up in the XSL; it may just get passed through to the web enabled form.

bryansh