UPnP / DLNA Media Server for MediaPortal 2 (1 Viewer)

morpheus_xx

Retired Team Member
  • Team MediaPortal
  • March 24, 2007
    12,073
    7,459
    Home Country
    Germany Germany

    FreakyJ

    Retired Team Member
  • Premium Supporter
  • July 25, 2010
    4,024
    1,420
    Home Country
    Germany Germany
    @morpheus_xx
    Sorry to bother you:
    I read this:
    /// <summary>
    /// Returns a resource locator instance for this item.
    /// </summary>
    /// <returns>Resource locator instance or <c>null</c>, if this item doesn't contain a <see cref="ProviderResourceAspect"/>.</returns>
    public IResourceLocator GetResourceLocator()

    And this code:
    var mediaIteamLocator = item.GetResourceLocator();
    returns 'null'

    What are the reasons that the ProviderResourceAspect is unavailable?
    If I take a look into the DB I have 77 entries for in the MediaItem Aspect and 77 entries in Resourceprovidersource table.
    But I get for every MediaItem 'null' while trying the Resourcelocator...

    Part of the whole function:
    Code:
    public static MetadataContainer ParseMediaItem(MediaItem item)
        {
          MetadataContainer info = new MetadataContainer();
          var mediaIteamLocator = item.GetResourceLocator();
          try
          {
            var mediaItemPath = mediaIteamLocator.NativeResourcePath;
            var mediaItemDirectoryPath = ResourcePathHelper.Combine(mediaItemPath, "../");
            using (var mediaItemAccessor = new ResourceLocator(mediaIteamLocator.NativeSystemId, mediaItemDirectoryPath).CreateAccessor())
            {
              //IResourceAccessor mediaItemAccessor = item.GetResourceLocator().CreateAccessor();
              if (mediaItemAccessor is IFileSystemResourceAccessor)
              {
                using (var fsra = (IFileSystemResourceAccessor)mediaItemAccessor.Clone())
                {
                  if (!fsra.IsFile)
                    return null;
                  using (var lfsra = StreamedResourceToLocalFsAccessBridge.GetLocalFsResourceAccessor(fsra))
                  {
                    info.Metadata.Source = lfsra.LocalFileSystemPath;
                  }
                }
                info.Metadata.Size = new FileInfo(info.Metadata.Source).Length;
              }
              else if (mediaItemAccessor is INetworkResourceAccessor)
              {
                using (var nra = (INetworkResourceAccessor)mediaItemAccessor.Clone())
                {
                  info.Metadata.Source = nra.URL;
                }
                info.Metadata.Size = 0;
              }
            }
          }
          catch (Exception ex)
          {
    //#if DEBUG
            var name = item.Aspects[MediaAspect.ASPECT_ID].GetAttributeValue(MediaAspect.ATTR_TITLE);
            Logger.Warn("DlnaMediaServer: Error while accessing Mediaitem '{0}' in ParseMediaItem()", ex, name);
    //#endif
            info.Metadata.Size = 0;
          }

    Log:
    [2015-09-10 09:52:15,509] [31125 ] [39 ] [WARN ] - DlnaMediaServer: Error while accessing Mediaitem 'Covert Affairs S04E13 - No. 13 Baby' in ParseMediaItem()
    System.NullReferenceException: Object reference not set to an instance of an object.
    at MediaPortal.Extensions.MediaServer.MetadataExtractors.DlnaVideoMetadataExtractor.ParseMediaItem(MediaItem item) in m:\Programmieren\C#\MediaPortal 2\MediaPortal\Incubator\MediaServer\MetadataExtractors\DlnaVideoMetadataExtractor.cs:line 235

    Edit:
    The exception is caused because 'mediaIteamLocator ' is null
     

    morpheus_xx

    Retired Team Member
  • Team MediaPortal
  • March 24, 2007
    12,073
    7,459
    Home Country
    Germany Germany
    How did you load the MediaItems? Usually you need to pass the AspectIds you want to include, did you miss the ProviderResourceAspect?
     

    henso

    Development Group
  • Team MediaPortal
  • February 16, 2012
    2,341
    832
    Home Country
    Denmark Denmark
    GUI strings? Which GUI strings? The Media Server doesn't even have a gui :)
    I just get a lot of exceptions in a function called TryToTranslate or something similar. So I assumed I was missing some translations. I think it was for the FriendlyName, Manufacturer etc. for the UPnP device.
     

    FreakyJ

    Retired Team Member
  • Premium Supporter
  • July 25, 2010
    4,024
    1,420
    Home Country
    Germany Germany
    How did you load the MediaItems? Usually you need to pass the AspectIds you want to include, did you miss the ProviderResourceAspect?
    First of all thank you for your answer! I don't know what we would do without you :)
    I've added this to the search query:
    Code:
          necessaryMIATypes.Add(ProviderResourceAspect.ASPECT_ID);

    ISet<Guid> necessaryMIATypes = new HashSet<Guid>();
    necessaryMIATypes.Add(MediaAspect.ASPECT_ID);
    necessaryMIATypes.Add(ProviderResourceAspect.ASPECT_ID);
    IFilter searchFilter = SearchParser.Convert(exp, necessaryMIATypes);
    MediaItemQuery searchQuery = new MediaItemQuery(necessaryMIATypes, null, searchFilter);

    [...]

    IList<MediaItem> items = ServiceRegistration.Get<IMediaLibrary>().Search(searchQuery, true);

    var msgBuilder = new GenericDidlMessageBuilder();
    var o = deviceClient.RootContainer.FindObject(containerId);
    if (o == null)
    {
    // We failed to find the container requested
    // throw error!
    throw new ArgumentException("ObjectID not found");
    }
    IEnumerable<IDirectoryObject> objects = items.Select(item => MediaLibraryHelper.InstansiateMediaLibraryObject(item, MediaLibraryHelper.GetBaseKey(containerId), (BasicContainer)o));
    msgBuilder.BuildAll(filter, objects);

    on GitHub:
    https://github.com/MediaPortal/Medi...erver/UPnPContentDirectoryServiceImpl.cs#L473

    Now it looks like it is working (y)

    Edit:
    Commit: https://github.com/MediaPortal/MediaPortal-2/commit/cf8498caf10ba9e5620f02da8c72efdd3b3c0f21
     

    FreakyJ

    Retired Team Member
  • Premium Supporter
  • July 25, 2010
    4,024
    1,420
    Home Country
    Germany Germany

    Attachments

    • MediaServer.rar
      40.9 MB

    FreakyJ

    Retired Team Member
  • Premium Supporter
  • July 25, 2010
    4,024
    1,420
    Home Country
    Germany Germany
    I just get a lot of exceptions in a function called TryToTranslate or something similar. So I assumed I was missing some translations. I think it was for the FriendlyName, Manufacturer etc. for the UPnP device.
    I can't confirm that. Do you have a stack trace?
     

    Users who are viewing this thread

    Top Bottom