Inheritance: IDisposable
Beispiel #1
0
        public void SendSong(Song song, string path)
        {
            IntPtr path_ptr = Utility.Utf8StringToPtr(path);

            try {
                uint trackid;

                if(NJB_Send_Track(Handle, path_ptr, song.Handle,
                    delegate(ulong sent, ulong total, IntPtr buf, uint len, IntPtr data) {
                        if(ProgressChanged != null) {
                            TransferProgressArgs args = new TransferProgressArgs();
                            args.Current = sent;
                            args.Total = total;
                            args.Song = song;
                            ProgressChanged(this, args);
                        }
                    }, IntPtr.Zero, out trackid) == -1) {
                    throw new ApplicationException("Could not transfer song");
                }
            } finally {
                Utility.FreeStringPtr(path_ptr);
            }
        }
Beispiel #2
0
        public void ReadSong(Song song, string path)
        {
            UnixStream stream = (new UnixFileInfo(path)).Open(FileMode.Create, FileAccess.ReadWrite,
                Mono.Unix.Native.FilePermissions.S_IWUSR |
                Mono.Unix.Native.FilePermissions.S_IRUSR |
                Mono.Unix.Native.FilePermissions.S_IRGRP |
                Mono.Unix.Native.FilePermissions.S_IROTH);

            if(NJB_Get_Track_fd(Handle, (uint)song.Id, song.FileSize,
                stream.Handle, delegate(ulong sent, ulong total, IntPtr buf, uint len, IntPtr data) {
                    if(ProgressChanged != null) {
                        TransferProgressArgs args = new TransferProgressArgs();
                        args.Current = sent;
                        args.Total = total;
                        args.Song = song;
                        ProgressChanged(this, args);
                    }
                }, IntPtr.Zero) == -1) {
                stream.Close();
                throw new ApplicationException("Error reading song");
            }

            stream.Close();
        }
Beispiel #3
0
 public void DeleteSong(Song song)
 {
     if(NJB_Delete_Track(Handle, (uint)song.Id) == -1) {
         throw new ApplicationException("Could not delete song " + song.Id);
     }
 }
Beispiel #4
0
        public Song GetSong(uint id)
        {
            IntPtr songPtr = IntPtr.Zero;
            NJB_Reset_Get_Track_Tag(Handle);

            while((songPtr = NJB_Get_Track_Tag(Handle)) != IntPtr.Zero) {
                Song song = new Song(songPtr, this);
                if(song.Id == id) {
                    return song;
                }
            }

            return null;
        }
Beispiel #5
0
        public static SongFrame Find(Song song, string label)
        {
            IntPtr ptr = NJB_Songid_Findframe(song.Handle, Utility.Utf8StringToPtr(label));
            if(ptr == IntPtr.Zero) {
                return null;
            }

            return new SongFrame(ptr);
        }