当前位置: 首页>>代码示例>>C#>>正文


C# MediaItem.GetResourceLocator方法代码示例

本文整理汇总了C#中MediaItem.GetResourceLocator方法的典型用法代码示例。如果您正苦于以下问题:C# MediaItem.GetResourceLocator方法的具体用法?C# MediaItem.GetResourceLocator怎么用?C# MediaItem.GetResourceLocator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MediaItem的用法示例。


在下文中一共展示了MediaItem.GetResourceLocator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Process

    public override bool Process(MediaItem mediaItem, out ContentDirectoryMessaging.MediaItemChangeType changeType)
    {
      changeType = ContentDirectoryMessaging.MediaItemChangeType.None;

      var rl = mediaItem.GetResourceLocator();
      using (var ra = rl.CreateAccessor())
      {
        var rad = ra as IResourceDeletor;
        if (rad == null)
          return false;

        // First try to delete the file from storage.
        if (rad.Delete())
        {
          changeType = ContentDirectoryMessaging.MediaItemChangeType.Deleted;

          // If the MediaItem was loaded from ML, remove it there as well.
          if (IsManagedByMediaLibrary(mediaItem))
          {
            IContentDirectory cd = ServiceRegistration.Get<IServerConnectionManager>().ContentDirectory;
            if (cd == null)
              return true;

            cd.DeleteMediaItemOrPath(rl.NativeSystemId, rl.NativeResourcePath, true);
            return true;
          }
        }
      }
      return false;
    }
开发者ID:chekiI,项目名称:MediaPortal-2,代码行数:30,代码来源:DeleteFromStorage.cs

示例2: GetPlayer

 public IPlayer GetPlayer(MediaItem mediaItem)
 {
   string mimeType;
   string title;
   if (!mediaItem.GetPlayData(out mimeType, out title))
     return null;
   IResourceLocator locator = mediaItem.GetResourceLocator();
   if (!ImagePlayer.CanPlay(locator, mimeType))
     return null;
   ImagePlayer player = new ImagePlayer();
   try
   {
     if (!player.NextItem(mediaItem, StartTime.AtOnce))
     {
       player.Dispose();
       return null;
     }
   }
   catch (Exception e)
   {
     ServiceRegistration.Get<ILogger>().Warn("ImagePlayerBuilder: Error playing media item '{0}'", e, locator);
     player.Dispose();
     return null;
   }
   return player;
 }
开发者ID:joconno4,项目名称:MediaPortal-2,代码行数:26,代码来源:ImagePlayerBuilder.cs

示例3: GetPlayer

        public IPlayer GetPlayer(MediaItem mediaItem)
        {
            string mimeType;
            string title;
            if (!mediaItem.GetPlayData(out mimeType, out title))
                return null;

            PlaylistItem item = mediaItem as PlaylistItem;
            if (item != null && item.InputStreamSite != null)
            {
                Dictionary<string, string> properties;
                if (item.InputStreamSite.GetStreamProperties(item.VideoInfo, out properties))
                {
                    // Replace raw url / token source by resolved stream url
                    var resourceAccessor = new RawUrlResourceAccessor(properties["inputstream.streamurl"]);
                    IList<MultipleMediaItemAspect> providerResourceAspects;
                    MediaItemAspect.TryGetAspects(item.Aspects, ProviderResourceAspect.Metadata, out providerResourceAspects);
                    MultipleMediaItemAspect providerResourceAspect = providerResourceAspects.First();
                    String raPath = resourceAccessor.CanonicalLocalResourcePath.Serialize();
                    providerResourceAspect.SetAttribute(ProviderResourceAspect.ATTR_RESOURCE_ACCESSOR_PATH, raPath);

                    IResourceLocator locator = mediaItem.GetResourceLocator();
                    InputStreamPlayer iplayer = (false) ?
                        new InputStreamDownloader(@"F:\Capture\Dump.mkv") : 
                        new InputStreamPlayer();
                    try
                    {
                        InitOnline(iplayer, properties);
                        iplayer.SetMediaItem(locator, title);

                        if (iplayer.DecryptError)
                            throw new Exception("Decrypting by InputStream failed.");

                        return iplayer;
                    }
                    catch (Exception ex)
                    {
                        ServiceRegistration.Get<ILogger>().Warn("Error playing media item '{0}': {1}", locator, ex.Message);
                        iplayer.Dispose();
                    }
                }
            }

            // Also try browser player as fallback if InputStream decoding failed
            if (mimeType == WebBrowserVideoPlayer.ONLINEVIDEOSBROWSER_MIMETYPE)
            {
                var player = new WebBrowserVideoPlayer();
                if (!player.Init(mediaItem))
                {
                    player.Dispose();
                    return null;
                }
                return player;
            }

            return null;
        }
开发者ID:offbyoneBB,项目名称:mp-onlinevideos2,代码行数:57,代码来源:OnlineVideoPlayerBuilder.cs

示例4: IsAvailable

 public override bool IsAvailable(MediaItem mediaItem)
 {
   try
   {
     var rl = mediaItem.GetResourceLocator();
     using (var ra = rl.CreateAccessor())
       return ra is IResourceDeletor;
   }
   catch (Exception)
   {
     return false;
   }
 }
开发者ID:chekiI,项目名称:MediaPortal-2,代码行数:13,代码来源:DeleteFromStorage.cs

示例5: Process

    public override bool Process(MediaItem mediaItem, out ContentDirectoryMessaging.MediaItemChangeType changeType)
    {
      changeType = ContentDirectoryMessaging.MediaItemChangeType.None;
      IContentDirectory cd = ServiceRegistration.Get<IServerConnectionManager>().ContentDirectory;
      if (cd == null)
        return false;

      var rl = mediaItem.GetResourceLocator();

      Guid parentDirectoryId;
      if (!MediaItemAspect.TryGetAttribute(mediaItem.Aspects, ProviderResourceAspect.ATTR_PARENT_DIRECTORY_ID, out parentDirectoryId))
        return false;

      MediaItemAspect.SetAttribute(mediaItem.Aspects, MediaAspect.ATTR_PLAYCOUNT, GetNewPlayCount());

      cd.AddOrUpdateMediaItem(parentDirectoryId, rl.NativeSystemId, rl.NativeResourcePath, mediaItem.Aspects.Values);

      changeType = ContentDirectoryMessaging.MediaItemChangeType.Updated;
      return true;
    }
开发者ID:chekiI,项目名称:MediaPortal-2,代码行数:20,代码来源:AbstractPlayCountAction.cs

示例6: GetPlayer

 public IPlayer GetPlayer(MediaItem mediaItem)
 {
   string mimeType;
   string title;
   if (!mediaItem.GetPlayData(out mimeType, out title))
     return null;
   if (mimeType != LiveTvMediaItem.MIME_TYPE_TV && mimeType != LiveTvMediaItem.MIME_TYPE_RADIO)
     return null;
   IResourceLocator locator = mediaItem.GetResourceLocator();
   BaseDXPlayer player = mimeType == LiveTvMediaItem.MIME_TYPE_TV ? (BaseDXPlayer) new LiveTvPlayer() : new LiveRadioPlayer(true);
   try
   {
     player.SetMediaItem(locator, title);
   }
   catch (Exception e)
   {
     ServiceRegistration.Get<ILogger>().Warn("SlimTvPlayerBuilder: Error playing media item '{0}'", e, locator);
     player.Dispose();
     return null;
   }
   return player;
 }
开发者ID:chekiI,项目名称:MediaPortal-2,代码行数:22,代码来源:SlimTvPlayerBuilder.cs

示例7: GetPlayer

 public IPlayer GetPlayer(MediaItem mediaItem)
 {
     string mimeType;
       string title;
       if (!mediaItem.GetPlayData(out mimeType, out title))
     return null;
       if (mimeType != "video/livetv")
     return null;
       IResourceLocator locator = mediaItem.GetResourceLocator();
       LiveTvPlayer player = new LiveTvPlayer();
       try
       {
     player.SetMediaItem(locator, title);
       }
       catch (Exception e)
       {
     ServiceRegistration.Get<ILogger>().Warn("LiveTvPlayer: Error playing media item '{0}'", e, locator);
     player.Dispose();
     return null;
       }
       return player;
 }
开发者ID:fokion,项目名称:MediaPortal-2,代码行数:22,代码来源:SlimTvPlayerBuilder.cs

示例8: GetPlayer

        public IPlayer GetPlayer(MediaItem mediaItem)
        {
            string mimeType;
              string title;
              if (!mediaItem.GetPlayData(out mimeType, out title))
            return null;

              // Our special player is only used for our mimetype
              if (mimeType != WebRadioPlayerHelper.WEBRADIO_MIMETYPE)
            return null;

              // Set back to valid audio mimetype
              mimeType = "audio/stream";

              IResourceLocator locator = mediaItem.GetResourceLocator();
              if (InputSourceFactory.CanPlay(locator, mimeType))
              {

               // Bass.BASS_PluginLoad(@"C:\Users\dierk_000\Downloads\basswm24\basswma.dll");

            BassPlayer player = new WebRadioBassPlayer(_pluginDirectory);

            // Config the BASSPlayer to play also .pls and .m3u
            Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_NET_PLAYLIST, 1);
            try
            {
              player.SetMediaItemLocator(locator, mimeType, title);
            }
            catch (Exception e)
            {
              ServiceRegistration.Get<ILogger>().Warn("WebRadioBassPlayer: Error playing media item '{0}'", e, locator);
              player.Dispose();
              return null;
            }
            return player;
              }
              return null;
        }
开发者ID:BigGranu,项目名称:Webradio_MP2,代码行数:38,代码来源:WebRadioPlayerBuilder.cs

示例9: GetPlayer

 public IPlayer GetPlayer(MediaItem mediaItem)
 {
   string mimeType;
   string title;
   if (!mediaItem.GetPlayData(out mimeType, out title))
     return null;
   IResourceLocator locator = mediaItem.GetResourceLocator();
   if (InputSourceFactory.CanPlay(locator, mimeType))
   {
     BassPlayer player = new BassPlayer();
     try
     {
       player.SetMediaItemLocator(locator, mimeType, title);
     }
     catch (Exception e)
     {
       ServiceRegistration.Get<ILogger>().Warn("BassPlayerPlugin: Error playing media item '{0}'", e, locator);
       player.Dispose();
       return null;
     }
     return player;
   }
   return null;
 }
开发者ID:davinx,项目名称:MediaPortal-2,代码行数:24,代码来源:BassPlayerPlugin.cs

示例10: GetPlayer

 public IPlayer GetPlayer(MediaItem mediaItem)
 {
   string mimeType;
   string title;
   if (!mediaItem.GetPlayData(out mimeType, out title))
     return null;
   IResourceLocator locator = mediaItem.GetResourceLocator();
   if (mimeType == "video/bluray")
   {
     BluRayPlayer player = new BluRayPlayer();
     try
     {
       player.SetMediaItem(locator, title);
     }
     catch (Exception)
     {
       LogError("Error playing media item '{0}'", locator);
       player.Dispose();
       return null;
     }
     return player;
   }
   return null;
 }
开发者ID:davinx,项目名称:MediaPortal-2,代码行数:24,代码来源:BluRayPlayerBuilder.cs

示例11: NextItem

 public bool NextItem(MediaItem mediaItem, StartTime startTime)
 {
   string mimeType;
   string title;
   if (!mediaItem.GetPlayData(out mimeType, out title) || mimeType != LiveTvMediaItem.MIME_TYPE_TV)
   {
     ServiceRegistration.Get<ILogger>().Debug("SlimTvHandler: Cannot reuse current player for new mimetype {0}", mimeType);
     return false;
   }
   Stop();
   // Set new resource locator for existing player, this avoids interim close of player slot
   IResourceLocator resourceLocator = mediaItem.GetResourceLocator();
   ServiceRegistration.Get<ILogger>().Debug("SlimTvHandler: Changing file/stream for player to {0}", resourceLocator.NativeResourcePath);
   SetMediaItem(resourceLocator, mimeType);
   return true;
 }
开发者ID:davinx,项目名称:MediaPortal-2,代码行数:16,代码来源:LiveTvPlayer.cs

示例12: HandleUnableToPlay

 /// <summary>
 /// This method handles two cases:
 /// <list type="bullet">
 /// <item>No player available to play the resource</item>
 /// <item>The resouce to play is broken</item>
 /// </list>
 /// </summary>
 /// <param name="item"></param>
 /// <param name="exceptions"></param>
 protected void HandleUnableToPlay(MediaItem item, ICollection<Exception> exceptions)
 {
   INotificationService notificationService = ServiceRegistration.Get<INotificationService>();
   // Start a heuristics to find a proper error message for the user
   IResourceLocator locator = item.GetResourceLocator();
   if (locator == null)
   {
     ServiceRegistration.Get<ILogger>().Warn("PlayerSlotController: Could not play media item '{0}', resource locator could not be built", item);
     return;
   }
   if (exceptions.Count != 0) // This is the indicator that at least one player builder tried to open the resource but threw an exception
   {
     // 1) Check if resource is present
     IResourceAccessor ra = null;
     try
     {
       bool exists;
       try
       {
         ra = locator.CreateAccessor();
         IFileSystemResourceAccessor fsra = ra as IFileSystemResourceAccessor;
         exists = fsra != null && fsra.Exists;
       }
       catch (Exception)
       {
         exists = false;
       }
       notificationService.EnqueueNotification(
           NotificationType.UserInteractionRequired, RES_ERROR_PLAYING_MEDIA_ITEM_TITLE, exists ?
               LocalizationHelper.Translate(RES_UNABLE_TO_PLAY_MEDIA_ITEM_TEXT, ra.ResourceName) :
               LocalizationHelper.Translate(RES_RESOURCE_NOT_FOUND_TEXT, locator.NativeResourcePath.FileName), true);
     }
     finally
     {
       if (ra != null)
         ra.Dispose();
     }
   }
   else
   {
     using (IResourceAccessor ra = locator.CreateAccessor())
       notificationService.EnqueueNotification(NotificationType.UserInteractionRequired, RES_NO_PLAYER_AVAILABLE_NOTIFICATION_TITLE,
           LocalizationHelper.Translate(RES_NO_PLAYER_AVAILABLE_NOTIFICATION_TEXT, ra.ResourceName), true);
   }
 }
开发者ID:chekiI,项目名称:MediaPortal-2,代码行数:54,代码来源:PlayerSlotController.cs

示例13: NextItem

 public bool NextItem(MediaItem mediaItem, StartTime startTime)
 {
     string mimeType;
       string title;
       if (!mediaItem.GetPlayData(out mimeType, out title))
     return false;
       if (mimeType != "video/livetv")
     return false;
       IResourceLocator locator = mediaItem.GetResourceLocator();
       if (locator == null)
     return false;
       Shutdown();
       SetMediaItem(locator, title);
       return true;
 }
开发者ID:npcomplete111,项目名称:MediaPortal-2,代码行数:15,代码来源:LiveTvPlayer.cs

示例14: NextItem

 public bool NextItem(MediaItem mediaItem, StartTime startTime)
 {
   string mimeType;
   string title;
   if (!mediaItem.GetPlayData(out mimeType, out title))
     return false;
   IResourceLocator locator = mediaItem.GetResourceLocator();
   if (locator == null)
     return false;
   if (!CanPlay(locator, mimeType))
     return false;
   RightAngledRotation rotation = RightAngledRotation.Zero;
   bool flipX = false;
   bool flipY = false;
   MediaItemAspect imageAspect = mediaItem[ImageAspect.ASPECT_ID];
   if (imageAspect != null)
   {
     int orientationInfo = (int) imageAspect[ImageAspect.ATTR_ORIENTATION];
     ImageRotation imageRotation;
     ImageAspect.OrientationToRotation(orientationInfo, out imageRotation);
     rotation = PlayerRotationTranslator.TranslateToRightAngledRotation(imageRotation);
     ImageAspect.OrientationToFlip(orientationInfo, out flipX, out flipY);
   }
   SetMediaItemData(locator, title, rotation, flipX, flipY);
   return true;
 }
开发者ID:BigGranu,项目名称:MediaPortal-2,代码行数:26,代码来源:ImagePlayer.cs

示例15: Init

        public bool Init(MediaItem mediaItem)
        {
            // Prepare process information
            Prepare(mediaItem);

            IResourceAccessor ra = null;
            try
            {
                ra = mediaItem.GetResourceLocator().CreateAccessor();
                RawUrlResourceAccessor rua = ra as RawUrlResourceAccessor;
                if (rua != null)
                {
                    _fileOrUrl = rua.URL;
                }
                else
                {
                    RawTokenResourceAccessor rra = ra as RawTokenResourceAccessor;
                    if (rra == null)
                        return false;
                    _fileOrUrl = rra.Token;
                }
                Play();
                return true;
            }
            catch (Exception)
            {
                // Log
            }
            finally
            {
                if (ra != null)
                    ra.Dispose();
            }
            return false;
        }
开发者ID:offbyoneBB,项目名称:mp-onlinevideos2,代码行数:35,代码来源:WebBrowserVideoPlayer.cs


注:本文中的MediaItem.GetResourceLocator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。