Recently in iOS Category

iOS Music app widget

| No Comments | No TrackBacks
iOS 5.0 增加 MPNowPlayingInfoCenter

Use a now playing info center to set now-playing information for media being played by your app.

The system displays now-playing information on the device lock screen and in the multimedia controls in the multitasking UI. If the user directs playback of your media to Apple TV via AirPlay, the now-playing information appears on the television screen. If the user connects a device to an iPod accessory, such as in a car, the accessory may display now-playing information. 

支持lock screen, AirPlay ,iPod accessory, 欢喜

看看sample code

-(void)updateInfoCenter:(UIImage*)cover

{

    MPNowPlayingInfoCenter *infoCenter=[MPNowPlayingInfoCenter defaultCenter];

    NSMutableDictionary *info=[[NSMutableDictionary alloc] initWithCapacity:2];

    [info setObject:currentSong.Artist forKey:MPMediaItemPropertyArtist];

    [info setObject:[currentSong nameStr] forKey:MPMediaItemPropertyTitle];

    MPMediaItemArtwork *itemwork=[[MPMediaItemArtwork alloc] initWithImage:cover];

    [info setObject:itemwork forKey:MPMediaItemPropertyArtwork];

    [infoCenter setNowPlayingInfo:info];

}

官方说明

Enriching Your App for AirPlay

Provide Audio Metadata

Your audio may be playing on a big-screen home theater system or on a sound system with an LCD display. Your app gives a better user experience if you provide metadata that can be shown on the AirPlay device's display, such as the artist name, song title, and album art.

Add metadata by passing a dictionary into the setNowPlayingInfo method of MPNowPlayingInfoCenter. The MPNowPlayingInfoCenter class is part of the MediaPlayerframework, but works with all playback frameworks, including MediaPlayerAVFoundation, and AudioQueue.

In addition to providing the usual song information strings, you should also pass in the playback rate, elapsed time, and media item duration. The playback device can use the duration and playback rate to create a progress bar. Update the elapsed time and playback rate whenever the playback rate changes.

看看效果,是不是比只是显示app的名字好多了。

IMG_0865.PNG

Enhanced by Zemanta

new iPad 牛排

| No Comments | No TrackBacks
毫无疑问new iPad 内存是1GB,但是我们怎么获取这个数值呢?
做iOS app开发的程序员,估计很少有人知道SYSCTL(8)
我们看看SYSCTL(8)是干什么的?

[SSD-2:~] yarshure% man sysctl
sysctl -- get or set kernel state
此处省略x 行
HISTORY
     sysctl first appeared in 4.4BSD.

BSD                             March 23, 2012                             BSD

输出保函
[SSD-2:~] yarshure% sysctl -a | cut -d. -f1|sort -u
appleprofile
audit
debug
hw 这个我们比较关系,硬件参数
kern
machdep
net
security
user
vfs
vm

hw.machine = iPad3,1 这个大家都知道
hw.model = J1AP 开发代号?
hw.ncpu = 2 我是双核的
hw.byteorder = 1234 CPU字节序
hw.physmem = 1035976704 真机内存 1035976704/1024/1024=987M 近似1G
hw.usermem = 907300864 用户态内存 907300864/1024/1024 = 865M 和上面差122M,这个是kernel 占用的?还是预留给GPU用的呢?
hw.pagesize = 4096  page 大小
hw.epoch = 1
hw.vectorunit = 0
hw.busfrequency = 250000000 238ZHz
hw.cpufrequency = 1000000000 1GHz
hw.cachelinesize = 32  不熟悉这
hw.l1icachesize = 32768 Gives the size in bytes of the processor's cache lines.
hw.l1dcachesize = 32768 L1 cache size
hw.l2settings = 1
hw.l2cachesize = 1048576 L2 cache size
hw.tbfrequency = 24000000 This gives the time base frequency used by the OS and is the basis of all timing services.
hw.memsize = 1035976704 ==hw.physmem 
hw.availcpu = 2 可使用的cpu数量

完善输出可以下载下面的文件

xnu 代码关于sysctl 的一些说明

PCM 音频格式播放

| No Comments | No TrackBacks
Mac 版本,理论上iOS 也没问题
使用CoreAudio Framework

pcmplayer.zip

WWDC归来

| No Comments | No TrackBacks
今年的WWDC 已经闭幕一个半月,回到上海已经一个月有于,总想写点什么,单不知从何写起。

WWDC 不只是技术会议,其实是技术人员的集会。如果你活跃在twitter和其他圈子,你可能会见到很多线上的朋友。这次我遇到了来自 加拿大独立开发者 @Anxonli ,来自国内上海的 独立开发者 @backspacer ,阿里系的开发者 @nowazhu ,来自AutoDesk的老朋友 @snakeeyxp。
还有很多朋友,如果不是因为WWDC,可能我们几乎没有见面的机会。

另外,WWDC期间我们认识第一财经周刊的记者,竟然不是哪的记者badge,而是以开发者身份参加,着实让我吃惊。
下面是这位记者的文章,估计很多人已经读过。

WWDC前期还遇到曾经给我回复过邮件的DTS Engineer。

原本打算在伯克利大学好好逛逛,无奈天公不做美,去的那天一直下雨。希望....

今年排队看乔布斯的人很多,下面是我拍摄的视频。

部分人还是买高价票去的,除了正常购买外,预留门票数量有限。

WWDC会议重要的不是session, 而是在Lab, 在Lab里面你可以拿你的代码去问苹果的工程师,一两句指点可能对你的产品有很大的帮助。

回来后同事和我聊天,说:"可以下载到Session视频,明年可以不用去了。" 也是许吧,毕竟整个行程费用不低。

写点攻略
1 旧金山的6月晚上还是毕竟凉,街上偶尔能看到穿棉衣的,如果去的时候没有准备,尽量还是买件厚点的衣服。
2 从机场到旧金山市区还是比较方便,如果没有出游计划不租车的话可以坐Burt
3 渔人码头39号Crab House Double shimp Double crab双虾双蟹 http://instagr.am/p/FawgA/
   一定要品尝,价格也不贵。
4 排队早晚去关系不是很大,攻略是进主会场后要蹲守在VIP区域附近。VIP区域可能是坐不满,机会很大,开场前会放一小部分观众过去。
5 会场提供早餐和午餐,基本一天都可以在会场里面。
6 如果购物,去Gilroy不错,在San Jose 南,沿着101开车即可到达。
7 斯坦福大学一定要去,今年看到很多系在搞毕业典礼。


先写这么多,照片拍了几十GB,还没有空整理,部分照片发到Flickr,地址 

Enhanced by Zemanta

iOS poc-bbot 蠕虫进程 kill

| No Comments | No TrackBacks
网上很多教程,之前比较懒,破解安装OpenSSH后没有改密码,今天登录系统发现很多链接
netstat -an
tcp4       0      0  10.34.11.26.56280      172.21.221.99.22       SYN_SENT
tcp4       0      0  10.34.11.26.56279      172.21.221.98.22       SYN_SENT
tcp4       0      0  10.34.11.26.56278      172.21.221.97.22       SYN_SENT
tcp4       0      0  10.34.11.26.56277      172.21.221.96.22       SYN_SENT
tcp4       0      0  10.34.11.26.56276      172.21.221.95.22       SYN_SENT
tcp4       0      0  10.34.11.26.56275      172.21.221.94.22       SYN_SENT
tcp4       0      0  10.34.11.26.56274      172.21.221.93.22       SYN_SENT

继续勘察
iPhone3GSUS:/bin root# ps -ef|grep -i poc
    0   805     1   0   0:00.10 ??         0:00.13 /bin/poc-bbot
毫不犹豫杀掉
iPhone3GSUS:/bin root# kill -9 805
清楚文件
rm -rf /bin/poc-bbot 
最后改密码
iPhone3GSUS:/etc/ssh root# passwd
你也可以不修改密码,修改sshd配置,编辑/etc/ssh/sshd_config
PermitRootLogin no #来禁止root登录
最后还要清除启动项
iPhone3GSUS:~/Library root# cat  /System/Library/LaunchDaemons/com.ikey.bbot.plist 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>com.ikey.bbot</string>
<key>Program</key>
<string>/bin/poc-bbot</string>
<key>RunAtLoad</key>
<true/>
<key>UserName</key>
<string>root</string>
</dict>
</plist>
删除文件即可
iPhone3GSUS:~/Library root# rm /System/Library/LaunchDaemons/com.ikey.bbot.plist
最后还是reboot下吧。

Unknown OS detected

| No Comments | No TrackBacks
os421.png
机器是美版3GS,iOS 4.2.1,发现Collect完成后是假的,下次链接iPhone 还是提示这个,否则不能联机调试。难道是破解的问题,iPad 就没发现这个现象