+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Add SWF o0r Flash video in the pages.

Add SWF o0r Flash video in the pages.

23 posts, 0 answered
  1. Reinier
    Reinier  avatar
    2 posts
    Registered:
    11 Dec 2008
    15 Dec 2008
    Link to this post
    HI Im new to SiteFinity. I need to add 1 or more flash video in the page. where I can also change it depending on the needs. More or else adding the video toa custom module.

    Thanks for help.
  2. Parvan
    Parvan avatar
    151 posts
    Registered:
    24 Sep 2012
    15 Dec 2008
    Link to this post
    Hello Reinier ,

    For adding flash swf files, you can use Generic Content - portions of html that can later be added to the pages.
    Generic Content items use WYSIWYG editor for adding *swf files, as well video, music.
    The editor has button Flash Manager, which allows you to upload swf files and embed some among them.

    Generic content can be created and added on two places in Sitefinity administration:
    1. When editing a page you drag&drop Generic Content control from the Add Controls panel.
    2. In Modules->Generic_Content you can also create content items(so called shared items)

    I hope that this information will help you.

    Greetings,

    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Reinier
    Reinier  avatar
    2 posts
    Registered:
    11 Dec 2008
    15 Dec 2008
    Link to this post
    ok i got it. but here's the scenario. using sitefinity i need to create a program about fashion which has news events. the user can add the flash or images file to the news event page. thanks. which is also dynamically adding or deleting the files.
  4. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    16 Dec 2008
    Link to this post
    Hello Reinier ,

    You can use the User Controls approach. You need to create a user control, which accepts a URL of a flash animation. For more information about the user controls, please check these videos:
    • http://www.sitefinity.com/Videos/Controls/
    • http://www.sitefinity.com/Videos/Adding_Simple_Functionality_With_User_Controls/
    As for the files, you may take a look at the Administration->Files section.

    Greetings,
    Georgi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  5. mimholt
    mimholt avatar
    11 posts
    Registered:
    01 Mar 2007
    20 Dec 2008
    Link to this post
    I found the flash implementation of the Generic content control more than a bit limiting.  But the user control approach works well.  Here's the code for a fairly generic flash user control using SWFObject.  You do have to embed a link to the SWFObject.js in the master page, but after that, this works well.  It could be better - I could add the SWFObject.js link as a script block and I could decorate the properties for nicer editors, but it's ok.  Here' it is:

    Flashbox.ascx:

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="FlashBox.ascx.cs" Inherits="UserControls_FlashBox" %>

    <asp:Literal ID="litFlashOutput" runat="server"></asp:Literal>



    CODE BEHIND:

    protected void Page_Load(object sender, EventArgs e)

    {

    string s;

    s = Request["cmspagemode"];

    if ((string.IsNullOrEmpty(s) == true) || (s != "edit"))

    {

    if (!Page.IsPostBack)

    {

    string key = "FlashScriptBlock";

    string script = "<script type=\"text/javascript\">var param = {0} base: {1} {2}; swfobject.embedSWF(\"{3}\", \"{4}\", \"{5}\", \"{6}\", \"9.0.0\", \"{7}\", null, param );</script>";

    string tag = "<div id=\"{0}\"></div>";

    string dir = "\"" + BaseDir + "\"";

    object[] vars = new object[] { "{", dir, "}", FlashFile, DivName, Width, Height, ExpressInstallLocation };

    script = string.Format(script, vars);

    if (this.GenerateDiv == true)

    this.litFlashOutput.Text = string.Format(tag, DivName);

    else

    this.litFlashOutput.Text = string.Empty;

    Page.RegisterStartupScript(key, script);

    }

    }

    else

    {

    string tempTag = "<div>{0}</div>";

    tempTag = string.Format(tempTag, "Please click on Preview or Publish to see your flash content");

    this.litFlashOutput.Text = tempTag;

    }

    }

    [Browsable(true)]
    public string ExpressInstallLocation { get; set; }

    [Browsable(true)]
    public bool GenerateDiv { get; set; }

    [Browsable(true)]
    public string DivName { get; set; }

    [Browsable(true)]
    public string FlashFile { get; set; }

    [Browsable(true)]
    public string BaseDir { get; set; }

    [Browsable(true)]
    public int Width { get; set; }

    [Browsable(true)]
    public int Height { get; set; }

     
  6. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    22 Dec 2008
    Link to this post
    Hello,

    I am glad that you have it working as you wish. Thank you for sharing the solution with us!

    Greetings,
    Georgi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  7. michael
    michael avatar
    15 posts
    Registered:
    22 Jan 2009
    28 Jan 2009
    Link to this post
    mimholt, I had to edit your code a little to get it to work, specifically the publics at the end of your class:

    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.ComponentModel;

    public partial class UserControls_FlashBox : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            string s;

            s = Request["cmspagemode"];

            if ((string.IsNullOrEmpty(s) == true) || (s != "edit"))
            {

                if (!Page.IsPostBack)
                {

                    string key = "FlashScriptBlock";

                    string script = "<script type=\"text/javascript\">var param = {0} base: {1} {2}; swfobject.embedSWF(\"{3}\", \"{4}\", \"{5}\", \"{6}\", \"9.0.0\", \"{7}\", null, param );</script>";

                    string tag = "<div id=\"{0}\"></div>";

                    string dir = "\"" + BaseDir + "\"";

                    object[] vars = new object[] { "{", dir, "}", FlashFile, DivName, Width, Height, ExpressInstallLocation };

                    script = string.Format(script, vars);

                    if (this.GenerateDiv == true)

                        this.litFlashOutput.Text = string.Format(tag, DivName);

                    else

                        this.litFlashOutput.Text = string.Empty;

                    Page.RegisterStartupScript(key, script);

                }

            }

            else
            {

                string tempTag = "<div>{0}</div>";

                tempTag = string.Format(tempTag, "Please click on Preview or Publish to see your flash content");

                this.litFlashOutput.Text = tempTag;

            }

        }

        private string _ExpressInstallLocation;
        private bool _GenerateDiv;
        private string _DivName;
        private string _FlashFile;
        private string _BaseDir;
        private int _Width;
        private int _Height;

        [Browsable(true)]
        public string ExpressInstallLocation {
            get { return _ExpressInstallLocation; }
            set { _ExpressInstallLocation = value; }
        }

        [Browsable(true)]
        public bool GenerateDiv    {
            get { return _GenerateDiv; }
            set { _GenerateDiv = value; }
        }

        [Browsable(true)]
        public string DivName    {
            get { return _DivName; }
            set { _DivName = value; }
        }

        [Browsable(true)]
        public string FlashFile    {
            get { return _FlashFile; }
            set { _FlashFile = value; }
        }

        [Browsable(true)]
        public string BaseDir    {
            get { return _BaseDir; }
            set { _BaseDir = value; }
        }

        [Browsable(true)]
        public int Width    {
            get { return _Width; }
            set { _Width = value; }
        }

        [Browsable(true)]
        public int Height    {
            get { return _Height; }
            set { _Height = value; }
        }
    }

  8. Justin Beitlich
    Justin Beitlich avatar
    3 posts
    Registered:
    11 Mar 2009
    21 Aug 2009
    Link to this post
    I've tried to upload a flash file to the generic content editor but the upload icon is inactive.  How can I get around this?
  9. Parvan
    Parvan avatar
    151 posts
    Registered:
    24 Sep 2012
    23 Aug 2009
    Link to this post
    Hello michael,

    I attached a version that has some enhancements - default values for attributes.
    Before Width ,Height , DivName were not set by default. Now I assigned them default values.
    I put the swfobject.js I used(version 2.1).
    You can set the FlashFile attribute as absolute url to swf file on your site( for example
    http://server.com/example.swf).

    I hope this information will help you.


    Regards,
    Parvan
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  10. Thomas Sworen
    Thomas Sworen avatar
    3 posts
    Registered:
    30 Oct 2008
    22 Jun 2010
    Link to this post
    I am not sure where to put the reference for the java script.
  11. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    22 Jun 2010
    Link to this post
    Hello Thomas Sworen,

    The script should be registered in the head tag of the master page - you can use <script> tags to to this

    <script type="text/javascript" src="swfobject.js"></script>


     or do it programmatically inside the user control

    HtmlGenericControl control = new ......;
    control.TagName = "script";
    control.Attributes.Add("src", url);
    control.Attributes.Add("type", "text/javascript");
     
    this.Page.Header.Controls.Add(control);

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  12. Thomas Sworen
    Thomas Sworen avatar
    3 posts
    Registered:
    30 Oct 2008
    23 Jun 2010
    Link to this post
    Thank you for the help it has resolved the error that I was receiving. When I view the page though it doesn't play the swf file.

    I have copied the code to the user control as posted and put the java link in the master page.
    When I drag the user control to the page I set the path for the swf file but still doesn't display.

    Is there something I am missing?

    Thanks!
  13. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    05 Jul 2010
    Link to this post
    Hello Thomas Sworen,

    I verified the code supplied by Parvan. It is working fine. The video plays without problems. Please check whether there are any js thrown and the flash object is loaded into the HTML. 

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  14. Ahmed Salman
    Ahmed Salman avatar
    31 posts
    Registered:
    13 Apr 2010
    08 Jul 2010
    Link to this post

    Dear sir,

        it is not working with me.i download the control and i use it but it is not working.


    i add the code to my MasterPage:

    <script type="text/javascript" src="swfobject.js"></script>

    but wher the swfobject.js  should be ? in which folder?


    becuase i have java error   "swfobject" undifine ?
  15. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    08 Jul 2010
    Link to this post
    Hello Ahmed Salman,

    The error you are getting meant that js library swfobject has not been added on your page. You can use FireBug to see that. Your src path is not correct. You could also use the server control JsFileLink instead of adding <script> tag reference in the head.

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  16. Ahmed Salman
    Ahmed Salman avatar
    31 posts
    Registered:
    13 Apr 2010
    08 Jul 2010
    Link to this post
    how i can add the file to "js library " ???
  17. Kristian
    Kristian avatar
    214 posts
    Registered:
    03 Jun 2010
    23 Jul 2010
    Link to this post
    <script type="text/javascript" src="../UserControls/Flash/swfobject.js"></script>

    Was the path i needed to use after I uploaded the user control into the Group flash.
  18. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    25 Jul 2010
    Link to this post
    Hi Kristian,

    Use JsFileLink which is a server control. Check the Chrome console for any js errors.

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  19. Kristian
    Kristian avatar
    214 posts
    Registered:
    03 Jun 2010
    29 Jul 2010
    Link to this post
    Cool I got it working.

    One question
    I noticed that the Flashbox control you have provided allows you to select from Video Libraries. I added the extensions for flash in my video library and uploaded my flash movie there. When doing it this way the movie does not play, I can only get the movie to play if I specify the movie directory directly. I'd like to have this functionality of using the video library so only users with permissions can view them and NOT be able to just type the movie url in the browser e.g. http://www.mydomain.com/movie.swf. Am I missing a step?
  20. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    30 Jul 2010
    Link to this post
    Hello Kristian,

    Thank you for getting back to us.

    In order to use swf files from the images and documents module you would have to enable Libraries to use the real extensions of files. This is explained in this KB article: How to use the real extensions for the items in the Images and Documents module. When you are done with the steps from the article you should also map the swf extension:
    <extensionMapping defaultExtension=".sflb.ashx">
        <add key=".jpg"/>
        <add key=".pdf"/>
        <add key=".csv"/>
        <add key=".xls"/>
        <add key=".swf"/>
    </extensionMapping>


    Regards,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  21. Kristian
    Kristian avatar
    214 posts
    Registered:
    03 Jun 2010
    30 Jul 2010
    Link to this post
    Im running my site in classic pipeline, is there a dll/exe available to add to the handler mappings?
  22. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    30 Jul 2010
    Link to this post
    Hi Kristian,

    This is also available in classic pipeline mode. You have to configure system.web/httpModules

    Kind regards,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  23. Kristian
    Kristian avatar
    214 posts
    Registered:
    03 Jun 2010
    30 Jul 2010
    Link to this post
    Thanks I got it
Register for webinar
23 posts, 0 answered