当前位置:操作系统 > 安卓/Android >>

android获取音频、视频、图片信息

MediaStore提供了音频、视频、图片信息,我们可以通过ContentResolver进行读取。

首先给出了Audio,Video和Image三个类,然后分别定义了三个Provider:AudioProvider,

VideoProvider,ImageProvider,貌似用到了工厂方法模式: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;   

补充:移动开发 , Android ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,