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


C# MediaItem.GetPlayData方法代码示例

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


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

示例1: 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

示例2: 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

示例3: GetPlayer

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

      if (mimeType == UPnPRendererImagePlayer.MIMETYPE)
      {
        UPnPRendererImagePlayer imagePlayer = new UPnPRendererImagePlayer();
        imagePlayer.NextItem(mediaItem, StartTime.AtOnce);
        return imagePlayer;
      }
      return null;
    }
开发者ID:aspik,项目名称:MediaPortal-2,代码行数:15,代码来源:PlayerBuilder.cs

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: GetPlayer

 public IPlayer GetPlayer(MediaItem mediaItem)
 {
   string mimeType;
   string title;
   if (!mediaItem.GetPlayData(out mimeType, out title))
     return null;
   IResourceLocator locator = mediaItem.GetResourceLocator();
   Type playerType = PlayerRegistration.GetPlayerTypeForMediaItem(locator, mimeType);
   if (playerType == null)
     return null;
   IInitializablePlayer player = (IInitializablePlayer) Activator.CreateInstance(playerType);
   try
   {
     player.SetMediaItem(locator, title);
   }
   catch (Exception e)
   { // The file might be broken, so the player wasn't able to play it
     ServiceRegistration.Get<ILogger>().Warn("{0}: Unable to play '{1}'", e, playerType, locator);
     IDisposable disposablePlayer = player as IDisposable;
     if (disposablePlayer != null)
       disposablePlayer.Dispose();
     throw;
   }
   return (IPlayer) player;
 }
开发者ID:joconno4,项目名称:MediaPortal-2,代码行数:25,代码来源:VideoPlayerBuilder.cs

示例12: 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;
   IInputSource inputSource = _inputSourceFactory.CreateInputSource(locator, mimeType);
   if (inputSource == null)
     return false;
   lock (_syncObj)
     _externalState = PlayerState.Active;
   _controller.MoveToNextItem_Async(inputSource, startTime);
   _mediaItemTitle = title; // This is a bit too early because we're not switching to the next item at once, but doesn't matter
   return true;
 }
开发者ID:jgauffin,项目名称:MediaPortal-2,代码行数:18,代码来源:BassPlayer.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


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