qt phonon

       在qt这个模块中比其他模块来的更特出,因为他的函数与类都在它的命名空间中。以下是官方的phonon的模块的介绍。

     

    Phonon is a cross-platform multimedia framework that enables the use of audio and video content in Qt applications. The Phonon Overview document provides an          introduction to the architecture and features included in Phonon. The Phonon namespace contains a list of all classes, functions and namespaces provided by the module.

Applications that use Phonon's classes need to be configured to be built against the Phonon module. The following declaration in a qmakeproject file ensures that an application is compiled and linked appropriately:

 QT += phonon
我翻译一下,虽然我还没考英语4级,总的来说还可以。Phonon这个是个跨平台的能用于播放音频和视频多媒体的框架。那个简介文档提供了介绍他的构造。他的命名空间里有一系列的类,函数。

License Information

Qt Commercial Edition licensees that wish to distribute applications that use the Phonon module need to be aware of their obligations under the GNU Lesser General Public License (LGPL).
以上我就不翻译了,就是要用qt的Phonon模块来制作商业软件必须意识到要得到LGPL的许可的义务。
首先介绍一下,Phonon::mediaSource

Detailed Description

The MediaSource class provides multimedia data for media objects.

The MediaSource class manages a source of multimedia content, such as a music or video file, of which data is given to a MediaObject.

The media source knows how fetch its data from several sources, e.g., from files, a QIODevice, or a CD. The possible source types are described by the Type enum. The type of the source is set by the media source itself, and is dependent on the constructor used to create it. Note that it is possible to provide data from any source by implementing a QIODevice.

The class has several functions to acquire information about the source it manages, e.g., fileName() and url(). The return from these functions are dependent on the type() of the media source.

Normally, a programmer does not need to be concerned with media sources. It's constructors are implicit, so one can, for instance, send an URL or filename directly to the constructors of the MediaObject.

这个类提供了多媒体的数据给MediaObject.
 多媒体资源知道如何得到它的的数据从各种资源,举个列子,从文件,cd。可能的资源类型被描写与Type的枚举了。 
 接下来我介绍一下,Phonon::MediaObject这个类,这个类非常有用的。

The MediaObject class provides an interface for media playback.

The media object manages a MediaSource, which supplies the media object with multimedia content, e.g., from a file. A playback in Phonon is always started by calling the play() function.

The state of play (play, pause, stop, seek) is controlled by the media object, and you can also query the current state(). It keeps track of the playback position in the media stream, and emits the tick() signal when the current position in the stream changes.

Notice that most functions of this class are asynchronous, so you cannot rely on that a state is entered after a function call before you receive the stateChanged() signal. The description of the State enum gives a description of the different states.

Before play() is called, the media object should be connected to output nodes, which outputs the media to the underlying hardware. The output nodes required are dependent on the contents of the multimedia file that is played back. Phonon has currently two output nodes: theAudioOutput for audio content and VideoWidget for video content. If a MediaSource contains both audio and video, both nodes need to be connected to the media object.

这个类提供了用于回放多媒体的接口。medio对象掌控了提供了有多媒体的数据的MediaDSource类,一个回放经常开始以调用play()函数。播放状态被控制与media object,它能追踪在数据流的播放位置。放送tick()信号当当前的位子发生在数据流中。注意到这些函数是异步的。这个状态描写枚举给了不同的状态的描写,
在调用play()之前,media object对象应该连接与
在接下来我在介绍一下,Phonon::AudioOutput这个类

The AudioOutput class is used to send data to audio output devices.

The AudioOutput class plays sound over a sound device. The audio output needs to be connected to a MediaObject using createPath(). To start playback, you call play() on the media object.

     Phonon::MediaObject *mediaObject = new Phonon::MediaObject(this);
     mediaObject->setCurrentSource(Phonon::MediaSource("/mymusic/barbiegirl.wav"));
     Phonon::AudioOutput *audioOutput =
         new Phonon::AudioOutput(Phonon::MusicCategory, this);
     Phonon::Path path = Phonon::createPath(mediaObject, audioOutput);

The class supports changing the volume(). It is also possible to mute the sound.

To find out what AudioOutputDevices are available for AudioOutput, you can call BackendCapabilities::availableAudioOutputDevices(). A default device is selected by the backend, but it is possible to set the device to be used with setOutputDevice(). The outputDeviceChanged() signal will be emitted if the device changes.

If an error occurs with the playback, for instance, if no valid output device is found, the media object will receive a stateChanged() signal with the ErrorState.

Note that the default values of properties are dependent on the backend.

AudioOutput这个类用于发送数据到输出设备中。AudioOutput通过声音设备播发,声音输出需要连接mediaobject使用createpath()



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Qt 5.14版本开始,Phonon不再作为Qt的一部分发行,而是作为单独的模块进行发行。在Qt 5.15.2中,您需要执行以下步骤来安装Phonon模块: 1. 确保您已经安装了Qt 5.15.2的完整版本。 2. 打开Qt的“Maintenance Tool”,并在“Add or Remove Components”选项卡中找到“Qt 5.15.2/Qt 5.15.2 for Desktop”下的“Qt Multimedia”模块。 3. 将“Qt Multimedia”模块选中,并点击“Next”按钮进行安装。 4. 安装完成后,您可以在Qt Creator中选择“File”->“New File or Project”->“Application”->“Qt Widgets Application”模板,并在“Qt Widgets Application”向导中选择“Qt Multimedia Application”模板。这样,您就可以开始使用Phonon模块了。 如果您需要在Qt 5.15.2中使用Phonon模块,但是没有安装完整版本的Qt,请按照以下步骤进行操作: 1. 下载并安装Qt 5.15.2的开发套件。 2. 打开Qt的“Maintenance Tool”,并在“Add or Remove Components”选项卡中找到“Qt 5.15.2/Qt 5.15.2 for Desktop”下的“Qt Multimedia”模块。 3. 将“Qt Multimedia”模块选中,并点击“Next”按钮进行安装。 4. 在Qt Creator中,选择“Tools”->“Options”->“Build & Run”->“Kits”选项卡,然后添加一个新的Qt版本,指向您刚刚安装的Qt 5.15.2的安装目录。 5. 在“Kits”选项卡中,选择您刚刚添加的Qt版本,并将其设置为默认版本。 6. 创建一个新的Qt Widgets Application,并在项目的.pro文件中添加以下行: ``` QT += multimedia ``` 7. 在代码中包含Phonon相关的头文件,并使用Phonon的类和函数。 注意:在使用Phonon模块时,您需要在操作系统中安装相应的多媒体框架。例如,在Windows中,您需要安装DirectShow;在Linux中,您需要安装GStreamer等。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值