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

Video Player

10 posts, 0 answered
  1. Gökhan Yalçın
    Gökhan Yalçın avatar
    21 posts
    Registered:
    26 Nov 2009
    30 Dec 2009
    Link to this post
    Hi everyone ,
     
    I am using JW Player instead of default video player in sitefinity .  I upload a flv file toa  video library and when i want to play this video in JW player,  it does not play  because the url generated by sitefinity has ashx extension . What can i do about it ?

    Thanks .
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    03 Jan 2010
    Link to this post
    Hello Gökhan Yalçın,

    In this case you can use the default file extension. Please take a look at

    How to filter the default ContentHttpHandler by extension
    How to use the real extensions for the items in the Images and Documents module

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Gökhan Yalçın
    Gökhan Yalçın avatar
    21 posts
    Registered:
    26 Nov 2009
    06 Jan 2010
    Link to this post
    Hello Ivan ,

    Thanks it works . However, i have another question . When i upload a video with wmv extension , sitefinity creates a
    thumbnail image for the video but when upload a  video with flv extension it doesn't . What should i do ?

    Thanks
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    07 Jan 2010
    Link to this post
    Hi Gökhan Yalçın,

    It could be done but it is not easy. We use InteropDexterLib to generate the thumb image during upload. To get thimb image for other mime types that "video" you have to create a custom class that inherits from LibrararyManager. Then create a custom class that will be used to upload your item.


    public IContent UploadFile(byte[] buffer, string fileName, string fileExtension, string mimeType, long streamLength, ILibrary library, bool overwrite)
           {
              
                if (currentItem.MimeType.StartsWith("application/octet-stream", true, CultureInfo.InvariantCulture) &&
                   (selectedLibrary.TypeName == LibraryInfo.Library_Video_Name || selectedLibrary.TypeName == LibraryInfo.Library_Custom_Name))
               {
                   bool fullTrust = SecurityManager.IsGranted(new AspNetHostingPermission(PermissionState.Unrestricted));
     
                   if (fullTrust)
                   {
                       string baseDir = System.AppDomain.CurrentDomain.BaseDirectory + "App_Data\\Temp\\";
                       string currentItemId = currentItem.ID.ToString().Replace("-", string.Empty);
                       /// create the video and jpg
                       string videoFile = baseDir + currentItemId + ".flv";
                       string imageFile = baseDir + currentItemId + ".jpg";
     
                       try
                       {
                           /// try uploading thumbnail for video using Dexter Lib
                           if (!Directory.Exists(baseDir))
                               Directory.CreateDirectory(baseDir);
     
                           using (FileStream videoWriterStream = new FileStream(videoFile, FileMode.OpenOrCreate, FileAccess.Write))
                           {
                               BinaryWriter writer = new BinaryWriter(videoWriterStream);
     
                               writer.Write(buffer);
                               writer.Close();
     // only in FULL TRUST WITH REFLECTION PERMISSIONS
                               Type type = Type.GetType("DexterLib.MediaDetClass, Interop.DexterLib");
                               object instance = Activator.CreateInstance(type);
     
                               PropertyInfo fileNameInfo = type.GetProperty("Filename");
                               fileNameInfo.SetValue(instance, videoFile, null);
     
                               PropertyInfo currentStreamInfo = type.GetProperty("CurrentStream");
                               currentStreamInfo.SetValue(instance, 0, null);
     
                               MethodInfo writeBitmapBitsInfo = type.GetMethod("WriteBitmapBits");
                               object[] parameters = new object[] {0, 640, 480, imageFile};
                               writeBitmapBitsInfo.Invoke(instance, parameters);
     
                               videoWriterStream.Close();
                           }
     
                           using (FileStream imageStream = new FileStream(imageFile, FileMode.Open, FileAccess.Read))
                           {
                               BinaryReader reader = new BinaryReader(imageStream);
                               byte[] thumbData = new byte[imageStream.Length];
     
                               reader.Read(thumbData, 0, thumbData.Length);
                               reader.Close();
                               currentItem = SaveThumbnail(mimeType, currentItem, thumbData);
     
                               imageStream.Close();
                           }
                       }
                       catch (Exception ex)
                       {
                          
                       }
                       finally
                       {
                           // clean up.
                           if (File.Exists(videoFile))
                               File.Delete(videoFile);
                           if (File.Exists(imageFile))
                               File.Delete(imageFile);
                       }
                   }
               }
               if (currentItem != null && this.items != null)
                   this.items.Add(currentItem);
     
               return currentItem;
           }


    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. Gökhan Yalçın
    Gökhan Yalçın avatar
    21 posts
    Registered:
    26 Nov 2009
    03 Feb 2010
    Link to this post
    Hi Ivan,

    We have written a custom class that inherits from LibraryManager. How do we make sure that the upload process actually goes through this class? Is that configurable through a configuration file, such as web.config or controlsconfig.xml? Can you please get into more detail?

    Thanks, 
    Gökhan Yalçın
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    03 Feb 2010
    Link to this post
    Hello Gökhan Yalçın,

    1. You can create a custom module where you will use your custom manager.
    2. You can create a custom upload form where you get the files and call CustmLibraryManager.YourUploadMethod. Generally this will require to replace the default LibraryItemUpload view with your custom one. You can gather more information at Replacing a child view with another one .

    All the best,
    Ivan Dimitrov
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  7. Gökhan Yalçın
    Gökhan Yalçın avatar
    21 posts
    Registered:
    26 Nov 2009
    05 Feb 2010
    Link to this post
    Hi Ivan,

    Per your advise in "Replacing a child view with another one" we tried the following solution. We tried replacing LibraryItemUpload`1 with CustomUpload, where the latter subclasses from the former. We tried altering the configuration, "ControlsConfig.xml" as follows: 

    <viewSettings hostType="Telerik.Libraries.WebControls.Admin.LibraryItemsView, Telerik.Libraries">
      <views>
        <remove name="LibraryItemUpload`1"></remove>
        <add name="LibraryItemUpload`1" viewType="CustomUpload, App_Code"></add>
      </views>
    </viewSettings>

    However, that yielded the following exception, when we tried loading the admin panel. 

    [ArgumentException: Could not find a type for a name.  The type name was 'CustomUpload, App_Code'.]
       Telerik.Utilities.TypeResolutionService.GetType(String name, Boolean throwOnError, Boolean ignoreCase) +1220
       Telerik.Utilities.TypeResolutionService.GetType(String name, Boolean throwOnError) +44
       Telerik.Utilities.TypeResolutionService.GetType(String name) +38
       Telerik.Utilities.TypeResolutionService.ResolveType(String name) +39
       Telerik.Utilities.StringTypeConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value) +106
       System.ComponentModel.TypeConverter.ConvertFromString(String text) +12
       Telerik.Sitefinity.Configuration.XmlConfigProvider.LoadAttributes(ConfigElement element, XmlReader reader) +672
       Telerik.Sitefinity.Configuration.XmlConfigProvider.LoadElement(ConfigElement element, XmlReader reader, Stack`1 stack) +584
       Telerik.Sitefinity.Configuration.XmlConfigProvider.LoadElement(ConfigElement element, XmlReader reader, Stack`1 stack) +826
    
    
    What would you recommend?
    
    
    Thanks, 
    
    
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    05 Feb 2010
    Link to this post
    Hi Gökhan Yalçın,

    The error is thrown because the following class CustomUpload cannot be found under App_Code. Make sure that you have not missed any namespace and the class is located under App_Code folder

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Telerik.Libraries.WebControls.Admin;
     
    /// <summary>
    /// Summary description for CustomUpload
    /// </summary>
    public class CustomUpload : LibraryItemUpload<LibraryItemsView>
    {
        public CustomUpload()
        {
            //
            // TODO: Add constructor logic here
            //
        }
    }


    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  9. Gökhan Yalçın
    Gökhan Yalçın avatar
    21 posts
    Registered:
    26 Nov 2009
    05 Feb 2010
    Link to this post
    Hi Ivan,

    That works, thanks!

    So, how do I then interfere with the uploading mechanism. I know that LibraryItemUpload uses LibraryManager to upload the documents. So, in my CustomUpload class, I should be calling my CustomLibraryManager right? Where is the appropriate place to do so? Is it ok if I just return CustomLibraryManager  in the LibManager getter? For exmple please see the code below: 

    public class CustomUpload : LibraryItemUpload<LibraryItemsView>
    {
     
        private CustomLibraryManager myLibManager;
     
        public CustomUpload()
        {
            //
            // TODO: Add constructor logic here
            //
        }
     
        public LibraryManager LibManager
        {
            get
            {
                if (myLibManager == null)
                {
                    myLibManager = new CustomLibraryManager();
                }
                return myLibManager;
            }
        }
    }


    For some reason the getter never gets invoked. What is the reason for this? Is there a better way of getting our CustomLibraryManager getting used?

    Thanks, 
  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    05 Feb 2010
    Link to this post
    Hello Gökhan Yalçın,

    Override InitializeControls of your custom upload class. Subscribe for the click event of the control you use to trigger the upload. Then call the upload method of your custom manager.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
Register for webinar
10 posts, 0 answered