コード例 #1
0
        public override int Enable(int lIndex, AMStreamSelectEnableFlags dwFlags)
        {
            bool changed        = false;
            uint oldAudioStream = _streamParser.InputStream.AudioStream.StreamId;

            for (int index = 0; index < _streamParser.SelectableTracks.Count; index++)
            {
                var track = _streamParser.SelectableTracks[index];

                bool isEnabled = (
                    index == lIndex && dwFlags == AMStreamSelectEnableFlags.Enable || // the current index should be enabled
                    dwFlags == AMStreamSelectEnableFlags.EnableAll                    // all should be enabled
                    ) && dwFlags != AMStreamSelectEnableFlags.DisableAll;             // must not be "Disable All"

                changed |= _streamParser.InputStream.EnableStream((int)track.StreamId, isEnabled);
            }
            uint newAudioStream = _streamParser.InputStream.AudioStream.StreamId;

            if (!changed)
            {
                return(NOERROR);
            }

            // Update output pin
            var audioPin = Pins.OfType <SplitterOutputPin>().FirstOrDefault(p => p.Track.Type == DemuxTrack.TrackType.Audio);

            if (audioPin != null)
            {
                AMMediaType mt;
                if (MediaTypeBuilder.TryGetType(_streamParser.InputStream.AudioStream, out mt))
                {
                    _streamParser.Tracks[1].SetStreamMediaType(mt);
                }
                var res = RenameOutputPin(audioPin, oldAudioStream, newAudioStream);
            }

            if (IsActive && dwFlags != AMStreamSelectEnableFlags.DisableAll)
            {
                try
                {
                    IMediaSeeking seeking = (IMediaSeeking)FilterGraph;
                    if (seeking != null)
                    {
                        long current;
                        seeking.GetCurrentPosition(out current);
                        // Only seek during playback, not on initial selection
                        if (current != 0)
                        {
                            current -= UNITS / 10;
                            seeking.SetPositions(current, AMSeekingSeekingFlags.AbsolutePositioning, null, AMSeekingSeekingFlags.NoPositioning);
                            current += UNITS / 10;
                            seeking.SetPositions(current, AMSeekingSeekingFlags.AbsolutePositioning, null, AMSeekingSeekingFlags.NoPositioning);
                        }
                    }
                }
                catch
                {
                }
            }
            return(NOERROR);
        }
コード例 #2
0
        private async void DrawRoute()
        {
            var to      = DataService.GetDriverRoute();
            var drivers = await DataService.GetDriverDeliveryPosition();

            Device.BeginInvokeOnMainThread(() =>
            {
                List <DriverPin> avPins = new List <DriverPin>();
                var driver = drivers.FirstOrDefault();
                if (driver != null)
                //foreach (var driver in drivers)
                {
                    DriverRoute route = Routes.FirstOrDefault(x => x.DriverInfo.DriverId == driver.DriverId);
                    if (route == null)
                    {
                        route = new DriverRoute
                        {
                            TravelMode  = TKRouteTravelMode.Driving,
                            Source      = new Position(driver.Latitude, driver.Longitude),
                            Destination = new Position(to.Latitude, to.Longitude),
                            Color       = Color.Blue,
                            LineWidth   = 20,
                            Selectable  = false,
                            DriverInfo  = new Model.DriverInfo
                            {
                                DriverId = driver.DriverId
                            }
                        };
                        Routes.Add(route);
                    }
                    else
                    {
                        route.Source = new Position(driver.Latitude, driver.Longitude);
                    }
                    DriverPin driverPin = Pins.OfType <DriverPin>().FirstOrDefault(x => x.DriverInfo.DriverId == driver.DriverId);
                    if (driverPin == null)
                    {
                        driverPin = new DriverPin()
                        {
                            Image       = Device.OnPlatform("car_icon", "car_icon", string.Empty),
                            Position    = new Position(driver.Latitude, driver.Longitude),
                            DriverInfo  = driver,
                            ShowCallout = true,
                        };
                        Pins.Add(driverPin);
                    }
                    else
                    {
                        driverPin.Position = new Position(driver.Latitude, driver.Longitude);
                    }

                    var toPin = Pins.OfType <OrderPin>().FirstOrDefault(x => x.OrderInfo.Id == driver.DriverId);
                    if (toPin == null)
                    {
                        toPin = new OrderPin
                        {
                            Position        = new Position(to.Latitude, to.Longitude),
                            DefaultPinColor = Color.Red,
                            OrderInfo       = new Model.Order {
                                Id = driver.DriverId
                            }
                        };
                        Pins.Add(toPin);
                    }
                    else
                    {
                        toPin.Position = new Position(to.Latitude, to.Longitude);
                    }
                    avPins.Add(driverPin);
                }
                //clear not use pins
                var castPins = Pins.OfType <DriverPin>();
                for (int i = 0; i < castPins.Count(); i++)
                {
                    if (avPins.FirstOrDefault(x => x.DriverInfo.DriverId == castPins.ElementAt(i).DriverInfo.DriverId) == null)
                    {
                        Routes.Remove(Routes.First(x => x.DriverInfo.DriverId == castPins.ElementAt(i).DriverInfo.DriverId));
                        Pins.Remove(Pins.OfType <OrderPin>().First(x => x.OrderInfo.Id == castPins.ElementAt(i).DriverInfo.DriverId));
                        Pins.Remove(castPins.ElementAt(i));
                        i = 0;
                    }
                }
            });
        }