コード例 #1
0
        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(_pluginDirectory);
                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);
        }
コード例 #2
0
ファイル: BassPlayer.cs プロジェクト: haibin05/MediaPortal-2
        /// <summary>
        /// Enqueues a play workitem for the given mediaitem.
        /// </summary>
        /// <param name="mediaItem">MediaItem to-be-played item.</param>
        /// <remarks>
        /// The workitem will actually be executed on the controller's mainthread.
        /// </remarks>
        public bool SetMediaItem(MediaItem mediaItem)
        {
            string mimeType;
            string title;

            if (!GetMediaItemPlayData(mediaItem, out mimeType, out title))
            {
                return(false);
            }
            IResourceLocator locator = mediaItem.GetResourceLocator();

            if (!InputSourceFactory.CanPlay(locator, mimeType))
            {
                return(false);
            }

            if (_externalState != PlayerState.Stopped)
            {
                Stop();
            }
            IInputSource inputSource = _inputSourceFactory.CreateInputSource(locator, mimeType);

            if (inputSource == null)
            {
                ServiceRegistration.Get <ILogger>().Warn("Unable to play '{0}'", locator);
                return(false);
            }
            _mediaItemTitle = title;
            _mediaItemId    = mediaItem.MediaItemId;
            _externalState  = PlayerState.Active;
            _controller.MoveToNextItem_Async(inputSource, StartTime.AtOnce);
            return(true);
        }
コード例 #3
0
        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.SetMediaItem(mediaItem);
                }
                catch (Exception e)
                {
                    ServiceRegistration.Get <ILogger>().Warn("WebRadioBassPlayer: Error playing media item '{0}'", e, locator);
                    player.Dispose();
                    return(null);
                }
                return(player);
            }
            return(null);
        }