Beispiel #1
0
        internal bool RemoveOTGTrack(Track track)
        {
            if (!otgtracks.Contains (track))
                return false;

            otgtracks.Remove (track);
            return true;
        }
Beispiel #2
0
        public bool RemoveTrack(Track track)
        {
            int index;
            bool ret = false;

            while ((index = IndexOf (track)) >= 0) {
                ret = true;
                RemoveTrack (index);
            }

            return ret;
        }
Beispiel #3
0
        public void InsertTrack(int index, Track track)
        {
            if (IsOnTheGo)
                throw new InvalidOperationException ("The On-The-Go playlist cannot be modified");

            PlaylistItemRecord item = record.CreateItem ();
            item.TrackId = track.Record.Id;

            record.InsertItem (index, item);

            if (TrackAdded != null)
                TrackAdded (this, index, track);
        }
Beispiel #4
0
 public int IndexOf(Track track)
 {
     return record.IndexOf (track.Record.Id);
 }
Beispiel #5
0
 public void AddTrack(Track track)
 {
     InsertTrack (-1, track);
 }
        private static void WriteTrackEntry(BinaryWriter writer, Device device, 
            Track track)
        {
            // size of entry
            writer.Write((byte)0x00);
            writer.Write(Utility.Swap ((short)0x022e));

            // unknown (0x5aa501)
            writer.Write((byte)0x5a);
            writer.Write((byte)0xa5);
            writer.Write((byte)0x01);

            // start time in 256ms increments (60 seconds = 0xea)
            writer.Write(new byte [3]);
            // unknown (always 0?)
            writer.Write(new byte [3]);
            // unknown, assoc. with start time
            writer.Write(new byte [3]);

            // stop time in 256ms increments (60 seconds = 0xea)
            writer.Write(new byte [3]);
            // unknown (always 0?)
            writer.Write(new byte [3]);
            // unknown, assoc. with stop time
            writer.Write(new byte [3]);

            // volume (-100 to 0 to 100)
            writer.Write((byte)0x00);
            writer.Write(Utility.Swap ((short)0x0064));

            // file type (0x01 = MP3, 0x02 = AAC, 0x04 = WAV)
            writer.Write(new byte [2]);
            switch(track.Record.Type) {
                case TrackRecordType.MP3:
                    writer.Write((byte)0x01);
                    break;
                case TrackRecordType.AAC:
                default:
                    writer.Write((byte)0x02);
                    break;
            }

            // unknown (0x000200)
            writer.Write((byte)0x00);
            writer.Write((byte)0x02);
            writer.Write((byte)0x00);

            // file name (UTF-16, record is 522 bytes)
            string file = track.FileName;
            if(file.StartsWith(device.VolumeInfo.MountPoint)) {
                file = file.Substring(device.VolumeInfo.MountPoint.Length);
            }

            byte [] filebytes = Encoding.Unicode.GetBytes(file);
            writer.Write(filebytes);
            writer.Write(new byte [522 - filebytes.Length]);

            // shuffle flag (0x00 to disable playback in shuffle mode)
            writer.Write((byte)0x01);

            // bookmark flag (0x00 to disable)
            writer.Write((byte)0x00);

            // unknown, always 0?
            writer.Write((byte)0x00);
        }