如何在ipod/iphone中一起播放音频和视频? [英] how can we play audio and video together in ipod/iphone?

查看:293
本文介绍了如何在ipod/iphone中一起播放音频和视频?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我正在播放没有声音的视频(.mp4格式)(我的意思是它没有声音,它是静音视频),并且在后台播放代码时,我正在播放音频文件(.mp3格式)通过模拟器,它可以按我希望的那样正常工作,就像我点击视频时一样,它只是静音,但是我正在播放音频,因此对于用户来说,视频似乎具有这种声音,但是当我在设备中安装我的代码并播放视频时,它却没有不是像这样播放视频但没有声音,而是如何以上述格式一起播放音频和视频?

i am playing a video(.mp4 format) without sound (i mean it doesn't have sound it is a mute video ) and in the background i am playing an audio file (.mp3 format) when i play my code through simulator it works fine as i want like when i tap on the video it is just mute but behind i am playing the audio so for user it seems that video has this sound but when i installed my code in device and play video than it doesn't work like so it play video but without sound than how can i play an audio and a video together in the above format ?

实际上,我们不仅仅是播放单个视频或音频文件,而是随机选择一个来自数组的音频文件,因此对于音频文件,我们无法做到这一点,所以还有其他想法吗?

actually we are not just playing a single video or audio file it just comes from an array by choosing randomly and same for the audio file so we cann't do this i think so any other idea for it ??

我们应该为音频aur视频使用另一种格式来执行此操作吗? 谢谢您的帮助

Should we use another format for audio aur video for doing this thing ?? thanks for the help

Balraj verma

Balraj verma

推荐答案

问题是默认的音频会话不允许音频混合.

The problem is that the default Audio Session does not allow audio mixing.

在参考库(

In the Reference Library (Working with Movie Players) they say you should use a mixable category configuration for your audio session, for example the Ambient category. In the Application Delegate:

AVAudioSession *audioSession = [AVAudioSession sharedInstance];
NSError *setCategoryError = nil;
[audioSession setCategory:AVAudioSessionCategoryAmbient error: &setCategoryError];

这篇关于如何在ipod/iphone中一起播放音频和视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆