android擷取音頻、視頻、圖片資訊

來源:互聯網
上載者:User

MediaStore提供了音頻、視頻、圖片資訊,我們可以通過ContentResolver進行讀取。

首先給出了Audio,Video和Image三個類,然後分別定義了三個Provider:AudioProvider,

VideoProvider,ImageProvider,貌似用到了Factory 方法模式:D,最後給出了一個樣本類Provider。

View Code
package com.provider;public class Audio {   

private int id;   

private String title;   

private String album;   

private String artist;   

private String path;   

private String displayName;   

private String mimeType;   

private long duration;   

private long size;       

/**     *      */    public Audio() {       

super();   

 }   

 /**    

* @param id    

* @param title    

* @param album    

* @param artist    

* @param path    

* @param displayName    

* @param mimeType    

* @param duration    

* @param size    

 */   

public Audio(int id, String title, String album, String artist,            String path, String displayName, String mimeType, long duration,            long size) {       

 super();       

 this.id = id;       

this.title = title;       

this.album = album;       

this.artist = artist;       

this.path = path;       

this.displayName = displayName;       

this.mimeType = mimeType;       

this.duration = duration;       

this.size = size;   

 }   

public int getId() {       

 return id;   

 }   

public void setId(int id) {       

this.id = id;   

 }   

public String getTitle() {       

return title;   

 }   

 public void setTitle(String title) {       

this.title = title;   

 }   

 public String getAlbum() {       

return album;   

}   

public void setAlbum(String album) {       

this.album = album;   

 }   

public String getArtist() {       

return artist;   

}   

public void setArtist(String artist) {       

 this.artist = artist;   

}   

 public String getPath() {       

 return path;   

}   

public void setPath(String path) {       

 this.path = path;   

}   

public String getDisplayName() {       

 return displayName;   

}   

public void setDisplayName(String displayName) {       

this.displayName = displayName;   

}   

public String getMimeType() {       

 return mimeType;   

}   

public void setMimeType(String mimeType) {       

this.mimeType = mimeType;   

}   

 public long getDuration() {       

return duration;   

}   

public void setDuration(long duration) {       

 this.duration = duration;   

}   

public long getSize() {       

return size;   

}   

public void setSize(long size) {       

this.size = size;   

}   

}

View Code
package com.provider;public class Video {   

 private int id;   

private String title;   

private String album;   

 private String artist;   

 private String displayName;   

private String mimeType;   

private String path;   

private long size;   

private long duration;   

 /**     *      */   

public Video() {       

super();   

}   

/**    

* @param id    

* @param title    

* @param album    

 * @param artist    

 * @param displayName    

* @param mimeType    

 * @param data    

 * @param size    

 * @param duration    

*/   

public Video(int id, String title, String album, String artist,            String displayName, String mimeType, String path, long size,            long duration) {        super();       

this.id = id;       

this.title = title;       

this.album = album;       

this.artist = artist;       

this.displayName = displayName;       

this.mimeType = mimeType;       

this.path = path;       

this.size = size;       

this.duration = duration;   

 }   

 public int getId() {       

 return id;   

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.