public PlaybackProgressReporter(IConnectionManager connectionManager, IMediaPlayer mediaPlayer, ILogger logger, IPlaybackManager playback)
 {
     _connectionManager = connectionManager;
     _mediaPlayer = mediaPlayer;
     _logger = logger;
     _playback = playback;
 }
示例#2
0
        //private readonly SpeechAudioFormatInfo _audioFormat = new SpeechAudioFormatInfo(
        //    EncodingFormat.Pcm,
        //    48000,
        //    16,
        //    2,
        //    320 * (1024 / 8),
        //    32,
        //    new byte[0]);
        public SongAnnouncer(IJukebox jukebox, IMediaPlayer mediaPlayer)
        {
            this._jukebox = jukebox;
            this._mediaPlayer = mediaPlayer;

            this._jukebox.SongStarting += _jukebox_SongStarting;
        }
 private void MediaPlayer_CurrentStateChanged(IMediaPlayer sender, object args)
 {
     switch (mediaPlayer.State)
     {
         case Windows.Media.Playback.MediaPlayerState.Closed:
             smtc.PlaybackStatus = MediaPlaybackStatus.Closed;
             break;
         case Windows.Media.Playback.MediaPlayerState.Opening:
             smtc.PlaybackStatus = MediaPlaybackStatus.Changing;
             break;
         case Windows.Media.Playback.MediaPlayerState.Buffering:
             smtc.PlaybackStatus = MediaPlaybackStatus.Changing;
             break;
         case Windows.Media.Playback.MediaPlayerState.Playing:
             smtc.PlaybackStatus = MediaPlaybackStatus.Playing;
             break;
         case Windows.Media.Playback.MediaPlayerState.Paused:
             smtc.PlaybackStatus = MediaPlaybackStatus.Paused;
             break;
         case Windows.Media.Playback.MediaPlayerState.Stopped:
             smtc.PlaybackStatus = MediaPlaybackStatus.Stopped;
             break;
         default:
             break;
     }
 }
 public PlaybackProgressReporter(IApiClient apiClient, IMediaPlayer mediaPlayer, ILogger logger, IPlaybackManager playback)
 {
     _apiClient = apiClient;
     _mediaPlayer = mediaPlayer;
     _logger = logger;
     _playback = playback;
 }
示例#5
0
        public VideoState(OverlayPlugin manager, XmlNode node, IMediaPlayer player)
            : base(manager, node)
        {
            mPlayer = player;
            mVideo = GetString(node, null, "File");
            if (mVideo == null)
                throw new ArgumentException("Unable to load VideoState. No File attribute specified.");
            mVideo = Path.GetFullPath(mVideo);
            if (!File.Exists(mVideo))
                throw new ArgumentException("Unable to load VideoState. The file '" + mVideo + "' does not exist.");

            mPlayer.PlaybackFinished += new Action(mPlayer_VideoFinished);
            mMainWindow = GetManager(manager, node, "video state");
            mBounds = manager.GetBounds(node, "video state");

            XmlAttribute toAttr = node.Attributes["FinishState"];
            if (toAttr != null && manager.GetState(toAttr.Value) != null) {
                mTrigger = new SimpleTrigger();
                ITransitionStyle transition = manager.GetTransition(node, "video state finish transition", new FeatureFrameTransitionFactory(new FeatureFadeFactory(), 2000), "Transition");
                if (transition == null) {
                    Logger.Debug("No transition specified for VideoState. using default 2s bitmap fade transition.");
                    transition = new FeatureFrameTransitionFactory(new FeatureFadeFactory(), 2000);
                }
                AddTransition(new StateTransition(Manager, this, manager.GetState(toAttr.Value), mTrigger, transition));
            }

            LoadTriggers(node, manager, "StartTriggers", mStartTriggers, new Action(StartTriggered));
            LoadTriggers(node, manager, "StopTriggers", mStopTriggers, new Action(StopTriggered));

            mRestartMode = GetBool(node, false, "RestartMode");
            if (mRestartMode) {
                LoadTriggers(node, manager, "ResetTriggers", mResetTriggers, new Action(RestartTriggered));
            }
        }
 public PlaybackProgressReporter(IConnectionManager connectionManager, IMediaPlayer mediaPlayer, ILogger logger, IPlaybackManager internalPlaybackManager, ApiInteraction.Playback.IPlaybackManager apiPlaybackManager)
 {
     _connectionManager = connectionManager;
     _mediaPlayer = mediaPlayer;
     _logger = logger;
     _internalPlaybackManager = internalPlaybackManager;
     _apiPlaybackManager = apiPlaybackManager;
 }
示例#7
0
文件: Menu.cs 项目: bodik0695/CSharp
 public Menu(IFridge fridge, IHeater heater, IFreezer freezer, IAirConditioning airConditioning, ITV tV, IMediaPlayer mediaPlayer)
 {
     Fridge = fridge;
     Heater = heater;
     Freezer = freezer;
     AirConditioning = airConditioning;
     TV = tV;
     MediaPlayer = mediaPlayer;
 }
示例#8
0
        public Step(FlythroughState state, XmlNode node, Text subtitlesText, int subtitleTimeoutS, IMediaPlayer player)
        {
            if (node.Attributes["St››ep"] == null && !int.TryParse(node.Attributes["Step"].Value, out mStep))
                throw new ArgumentException("Unable to load slideshow step. A valid 'Step' attribute must be supplied.");

            #if DEBUG
            if (sStatistics == null) {
                sStatistics = new TickStatistics();
                StatisticsCollection.AddStatistics(sStatistics, "Flythrough Steps");
            }
            #endif

            mPlayer = player;
            mManager = state.Manager;
            mStep = GetInt(node, -1, "Step");
            if (mStep == -1)
                throw new ArgumentException("Unable to load step ID. A valid Step attribute is expected.");

            XmlAttribute voiceoverAttribute = node.Attributes["Voiceover"];
            if (voiceoverAttribute != null && File.Exists(Path.GetFullPath(voiceoverAttribute.Value))) {
                if (mPlayer != null)
                    mVoiceoverFile = Path.GetFullPath(voiceoverAttribute.Value);
                else
                    Logger.Warn("Unable to load voiceover for flythrough step. No MediaPlayer supplied.");
            }

            mSubtitlesText = subtitlesText;

            XmlNode newFontNode = node.SelectSingleNode("child::SubtitlesFont");
            if (newFontNode != null)
                mNewSubtitlesFont = state.Manager.MakeText(newFontNode);

            if (mSubtitlesText != null) {
                mTickListener = new Action(mCoordinator_Tick);
                mSubtitleTimeoutS = subtitleTimeoutS;
                XmlNode subtitlesNode = node.SelectSingleNode("child::Subtitles");
                if (subtitlesNode != null) {
                    foreach (XmlNode child in subtitlesNode.ChildNodes) {
                        if (child is XmlElement) {
                            double time = child.Attributes["Time"] != null ? double.Parse(child.Attributes["Time"].Value) : 0;
                            mSubtitles.Add(time, child.InnerText.Trim('\n', ' ', Environment.NewLine[0]).Replace("  ", ""));
                        }
                    }
                }
            }

            foreach (var featureNode in GetChildrenOfChild(node, "Features")) {
                IFeature feature = mManager.GetFeature(featureNode, "flythrough step " + (mStep + 1), null);
                if (feature != null) {
                    mFeatures.Add(feature);
                    state.AddFeature(feature);
                    feature.Active = false;
                }
            }
        }
示例#9
0
        public VideoState(string name, FrameOverlayManager mainWindow, string video, State parent, ITransitionStyle transition, IMediaPlayer player)
            : base(name, mainWindow.Manager, DefaultBG)
        {
            mPlayer = player;
            mMainWindow = mainWindow;
            mVideo = Path.GetFullPath(video);
            mPlayer.PlaybackFinished += mPlayer_VideoFinished;

            mTrigger = new SimpleTrigger();
            AddTransition(new StateTransition(Manager, this, parent, mTrigger, transition));
        }
    public void Awake()
    {
        #if UNITY_ANDROID
        videoView = new IMediaPlayerAndroid();
        #elif UNITY_IPHONE
        videoView = new IMediaPlayerIOS();
        #else
        videoView = new IMediaPlayerNull();
        #endif

        callback = null;
    }
        public FlythroughState(OverlayPlugin manager, XmlNode node, IMediaPlayer player)
            : base(GetName(node, "flythrough state"), manager, node, false)
        {
            mStepListener = new Action<int>(mInput_StepStarted);

            mInput = manager.Core.GetPlugin<FlythroughPlugin>();
            bool displaySubtitles = GetBool(node, false, "DisplaySubtitles");
            mFlythrough = GetString(node, null, "File");
            mAutoStepping = GetBool(node, true, "AutoStep");
            mLoop = GetBool(node, true, "Loop");

            if (mFlythrough == null)
                throw new ArgumentException("Unable to load flythrough state. No flythrough file specified.");

            mPlayer = player;
            if (mPlayer != null)
                mDefaultWindow = Manager[0];

            if (displaySubtitles) {
                mSubtitlesText = Manager.MakeText(node.SelectSingleNode("child::SubtitleText"));
                mSubtitlesFont = Manager.MakeText(node.SelectSingleNode("child::SubtitleText"));
            }

            XmlNode stepTextNode = node.SelectSingleNode("child::StepText");
            if (stepTextNode != null)
                mStepText = Manager.MakeText(stepTextNode);

            //mInput.CurrentEventChange += new Action<FlythroughEvent<Camera>,FlythroughEvent<Camera>>(mInput_CurrentEventChange);
            int subtitleTimeout = GetInt(node, 20, "SubtitleTimeout");

            XmlNode stepsRoot = node.SelectSingleNode("child::Steps");
            if (stepsRoot != null) {
                foreach (XmlNode child in stepsRoot.ChildNodes) {
                    if (child is XmlElement) {
                        Step step = new Step(this, child, mSubtitlesText, subtitleTimeout, mPlayer);
                        mSteps.Add(step.StepNum, step);
                    }
                }
            }

            if (displaySubtitles)
                AddFeature(mSubtitlesText);
            if (mStepText != null)
                AddFeature(mStepText);

            XmlNode triggersRoot = node.SelectSingleNode("child::Triggers");
            if (triggersRoot != null) {
                foreach (XmlNode child in triggersRoot.ChildNodes)
                    AddStepTrigger(manager.GetTrigger(child, "flythrough step", null));
            }
        }
示例#12
0
 public MediaControler()
 {
     players();
     if (Properties.Settings.Default.mediaPlayer == "Windows Media Player")
     {
         mp = new WMPControl();
         Console.WriteLine("WMP");
     }
     else
     {
         mp = new WMPControl();
         Console.WriteLine("INNY");
     }
 }
        public void SetControls()
        {
            if (selectedDevice == null)
            {
                launcher = null;
                mediaPlayer = null;
                mediaControl = null;
                tvControl = null;
                volumeControl = null;
                toastControl = null;
                textInputControl = null;
                mouseControl = null;
                externalInputControl = null;
                powerControl = null;
                keyControl = null;
                playListControl = null;
                webAppLauncher = null;
            }
            else
            {
                launcher = selectedDevice.GetCapability<ILauncher>();
                mediaPlayer = selectedDevice.GetCapability<IMediaPlayer>();
                mediaControl = selectedDevice.GetCapability<IMediaControl>();
                tvControl = selectedDevice.GetCapability<ITvControl>();
                volumeControl = selectedDevice.GetCapability<IVolumeControl>();
                toastControl = selectedDevice.GetCapability<IToastControl>();
                textInputControl = selectedDevice.GetCapability<ITextInputControl>();
                mouseControl = selectedDevice.GetCapability<IMouseControl>();
                externalInputControl = selectedDevice.GetCapability<IExternalInputControl>();
                powerControl = selectedDevice.GetCapability<IPowerControl>();
                keyControl = selectedDevice.GetCapability<IKeyControl>();
                playListControl = selectedDevice.GetCapability<IPlayListControl>();
                webAppLauncher = selectedDevice.GetCapability<IWebAppLauncher>();
            }

            SetControlsMedia();
            SetWebAppControls();
            SetControlControls();
            SetControlApps();
            SetControlKeys();
            SetControlSystem();
        }
示例#14
0
        public MusicHubBot(
            IJukebox jukebox,
            ILibraryRepository libraryRepository, 
            IUserRepository userRepository, 
            IMediaPlayer mediaPlayer,
            ISongRepository songRepository,
            IMetadataService metadataService, 
            IKernel kernel,
            SongSpider spider)
        {
            _jukebox = jukebox;
            _userRepository = userRepository;
            _libraryRepository = libraryRepository;
            _mediaPlayer = mediaPlayer;
            _libraryRepository = libraryRepository;
            _kernel = kernel;
            _spider = spider;

            _jukebox.SongStarted += _jukebox_SongStarted;

            InitializeChatCommandProcessors();
        }
示例#15
0
        public DefaultJukebox(
            IMediaPlayer mediaPlayer,
            IMusicLibraryFactory musicLibraryFactory,
            ILibraryRepository libraryRepository,
            ISongRepository songRepository,
            IAffinityTracker affinityTracker,
            IUserRepository userRepository,
            SongSpider spider)
        {
            _mediaPlayer = mediaPlayer;
            _musicLibraryFactory = musicLibraryFactory;
            _libraryRepository = libraryRepository;
            _songRepository = songRepository;
            _spider = spider;
            _affinityTracker = affinityTracker;
            _userRepository = userRepository;

            _mediaPlayer.SongFinished += _mediaPlayer_SongFinished;

            UpdateAllLibraries();
            MarkAllUsersAsAway();
        }
示例#16
0
        public void SetAutoplayHandler(IMediaPlayer mediaPlayer)
        {
            string handlerKeyName = mediaPlayer.GetHandlerName();
            string exePath = mediaPlayer.GetPath();
            string exeArgs = mediaPlayer.GetExeAutoplayArgs();
            string progId = mediaPlayer.GetProgId();
            string initCmdLine = mediaPlayer.GetInitCmdLine();
            string progName = mediaPlayer.GetName();

            WriteAutoplayHandler(DEFAULT_HANDLER_KEY_NAME, handlerKeyName);
            WriteAutoplayHandler(USER_HANDLER_KEY_NAME, handlerKeyName);

            string mpcHandlerKeyPath = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\" + handlerKeyName;

            Write(Registry.ClassesRoot, progId + @"\Shell\PlayVideoFiles\Command", "\"" + exePath + "\" " + exeArgs);
            Write(Registry.LocalMachine, @"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayBluRayOnArrival", handlerKeyName, "");
            Write(Registry.LocalMachine, mpcHandlerKeyPath, "Action", "Play Blu-ray Video");
            Write(Registry.LocalMachine, mpcHandlerKeyPath, "Provider", progName);
            Write(Registry.LocalMachine, mpcHandlerKeyPath, "InvokeProgID", progId);
            Write(Registry.LocalMachine, mpcHandlerKeyPath, "InvokeVerb", "PlayVideoFiles");
            Write(Registry.LocalMachine, mpcHandlerKeyPath, "DefaultIcon", exePath + ",0");
            Write(Registry.LocalMachine, mpcHandlerKeyPath, "InitCmdLine", initCmdLine);
        }
示例#17
0
        public MainWindow(ITrackFactory trackFactory, IAppDataPersister<Library.Model.Library> libraryPersister)
        {
            _trackFactory = trackFactory;
            _libraryPersister = libraryPersister;

            InitializeComponent();

            // Defaults
            Left = Settings.Default.MainWindowLeft;
            Top = Settings.Default.MainWindowTop;
            Width = Settings.Default.MainWindowWidth;
            Height = Settings.Default.MainWindowHeight;
            MainGrid.ColumnDefinitions.First(c => c.Name == "NavigationColumn").Width = new GridLength(20, GridUnitType.Star);
            MainGrid.ColumnDefinitions.First(c => c.Name == "ContentColumn").Width = new GridLength(80, GridUnitType.Star);

            Closing += MainWindow_Closing;

            _filesPath = @"M:\VA";
            _library = _libraryPersister.Load(LibraryFileName) ?? new Library.Model.Library();
            BindLibrary();

            _mediaPlayer = new WindowsMediaPlayer();
            _mediaPlayer.Volume = .5d;
        }
示例#18
0
        /// <summary>
        /// Plays the specified player.
        /// </summary>
        /// <param name="player">The player.</param>
        /// <param name="options">The options.</param>
        /// <param name="configuration">The configuration.</param>
        /// <returns>Task.</returns>
        private async Task Play(IMediaPlayer player, PlayOptions options, PlayerConfiguration configuration)
        {
            if (options.Items[0].IsPlaceHolder ?? false)
            {
                // play a phyical disc in the cdrom drive
                // Will be re-entrant call, so has to be made befpre the interlocked.CompareExchange below
                await PlayExternalDisc(true);

                return;
            }

            if (Interlocked.CompareExchange(ref _isStarting, 1, 0) == 0) // prevent race conditions, thread safe check we are not already starting to play an item
            {
                try
                {
                    if (options.Shuffle)
                    {
                        options.Items = options.Items.OrderBy(i => Guid.NewGuid()).ToList();
                    }

                    var firstItem = options.Items[0];


                    if (options.StartPositionTicks == 0 &&
                        player.SupportsMultiFilePlayback &&
                        firstItem.IsVideo &&
                        firstItem.LocationType == LocationType.FileSystem &&
                        options.GoFullScreen &&
                        !string.IsNullOrEmpty(firstItem.Id))
                    {
                        var apiClient = _connectionManager.GetApiClient(firstItem);

                        try
                        {
                            var intros = await apiClient.GetIntrosAsync(firstItem.Id, apiClient.CurrentUserId);

                            options.Items.InsertRange(0, intros.Items);
                        }
                        catch (Exception ex)
                        {
                            _logger.ErrorException("Error retrieving intros", ex);
                        }
                    }


                    options.Configuration = configuration;

                    await player.Play(options);

                    if (player is IInternalMediaPlayer && player is IVideoPlayer && firstItem.IsVideo)
                    {
                        await _presentationManager.Window.Dispatcher.InvokeAsync(() => _presentationManager.WindowOverlay.SetResourceReference(FrameworkElement.StyleProperty, "WindowBackgroundContentDuringPlayback"));

                        if (options.GoFullScreen)
                        {
                            await _nav.NavigateToInternalPlayerPage();
                        }
                    }
                    OnPlaybackStarted(player, options);
                }
                finally
                {
                    Interlocked.Exchange(ref _isStarting, 0);
                }
            }
        }
 public SidePlayerPluginMainViewModel(IMediaPlayer mediaPlayer)
 {
     MediaViewer = mediaPlayer;
     MediaControlBar = new MediaControlBarViewModel();
 }
示例#20
0
 private void _proxy_MediaOpened(IMediaPlayer sender, object args)
 {
 }
 private void MediaPlayer_MediaOpened(IMediaPlayer sender, object args)
 {
     mediaPlayer.SendMessage("M", "Ready to Play");
 }
示例#22
0
        private void OpenVideo()
        {
            if (Uri == null || SurfaceHolder == null)
            {
                return;
            }
            Intent i = new Intent("com.android.music.musicservicecommand");

            i.PutExtra("command", "pause");
            Context.SendBroadcast(i);
            Release(false);
            try
            {
                Duration = -1;
                CurrentBufferPercentage = 0;
                IjkMediaPlayer ijkMediaPlayer = null;
                if (Uri != null)
                {
                    ijkMediaPlayer = new IjkMediaPlayer();
                    ijkMediaPlayer.SetLogEnabled(false);
                    ijkMediaPlayer.SetOption(IjkMediaPlayer.FfpPropvDecoderAvcodec, "analyzemaxduration", 100L);
                    ijkMediaPlayer.SetOption(IjkMediaPlayer.FfpPropvDecoderAvcodec, "probesize", 10240L);
                    ijkMediaPlayer.SetOption(IjkMediaPlayer.FfpPropvDecoderAvcodec, "flush_packets", 1L);
                    ijkMediaPlayer.SetOption(IjkMediaPlayer.IjkLogInfo, "packet-buffering", 0L);
                    ijkMediaPlayer.SetOption(IjkMediaPlayer.IjkLogInfo, "framedrop", 1L);
                    ijkMediaPlayer.SetOption(IjkMediaPlayer.OptCategoryCodec, "skip_loop_filter", "48");
                    ijkMediaPlayer.SetOption(IjkMediaPlayer.OptCategoryCodec, "start-on-prepared", 0);
                    ijkMediaPlayer.SetOption(IjkMediaPlayer.OptCategoryCodec, "http-detect-range-support", 0);
                    ijkMediaPlayer.SetOption(IjkMediaPlayer.OptCategoryCodec, "skip_frame", 0);
                    ijkMediaPlayer.SetOption(IjkMediaPlayer.OptCategoryCodec, "max_cached_duration", 3000);
                    ijkMediaPlayer.SetOption(IjkMediaPlayer.OptCategoryCodec, "infbuf", 1);
                    if (Headers != null && Headers.Count > 0)
                    {
                        foreach (var header in Headers)
                        {
                            ijkMediaPlayer.SetOption(IjkMediaPlayer.OptCategoryFormat, header.Key, header.Value);
                        }
                    }
                }
                MediaPlayer = ijkMediaPlayer;
                if (MediaPlayer == null)
                {
                    return;
                }
                MediaPlayer.SetOnPreparedListener(this);
                MediaPlayer.SetOnVideoSizeChangedListener(this);
                MediaPlayer.SetOnCompletionListener(this);
                MediaPlayer.SetOnErrorListener(this);
                MediaPlayer.SetOnBufferingUpdateListener(this);
                MediaPlayer.SetOnInfoListener(this);
                MediaPlayer.SetOnSeekCompleteListener(this);
                if (Uri != null)
                {
                    MediaPlayer.SetDataSource(Context, Uri);
                }
                MediaPlayer.SetDisplay(SurfaceHolder);
                MediaPlayer.SetScreenOnWhilePlaying(true);
                MediaPlayer.PrepareAsync();
                CurrentState = STATE_PREPARING;
                AttachMediaController();
            }
            catch (IOException ex)
            {
                DebugLog.E(TAG, "Unable to open content: " + Uri, ex);
                CurrentState = STATE_ERROR;
                TargetState  = STATE_ERROR;
                OnErrorListener.OnError(MediaPlayer, (int)MediaError.Unknown, 0);
            }
            catch (IllegalArgumentException ex)
            {
                DebugLog.E(TAG, "Unable to open content: " + Uri, ex);
                CurrentState = STATE_ERROR;
                TargetState  = STATE_ERROR;
                OnErrorListener.OnError(MediaPlayer, (int)MediaError.Unknown, 0);
            }
        }
示例#23
0
 public FlythroughStateFactory(IMediaPlayer player)
 {
     mPlayer = player;
 }
        /// <summary>
        /// Plays the specified player.
        /// </summary>
        /// <param name="player">The player.</param>
        /// <param name="options">The options.</param>
        /// <param name="configuration">The configuration.</param>
        /// <returns>Task.</returns>
        private async Task Play(IMediaPlayer player, PlayOptions options, PlayerConfiguration configuration)
        {
            if (options.Shuffle)
            {
                options.Items = options.Items.OrderBy(i => Guid.NewGuid()).ToList();
            }

            var firstItem = options.Items[0];

            if (options.StartPositionTicks == 0 && player.SupportsMultiFilePlayback && firstItem.IsVideo && firstItem.LocationType == LocationType.FileSystem && options.GoFullScreen)
            {
                try
                {
                    var intros = await _apiClient.GetIntrosAsync(firstItem.Id, _apiClient.CurrentUserId);

                    options.Items.InsertRange(0, intros.Items);
                }
                catch (Exception ex)
                {
                    _logger.ErrorException("Error retrieving intros", ex);
                }
            }

            options.Configuration = configuration;

            await player.Play(options);

            if (player is IInternalMediaPlayer && player is IVideoPlayer && firstItem.IsVideo)
            {
                await _presentationManager.Window.Dispatcher.InvokeAsync(() => _presentationManager.WindowOverlay.SetResourceReference(FrameworkElement.StyleProperty, "WindowBackgroundContentDuringPlayback"));

                if (options.GoFullScreen)
                {
                    await _nav.NavigateToInternalPlayerPage();
                }
            }

            OnPlaybackStarted(player, options);
        }
        private void UpdatePauseValues(IMediaPlayer player)
        {
            CanPlay = IsPaused = player != null && player.PlayState == PlayState.Paused;

            CanPause = player != null && player.CanPause && player.PlayState == PlayState.Playing;
        }
示例#26
0
 private void MediaPlayer_MediaOpened(IMediaPlayer sender, object args)
 {
     mediaPlayer.SendMessage("M", "Ready to Play");
 }
 private void _player_SeekCompleted(IMediaPlayer sender, object args)
 {
     _controllerHandler?.NotifySeekCompleted();
 }
示例#28
0
 public VideoStateFactory(IMediaPlayer player)
 {
     mPlayer = player;
 }
示例#29
0
 private void SetupMediaPlayer()
 {
     mediaState  = MediaState.NEUTRAL;
     mediaPlayer = DependencyService.Get <IMediaPlayer>(DependencyFetchTarget.NewInstance);
 }
示例#30
0
 public SidePlayerPluginMainViewModel(IMediaPlayer mediaPlayer)
 {
     MediaViewer     = mediaPlayer;
     MediaControlBar = new MediaControlBarViewModel();
 }
示例#31
0
        private void OpenVideo()
        {
            if (mUri == null || mSurfaceHolder == null)
            {
                return;
            }
            Intent i = new Intent("com.android.music.musicservicecommand");

            i.PutExtra("command", "pause");
            mContext.SendBroadcast(i);
            Release(false);
            try
            {
                mDuration = -1;
                mCurrentBufferPercentage = 0;
                // mMediaPlayer = new AndroidMediaPlayer();
                IjkMediaPlayer ijkMediaPlayer = null;
                if (mUri != null)
                {
                    ijkMediaPlayer = new IjkMediaPlayer();
                    ijkMediaPlayer.SetLogEnabled(false);
                    ijkMediaPlayer.SetOption(IjkMediaPlayer.OptCategoryCodec, "skip_loop_filter", "48");
                }
                mMediaPlayer = ijkMediaPlayer;
                if (mMediaPlayer == null)
                {
                    return;
                }

                mMediaPlayer.SetOnPreparedListener(this);
                mMediaPlayer.SetOnVideoSizeChangedListener(this);
                mMediaPlayer.SetOnCompletionListener(this);
                mMediaPlayer.SetOnErrorListener(this);
                mMediaPlayer.SetOnBufferingUpdateListener(this);
                mMediaPlayer.SetOnInfoListener(this);
                mMediaPlayer.SetOnSeekCompleteListener(this);//;mOnSeekCompleteListener);

                if (mUri != null)
                {
                    mMediaPlayer.SetDataSource(mContext, mUri);
                }
                mMediaPlayer.SetDisplay(mSurfaceHolder);
                mMediaPlayer.SetScreenOnWhilePlaying(true);
                mMediaPlayer.PrepareAsync();
                mCurrentState = STATE_PREPARING;
                AttachMediaController();
            }
            catch (IOException ex)
            {
                DebugLog.E(TAG, "Unable to open content: " + mUri, ex);
                mCurrentState = STATE_ERROR;
                mTargetState  = STATE_ERROR;
                mOnErrorListener.OnError(mMediaPlayer, (int)MediaError.Unknown, 0);
            }
            catch (IllegalArgumentException ex)
            {
                DebugLog.E(TAG, "Unable to open content: " + mUri, ex);
                mCurrentState = STATE_ERROR;
                mTargetState  = STATE_ERROR;
                mOnErrorListener.OnError(mMediaPlayer, (int)MediaError.Unknown, 0);
            }
        }
 public PlayerCommandHandler(IMediaPlayer player)
 {
     this.player = player;
 }
        private void UpdatePosition(IMediaPlayer player)
        {
            var ticks = player != null ? player.CurrentPositionTicks : null;

            DisplayPosition = ticks.HasValue ? GetTimeString(ticks.Value) : "--:--";
            PositionTicks = ticks.HasValue ? ticks.Value : 0;

            OnPropertyChanged("ClockShortTime");
        }
示例#34
0
 public void OnSeekComplete(IMediaPlayer mp)
 {
     return;
 }
示例#35
0
 public void OnBufferingUpdate(IMediaPlayer mp, int percent)
 {
     outerInstance.mCurrentBufferPercentage = percent;
 }
示例#36
0
 public MediaController(IMediaPlayer mediaPlayer)
 {
     _mediaPlayer = mediaPlayer;
 }
示例#37
0
        public EnclosureAction(Browser browser)
            : base("Play_pause", "_Play")
        {
            this.browser = browser;

            Tooltip = "Play or pause the media enclosed";
            StockId = Stock.MediaPlay;
            Activated += Play;

            mediaplayer = new TotemMediaPlayer();
        }
 private void _player_MediaEnded(IMediaPlayer sender, object args)
 {
     _controllerHandler?.NotifyMediaEnd();
     MoveNext();
 }
示例#39
0
 private void _proxy_MediaFailed(IMediaPlayer sender, MediaPlayerFailedEventArgs args)
 {
 }
 /**
  * 视频跳转事件回调
  */
 public void OnSeekComplete(IMediaPlayer p0)
 {
     return;
     //throw new NotImplementedException();
 }
示例#41
0
 private void _proxy_SeekCompleted(IMediaPlayer sender, object args)
 {
     ResumeAskPosition();
 }
 /**
  * 视频播放完成事件回调
  */
 public void OnCompletion(IMediaPlayer p0)
 {
     mPlayerView.Pause();
 }
 private void MediaPlayer_MediaEnded(IMediaPlayer sender, object args)
 {
     Debug.WriteLine("Media ended.");
     mediaPlayer.Play();
 }
示例#44
0
 public MediaPlayerViewModel(IMediaPlayer player, bool enabled)
 {
     Player    = player;
     IsEnabled = enabled;
 }
示例#45
0
 public MediaPlayerViewModel(IMediaPlayer player, IMediaDisplayViewModel display)
 {
     Player  = player ?? throw new ArgumentNullException(nameof(player));
     Display = display ?? throw new ArgumentNullException(nameof(display));
 }
示例#46
0
 public EventService(IMessageSerializer messageSerializer, ILogger <EventService> logger, IMediaPlayer mediaPlayer)
 {
     this.messageSerializer = messageSerializer;
     this.logger            = logger;
     this.mediaPlayer       = mediaPlayer;
 }
示例#47
0
    public void Main()
    {
        IMediaPlayer player = GetMediaPlayer();

        player.Play();
    }
        public AudioFocusManager(IMediaPlayer <SimpleExoPlayer> player)
        {
            this.mediaPlayer = player;
            context          = global::Android.App.Application.Context;
            mAudioManager    = (AudioManager)context.GetSystemService(Context.AudioService);

            mAudioAttributes = new AudioAttributes.Builder()
                               .SetUsage(AudioUsageKind.Media)
                               .SetContentType(AudioContentType.Music)
                               .Build();

            mFocusListener = new AudioFocusListener
            {
                OnAudioFocusChangeImpl = (focusChange) =>
                {
                    switch (focusChange)
                    {
                    case AudioFocus.Gain:
                        if (ShouldPlayWhenReady && !IsPlaying())
                        {
                            exoPlayer.PlayWhenReady = true;     //play.
                        }
                        else if (IsPlaying())
                        {
                            exoPlayer.Volume = MEDIA_VOLUME_DEFAULT;
                        }

                        ShouldPlayWhenReady = false;
                        break;

                    case AudioFocus.LossTransientCanDuck:
                        exoPlayer.Volume = MEDIA_VOLUME_DUCK;
                        break;

                    case AudioFocus.LossTransient:
                        if (IsPlaying())
                        {
                            ShouldPlayWhenReady = true;

                            exoPlayer.PlayWhenReady = false;     //pause.
                        }
                        break;

                    case AudioFocus.Loss:
                        AbandonAudioFocus();
                        ShouldPlayWhenReady = false;
                        break;
                    }
                }
            };

            if (Build.VERSION.SdkInt >= BuildVersionCodes.O)
            {
                mAudioFocusRequest = new AudioFocusRequestClass
                                     .Builder(AudioFocus.Gain)
                                     .SetAudioAttributes(mAudioAttributes)
                                     .SetAcceptsDelayedFocusGain(true)
                                     .SetOnAudioFocusChangeListener(mFocusListener)
                                     .Build();
            }
        }
示例#49
0
 private void MediaPlayer_MediaEnded(IMediaPlayer sender, object args)
 {
     Debug.WriteLine("Media ended.");
     mediaPlayer.Play();
 }
 public void AddSupport(IMediaPlayer plugin)
 {
 }
        /// <summary>
        /// Called when [playback started].
        /// </summary>
        /// <param name="player">The player.</param>
        /// <param name="options">The options.</param>
        private async void OnPlaybackStarted(IMediaPlayer player, PlayOptions options)
        {
            EventHelper.QueueEventIfNotNull(PlaybackStarted, this, new PlaybackStartEventArgs
            {
                Options = options,
                Player = player
            }, _logger);

            await new PlaybackProgressReporter(_apiClient, player, _logger, this).Start().ConfigureAwait(false);
        }
示例#52
0
 /// <summary>
 /// Upon loading, set up the user media input.
 /// </summary>
 /// <param name="sender">Sends the object.</param>
 /// <param name="e">Routes the event arguments.</param>
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     this.LockVisibility();
     this.mediaplayer = MediaPlayer.MediaPlayerInstance;
 }
 private void RemovePlayerEvents(IMediaPlayer player)
 {
     player.MediaChanged -= player_MediaChanged;
     player.PlayStateChanged -= player_PlayStateChanged;
 }
示例#54
0
        public FlythroughState(OverlayPlugin manager, XmlNode node, IMediaPlayer player)
            : base(GetName(node, "flythrough state"), manager, node, false)
        {
            mStepListener = new Action <int>(mInput_StepStarted);

            mInput = manager.Core.GetPlugin <FlythroughPlugin>();
            bool displaySubtitles = GetBool(node, false, "DisplaySubtitles");

            mFlythrough   = GetString(node, null, "File");
            mAutoStepping = GetBool(node, true, "AutoStep");
            mLoop         = GetBool(node, true, "Loop");

            if (mFlythrough == null)
            {
                throw new ArgumentException("Unable to load flythrough state. No flythrough file specified.");
            }

            mPlayer = player;
            if (mPlayer != null)
            {
                mDefaultWindow = Manager[0];
            }

            if (displaySubtitles)
            {
                mSubtitlesText = Manager.MakeText(node.SelectSingleNode("child::SubtitleText"));
                mSubtitlesFont = Manager.MakeText(node.SelectSingleNode("child::SubtitleText"));
            }

            XmlNode stepTextNode = node.SelectSingleNode("child::StepText");

            if (stepTextNode != null)
            {
                mStepText = Manager.MakeText(stepTextNode);
            }

            //mInput.CurrentEventChange += new Action<FlythroughEvent<Camera>,FlythroughEvent<Camera>>(mInput_CurrentEventChange);
            int subtitleTimeout = GetInt(node, 20, "SubtitleTimeout");

            XmlNode stepsRoot = node.SelectSingleNode("child::Steps");

            if (stepsRoot != null)
            {
                foreach (XmlNode child in stepsRoot.ChildNodes)
                {
                    if (child is XmlElement)
                    {
                        Step step = new Step(this, child, mSubtitlesText, subtitleTimeout, mPlayer);
                        mSteps.Add(step.StepNum, step);
                    }
                }
            }

            if (displaySubtitles)
            {
                AddFeature(mSubtitlesText);
            }
            if (mStepText != null)
            {
                AddFeature(mStepText);
            }

            XmlNode triggersRoot = node.SelectSingleNode("child::Triggers");

            if (triggersRoot != null)
            {
                foreach (XmlNode child in triggersRoot.ChildNodes)
                {
                    AddStepTrigger(manager.GetTrigger(child, "flythrough step", null));
                }
            }
        }
        private void UpdatePlayerCapabilities(IMediaPlayer player, BaseItemDto media)
        {

            SupportsChapters = player != null && player.CanSeek && media != null && media.Chapters != null && media.Chapters.Count > 0;

            var videoPlayer = player as IVideoPlayer;

            var selectableStreams = videoPlayer == null
                                        ? new List<SelectableMediaStream>()
                                        : videoPlayer.SelectableStreams;

            var audioStreams = selectableStreams.Where(i => i.Type == MediaStreamType.Audio).ToList();
            var subtitleStreams = selectableStreams.Where(i => i.Type == MediaStreamType.Subtitle).ToList();

            CanSelectAudioTrack = videoPlayer != null && videoPlayer.CanSelectAudioTrack && media != null && audioStreams.Count > 0;
            CanSelectSubtitleTrack = videoPlayer != null && videoPlayer.CanSelectSubtitleTrack && media != null && subtitleStreams.Count > 0;
        }
示例#56
0
 public FlythroughStateFactory(IMediaPlayer player)
 {
     mPlayer = player;
 }
示例#57
0
 public VideoStateFactory(IMediaPlayer player)
 {
     mPlayer = player;
 }
示例#58
0
        /// <summary>
        /// Plays the specified player.
        /// </summary>
        /// <param name="player">The player.</param>
        /// <param name="options">The options.</param>
        /// <param name="configuration">The configuration.</param>
        /// <returns>Task.</returns>
        private async Task Play(IMediaPlayer player, PlayOptions options, PlayerConfiguration configuration)
        {
            if (options.Items[0].IsPlaceHolder ?? false)
            {
                // play a phyical disk in the cdrom drive
                // Will be re-entrant call, so has to be made befpre the interlocked.CompareExchange below
                await PlayExternalDisk(true);
                return;
            }

            if (Interlocked.CompareExchange(ref _isStarting, 1, 0) == 0) // prevent race conditions, thread safe check we are not already starting to play an item
            {
                try
                {
                    if (options.Shuffle)
                    {
                        options.Items = options.Items.OrderBy(i => Guid.NewGuid()).ToList();
                    }

                    var firstItem = options.Items[0];


                    if (options.StartPositionTicks == 0 && player.SupportsMultiFilePlayback && firstItem.IsVideo && firstItem.LocationType == LocationType.FileSystem && options.GoFullScreen)
                    {
                        try
                        {
                            var intros = await _apiClient.GetIntrosAsync(firstItem.Id, _apiClient.CurrentUserId);

                            options.Items.InsertRange(0, intros.Items);
                        }
                        catch (Exception ex)
                        {
                            _logger.ErrorException("Error retrieving intros", ex);
                        }
                    }


                    options.Configuration = configuration;

                    var playTask = player.Play(options);

                    if (player is IInternalMediaPlayer && player is IVideoPlayer && firstItem.IsVideo)
                    {
                        if (options.GoFullScreen)
                        {
                            await _nav.Navigate(Go.To.FullScreenPlayback());
                        }
                    }

                    await playTask;
                    OnPlaybackStarted(player, options);
                }
                finally
                {
                    Interlocked.Exchange(ref _isStarting, 0);
                }
            }
        }
示例#59
0
        private AxisMapViewModel CreateAxisMapViewModel(out IFileSystem subFileSystem, out IMediaPlayer subMediaPlayer, out HOTASAxis map)
        {
            subFileSystem = Substitute.For <IFileSystem>();
            var subDispatcherFactory  = new DispatcherFactory();
            var subMediaPlayerFactory = Substitute.For <MediaPlayerFactory>();

            map            = new HOTASAxis();
            subMediaPlayer = Substitute.For <IMediaPlayer>();
            subMediaPlayerFactory.CreateMediaPlayer().Returns(subMediaPlayer);

            var mapVm = new AxisMapViewModel(subDispatcherFactory.CreateDispatcher(), subMediaPlayerFactory, subFileSystem, map);

            return(mapVm);
        }
 private void _player_MediaFailed(IMediaPlayer sender, MediaPlayerFailedEventArgs args)
 {
     _controllerHandler?.NotifyMediaFailed();
 }