音乐播放

NSString *path = [[NSBundle
mainBundle] pathForResource:@"预谋"
ofType:@"mp3"];

if (path) {

NSURL *url = [NSURL
fileURLWithPath:path];

player= [[AVAudioPlayer
alloc]initWithContentsOfURL:url
error:nil];

[player
setDelegate:self];

player.volume =
;

player.pan =
;

;

if ([player
prepareToPlay]) {

NSLog(@"prepareToPlay:%@",path);

[player
play];

}
else {

NSLog(@"no prepareToPlay");

}

//[player release];

}

一定要注意player的引用,假设直接在函数内部申请一个暂时变量。那么这个player会在函数运行完毕,运行release 会被释放掉,假设须要在函数内部使用。那么请sleep下。只是这样会阻塞主线程的运作

视频播放器

NSURL * movieurl = [NSURL
URLWithString:@"http://v.youku.com/player/getRealM3U8/vid/XNDUwNjc4MzA4/type/video.m3u8"];

MPMoviePlayerViewController *player = [[MPMoviePlayerViewController
alloc] initWithContentURL:movieurl];

[self
presentMoviePlayerViewControllerAnimated:player];

最新文章

  1. iOS设计模式
  2. varsh4.1 安装清除cache
  3. C++ 类、构造析构、深拷贝
  4. C# 多线程详解 Part.03 (定时器)
  5. java中的异常机制(编译时异常)
  6. CentOS7.4 chrony时间同步服务器部署(替代NTPD)
  7. linkin大话数据结构--Set
  8. iterator和for of 循环
  9. matplotlib正弦和余弦图
  10. 基本的java加密算法MD5等等
  11. rapid7/metasploitable3 CTF摘要
  12. luogu P2144 [FJOI2007]轮状病毒
  13. Scala进阶之路-idea下进行spark编程
  14. Qt简单项目--加法计算器(详细代码注释)
  15. C#怎么通过一个按钮Button,实现点击这个按钮可以打开一个文件或者文件夹?
  16. try except else
  17. 20145122 《Java程序设计》第十周学习总结
  18. 好久没做.Net开发了,今天配置IIS和.Net Framework 4.0遇到点问题
  19. [006] largest_common_substring
  20. rcnn ->fast rcnn->faster rcnn物体检测论文

热门文章

  1. php定位并且获取天气信息
  2. NOI2015 D1T2 软件包管理器
  3. 洛谷——P1109 学生分组
  4. 【java NIO】服务器端读写图片的一次排错经历
  5. ES6 Set结构和Map结构(上)
  6. Linux关于终端的基本概念汇总(tty/pty)(转)
  7. 简单实现ToolStripMenuItem(菜单栏)的单选效果
  8. ocx控件打印之基础篇
  9. JavaScript -- 清除缓存
  10. 给ul下的li加click时间