Exemplo n.º 1
0
        private int chgcount = 3000 / 100;                         // every 3 seconds
        //private CueSheetEntry     _playing=null;

        public bool PositionDisplay()
        {
            if (ServiceManager.PlaybackController.Source == MySource)
            {
                CueSheet sheet = MySource.getSheet();
                if (sheet != null)
                {
                    mscount += 1;
                    if (mscount > chgcount)
                    {
                        mscount = 0;
                    }

                    // Position if necessary
                    if (_set_position)
                    {
                        _set_position = false;
                        _positioning  = true;
                        ServiceManager.PlayerEngine.Position = _position;
                    }

                    // Do nothing while seeking
                    uint   pos = ServiceManager.PlayerEngine.Position;
                    double p   = ((double)pos) / 1000.0;
                    if (_positioning && pos <= _position)
                    {
                        //Hyena.Log.Information ("seek="+_position+", pos="+pos);
                        // do nothing
                    }
                    else
                    {
                        _positioning = false;
                        // Track number
                        int i = sheet.searchIndex(_song_id, p);
                        if (i != index && i >= 0)
                        {
                            // Handle repeat track
                            if (ServiceManager.PlaybackController.RepeatMode == PlaybackRepeatMode.RepeatSingle)
                            {
                                seekSong(index);
                            }
                            else if (sheet.SheetKind == CueSheet.Kind.PlayList)
                            {
                                index = i;
                                seekSong(i);
                            }
                            // Every 2 seconds
                            if (mscount == 0)
                            {
                                Hyena.Log.Information("Found index i=" + i + ", songid=" + _song_id);
                                index = i;
                                CueSheetEntry e = sheet.entry(index);
                                Hyena.Log.Information("current entry: " + e);
                                //ServiceManager.PlayerEngine.SetCurrentTrack (e);
                            }
                        }

                        if (mscount == 0 && index >= 0)
                        {
                            Hyena.Log.Information("mscount=" + mscount + ", index=" + index);
                            //view.ScrollTo(index);
                            view.Selection.QuietUnselect(view.Selection.FirstIndex);
                            view.Selection.Select(index);
                        }
                    }
                }
            }
            return(true);
        }