View Javadoc
1   package com.foxinmy.weixin4j.tuple;
2   
3   import javax.xml.bind.annotation.XmlElement;
4   
5   import com.alibaba.fastjson.annotation.JSONField;
6   
7   /**
8    * 音乐对象
9    * <p>
10   * <font color="red">可用于「客服消息」</font>
11   * </p>
12   *
13   * @className Music
14   * @author jinyu(foxinmy@gmail.com)
15   * @date 2014年9月29日
16   * @since JDK 1.6
17   * @see
18   */
19  public class Music implements NotifyTuple {
20  
21  	private static final long serialVersionUID = -5952134916367253297L;
22  
23  	@Override
24  	public String getMessageType() {
25  		return "music";
26  	}
27  
28  	/**
29  	 * 音乐标题
30  	 */
31  	@XmlElement(name = "Title")
32  	private String title;
33  	/**
34  	 * 音乐描述
35  	 */
36  	@JSONField(name = "description")
37  	@XmlElement(name = "Description")
38  	private String desc;
39  	/**
40  	 * 音乐链接
41  	 */
42  	@JSONField(name = "musicurl")
43  	@XmlElement(name = "MusicUrl")
44  	private String musicUrl;
45  	/**
46  	 * 高质量音乐链接,WIFI环境优先使用该链接播放音乐
47  	 */
48  	@JSONField(name = "hqmusicurl")
49  	@XmlElement(name = "HQMusicUrl")
50  	private String hqMusicUrl;
51  	/**
52  	 * 缩略图的媒体id,通过上传多媒体文件,得到的id
53  	 */
54  	@JSONField(name = "thumb_media_id")
55  	@XmlElement(name = "ThumbMediaId")
56  	private String thumbMediaId;
57  
58  	/**
59  	 *
60  	 * @param musicUrl
61  	 *            音乐链接
62  	 * @param hqMusicUrl
63  	 *            高品质音乐链接
64  	 * @param thumbMediaId
65  	 *            缩略图
66  	 */
67  	public Music(String musicUrl, String hqMusicUrl, String thumbMediaId) {
68  		this(null, null, musicUrl, hqMusicUrl, thumbMediaId);
69  	}
70  
71  	/**
72  	 *
73  	 * @param title
74  	 *            标题
75  	 * @param desc
76  	 *            描述
77  	 * @param musicUrl
78  	 *            音乐链接
79  	 * @param hqMusicUrl
80  	 *            高品质音乐链接
81  	 * @param thumbMediaId
82  	 *            缩略图
83  	 */
84  	public Music(@JSONField(name = "title") String title,
85  			@JSONField(name = "desc") String desc,
86  			@JSONField(name = "musicUrl") String musicUrl,
87  			@JSONField(name = "hqMusicUrl") String hqMusicUrl,
88  			@JSONField(name = "thumbMediaId") String thumbMediaId) {
89  		this.title = title;
90  		this.desc = desc;
91  		this.musicUrl = musicUrl;
92  		this.hqMusicUrl = hqMusicUrl;
93  		this.thumbMediaId = thumbMediaId;
94  	}
95  
96  	public String getTitle() {
97  		return title;
98  	}
99  
100 	public void setTitle(String title) {
101 		this.title = title;
102 	}
103 
104 	public String getDesc() {
105 		return desc;
106 	}
107 
108 	public void setDesc(String desc) {
109 		this.desc = desc;
110 	}
111 
112 	public String getMusicUrl() {
113 		return musicUrl;
114 	}
115 
116 	public String getHqMusicUrl() {
117 		return hqMusicUrl;
118 	}
119 
120 	public String getThumbMediaId() {
121 		return thumbMediaId;
122 	}
123 
124 	@Override
125 	public String toString() {
126 		return "Music [title=" + title + ", desc=" + desc + ", musicUrl="
127 				+ musicUrl + ", hqMusicUrl=" + hqMusicUrl + ", thumbMediaId="
128 				+ thumbMediaId + "]";
129 	}
130 }