Skip to content

Commit e5d844e

Browse files
committed
[native][guide][multimedia] Split wav/tone player from media playback
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
1 parent 99f2516 commit e5d844e

File tree

3 files changed

+165
-149
lines changed

3 files changed

+165
-149
lines changed

docs/application/native/guides/multimedia/media-playback.md

Lines changed: 0 additions & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,6 @@ The main media playback features are:
2121

2222
Enables you to set specific URLs for [streaming media playback](#stream).
2323

24-
- Using the WAV player
25-
26-
Enables you to play audio in the [WAVE format](#wav).
27-
28-
- Using the tone player
29-
30-
Enables you to play [tones](#tone).
31-
3224
Before you start, [set up the player](#prepare).
3325

3426
<a name="audio"></a>
@@ -153,49 +145,6 @@ The player supports the streaming protocol features:
153145
- Real Time Streaming Protocol (RTSP)
154146
- RTSP Streaming
155147

156-
<a name="wav"></a>
157-
## WAV Player
158-
159-
The [WAV Player API](../../api/common/latest/group__CAPI__MEDIA__WAV__PLAYER__MODULE.html) provides controlling functions for using audio resources (media files stored on the device). Use the WAV Player API to enable your application to play audio and control playback. You can use the WAV and OGG audio formats.
160-
161-
Tizen enables your application to play WAVE format audio in 1 of 2 ways:
162-
163-
- Through the multimedia application control
164-
165-
When using the [multimedia application control](../app-management/common-appcontrols.md#multimedia), the device standard media player application is launched to play audio.
166-
167-
- With the WAV player functions
168-
169-
When [using the WAV player functions](#start_wav), your application plays audio using its own user interface.
170-
171-
Most operations of the WAV Player API work in a synchronous mode. The WAV Player API requires a callback to notify the application of the operational status of the player. The callback must be implemented and passed to stop the WAV playback.
172-
173-
Multiple instances of the WAV player can be used to play several audio data streams concurrently. This means that your application can play multiple uncompressed audio files, such as WAV, at the same time.
174-
175-
The following figure illustrates the general WAV player state changes.
176-
177-
**Figure: WAV player state changes**
178-
179-
![WAV player state changes](./media/wav_player_state_changes.png)
180-
181-
<a name="tone"></a>
182-
## Tone Player
183-
184-
Tizen enables your application to play a tone or a list of tones using the [Tone Player API](../../api/common/latest/group__CAPI__MEDIA__TONE__PLAYER__MODULE.html).
185-
186-
You can generate tones in 2 ways:
187-
188-
- Specify the frequency values. You can specify either 1 or 2 frequencies.
189-
- Use a DTMF (Dual Tone Multi Frequency) preset frequency value of the [`tone_type_e`](../../api/common/latest/group__CAPI__MEDIA__TONE__PLAYER__MODULE.html#gaf12912b2c8f9ffe720518ce797506574) enumerator.
190-
191-
You can [start and stop playing a tone](#play_tone), and [play a tone for a specified duration](#duration).
192-
193-
The following figures illustrate the general tone player state changes.
194-
195-
**Figure: Tone player states**
196-
197-
![Tone player states](./media/tone.png)
198-
199148
## Prerequisites
200149

201150
To enable your application to use the playback functionality:
@@ -276,22 +225,6 @@ To enable your application to use the playback functionality:
276225
}
277226
```
278227

279-
3. To start using the tone player, declare a player ID variable for identifying the tone player:
280-
281-
```
282-
int tone_player_id;
283-
```
284-
285-
4. To use the functions and data types of the [WAV Player API](../../api/common/latest/group__CAPI__MEDIA__WAV__PLAYER__MODULE.html), include the `<wav_player.h>` header file in your application:
286-
287-
```
288-
#include <wav_player.h>
289-
#include <stdio.h>
290-
#include <sound_manager.h>
291-
```
292-
293-
In this guide, you also need the `<stdio.h>` and `<sound_manager.h>` header files to use standard file input and output functions and the [Sound Manager API](../../api/common/latest/group__CAPI__MEDIA__SOUND__MANAGER__MODULE.html) functions.
294-
295228
<a name="prepare"></a>
296229
## Preparing the Player
297230

@@ -853,88 +786,6 @@ To insert subtitles to a video file:
853786
>
854787
> You can set the subtitle path when the player state is `PLAYER_STATE_IDLE`, `PLAYER_STATE_READY`, `PLAYER_STATE_PLAYING`, or `PLAYER_STATE_PAUSED`.
855788
856-
<a name="start_wav"></a>
857-
## Starting and Stopping the WAV Player
858-
859-
To start and stop the WAV player:
860-
861-
1. Start playback using the `wav_player_start_new()` function.
862-
863-
The second parameter should be sound information handle which can created by `sound_manager_create_stream_information()`.
864-
865-
The third parameter defines a callback that is invoked when the player finishes playback. Implement the callback and handle any post-playback actions in it.
866-
867-
The final parameter returns the WAV player ID, which you need to stop the player.
868-
869-
```
870-
static void
871-
_playback_completed_cb(int id, void *user_data)
872-
{
873-
const char* path = (const char*)user_data;
874-
dlog_print(DLOG_INFO, "WAV Player", "Completed! [id:%d, path:%s]", id, path);
875-
}
876-
877-
void
878-
main()
879-
{
880-
int wav_player_id;
881-
wav_player_error_e ret;
882-
const char* wav_path = "PATH OF YOUR WAV FILE";
883-
sound_stream_info_h stream_info;
884-
885-
sound_manager_create_stream_information(SOUND_STREAM_TYPE_MEDIA, NULL, NULL, &stream_info);
886-
887-
ret = wav_player_start_new(wav_path, stream_info, _playback_completed_cb, (void*)wav_path, &wav_player_id);
888-
}
889-
```
890-
891-
To set the path of your WAV file, you may need to retrieve the default path for audio files. For more information, see the [Data Storages](../data/data-storages.md) guide.
892-
893-
2. To stop the WAV player, use the `wav_player_stop()` function with the ID of the WAV player:
894-
895-
```
896-
void
897-
my_stop()
898-
{
899-
wav_player_error_e ret;
900-
ret = wav_player_stop(wav_player_id);
901-
}
902-
```
903-
904-
<a name="play_tone"></a>
905-
## Playing a Tone
906-
907-
To start and stop playing a tone:
908-
909-
1. Start playback using the `tone_player_start_new()` function.
910-
911-
The first parameter should be the [`tone_type_e`](../../api/common/latest/group__CAPI__MEDIA__TONE__PLAYER__MODULE.html#gaf12912b2c8f9ffe720518ce797506574) enumerators which can define the available values for the tone type.
912-
913-
The second parameter should be sound information handle which can created by `sound_manager_create_stream_information()`.
914-
915-
```
916-
tone_player_start_new(TONE_TYPE_DEFAULT, stream_info, -1, &tone_player_id);
917-
```
918-
919-
The player ID is assigned and returned if the function succeeds. The ID of the tone player that starts first is 0, the ID of the second one is 1, and so on. If you set the player ID parameter to `NULL`, the ID is not returned.
920-
921-
2. To stop playback, use the `tone_player_stop()` function with the ID of the player you want to stop:
922-
923-
```
924-
tone_player_stop(tone_player_id);
925-
```
926-
927-
<a name="duration"></a>
928-
## Playing a Tone for a Specified Duration
929-
930-
To play a tone for a specified duration, use the `tone_player_start_new()` function with the duration (third parameter) set to the number of milliseconds you want playback to last:
931-
932-
```
933-
tone_player_start_new(TONE_TYPE_SUP_CONGESTION, stream_info, 1000, &tone_player_id);
934-
```
935-
936-
When you set the duration to a specified time, playback stops automatically after that time. You can also stop playback manually using the `tone_player_stop()` function.
937-
938789
## Related Information
939790
- Dependencies
940791
- Since Tizen 2.4

docs/application/native/guides/multimedia/overview.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ You can use the following multimedia features in your native applications:
2929

3030
You can manage the playback of different media file types. You can play audio and video files, and tones. You can also manage the state of the media player.
3131

32+
- [WAV and Tone Player](wav-tone-player.md)
33+
34+
You can manage the playback of different media file types. You can play audio and video files, and tones. You can also manage the state of the media player.
35+
3236
- [Media Recording](media-recording.md)
3337

3438
You can manage the recording of different media file types. You can record audio data to a file and generate compressed video files using video data from a camera and audio data from an audio input device.
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
# Wav and Tone Player
2+
3+
4+
You can simply play WAV format files or TONE sound in your application.
5+
6+
- Using the WAV player
7+
8+
Enables you to play audio in the [WAVE format](#wav).
9+
10+
- Using the tone player
11+
12+
Enables you to play [tones](#tone).
13+
14+
<a name="wav"></a>
15+
## WAV Player
16+
17+
The [WAV Player API](../../api/common/latest/group__CAPI__MEDIA__WAV__PLAYER__MODULE.html) provides controlling functions for using audio resources (media files stored on the device). Use the WAV Player API to enable your application to play audio and control playback. You can use the WAV and OGG audio formats.
18+
19+
Tizen enables your application to play WAVE format audio in 1 of 2 ways:
20+
21+
- Through the multimedia application control
22+
23+
When using the [multimedia application control](../app-management/common-appcontrols.md#multimedia), the device standard media player application is launched to play audio.
24+
25+
- With the WAV player functions
26+
27+
When [using the WAV player functions](#start_wav), your application plays audio using its own user interface.
28+
29+
Most operations of the WAV Player API work in a synchronous mode. The WAV Player API requires a callback to notify the application of the operational status of the player. The callback must be implemented and passed to stop the WAV playback.
30+
31+
Multiple instances of the WAV player can be used to play several audio data streams concurrently. This means that your application can play multiple uncompressed audio files, such as WAV, at the same time.
32+
33+
The following figure illustrates the general WAV player state changes.
34+
35+
**Figure: WAV player state changes**
36+
37+
![WAV player state changes](./media/wav_player_state_changes.png)
38+
39+
<a name="tone"></a>
40+
## Tone Player
41+
42+
Tizen enables your application to play a tone or a list of tones using the [Tone Player API](../../api/common/latest/group__CAPI__MEDIA__TONE__PLAYER__MODULE.html).
43+
44+
You can generate tones in 2 ways:
45+
46+
- Specify the frequency values. You can specify either 1 or 2 frequencies.
47+
- Use a DTMF (Dual Tone Multi Frequency) preset frequency value of the [`tone_type_e`](../../api/common/latest/group__CAPI__MEDIA__TONE__PLAYER__MODULE.html#gaf12912b2c8f9ffe720518ce797506574) enumerator.
48+
49+
You can [start and stop playing a tone](#play_tone), and [play a tone for a specified duration](#duration).
50+
51+
The following figures illustrate the general tone player state changes.
52+
53+
**Figure: Tone player states**
54+
55+
![Tone player states](./media/tone.png)
56+
57+
## Prerequisites
58+
59+
To enable your application to use the playback functionality:
60+
61+
1. To start using the tone player, declare a player ID variable for identifying the tone player:
62+
63+
```
64+
int tone_player_id;
65+
```
66+
67+
2. To use the functions and data types of the [WAV Player API](../../api/common/latest/group__CAPI__MEDIA__WAV__PLAYER__MODULE.html), include the `<wav_player.h>` header file in your application:
68+
69+
```
70+
#include <wav_player.h>
71+
#include <stdio.h>
72+
#include <sound_manager.h>
73+
```
74+
75+
In this guide, you also need the `<stdio.h>` and `<sound_manager.h>` header files to use standard file input and output functions and the [Sound Manager API](../../api/common/latest/group__CAPI__MEDIA__SOUND__MANAGER__MODULE.html) functions.
76+
77+
<a name="start_wav"></a>
78+
## Starting and Stopping the WAV Player
79+
80+
To start and stop the WAV player:
81+
82+
1. Start playback using the `wav_player_start_new()` function.
83+
84+
The second parameter should be sound information handle which can created by `sound_manager_create_stream_information()`.
85+
86+
The third parameter defines a callback that is invoked when the player finishes playback. Implement the callback and handle any post-playback actions in it.
87+
88+
The final parameter returns the WAV player ID, which you need to stop the player.
89+
90+
```
91+
static void
92+
_playback_completed_cb(int id, void *user_data)
93+
{
94+
const char* path = (const char*)user_data;
95+
dlog_print(DLOG_INFO, "WAV Player", "Completed! [id:%d, path:%s]", id, path);
96+
}
97+
98+
void
99+
main()
100+
{
101+
int wav_player_id;
102+
wav_player_error_e ret;
103+
const char* wav_path = "PATH OF YOUR WAV FILE";
104+
sound_stream_info_h stream_info;
105+
106+
sound_manager_create_stream_information(SOUND_STREAM_TYPE_MEDIA, NULL, NULL, &stream_info);
107+
108+
ret = wav_player_start_new(wav_path, stream_info, _playback_completed_cb, (void*)wav_path, &wav_player_id);
109+
}
110+
```
111+
112+
To set the path of your WAV file, you may need to retrieve the default path for audio files. For more information, see the [Data Storages](../data/data-storages.md) guide.
113+
114+
2. To stop the WAV player, use the `wav_player_stop()` function with the ID of the WAV player:
115+
116+
```
117+
void
118+
my_stop()
119+
{
120+
wav_player_error_e ret;
121+
ret = wav_player_stop(wav_player_id);
122+
}
123+
```
124+
125+
<a name="play_tone"></a>
126+
## Playing a Tone
127+
128+
To start and stop playing a tone:
129+
130+
1. Start playback using the `tone_player_start_new()` function.
131+
132+
The first parameter should be the [`tone_type_e`](../../api/common/latest/group__CAPI__MEDIA__TONE__PLAYER__MODULE.html#gaf12912b2c8f9ffe720518ce797506574) enumerators which can define the available values for the tone type.
133+
134+
The second parameter should be sound information handle which can created by `sound_manager_create_stream_information()`.
135+
136+
```
137+
tone_player_start_new(TONE_TYPE_DEFAULT, stream_info, -1, &tone_player_id);
138+
```
139+
140+
The player ID is assigned and returned if the function succeeds. The ID of the tone player that starts first is 0, the ID of the second one is 1, and so on. If you set the player ID parameter to `NULL`, the ID is not returned.
141+
142+
2. To stop playback, use the `tone_player_stop()` function with the ID of the player you want to stop:
143+
144+
```
145+
tone_player_stop(tone_player_id);
146+
```
147+
148+
<a name="duration"></a>
149+
## Playing a Tone for a Specified Duration
150+
151+
To play a tone for a specified duration, use the `tone_player_start_new()` function with the duration (third parameter) set to the number of milliseconds you want playback to last:
152+
153+
```
154+
tone_player_start_new(TONE_TYPE_SUP_CONGESTION, stream_info, 1000, &tone_player_id);
155+
```
156+
157+
When you set the duration to a specified time, playback stops automatically after that time. You can also stop playback manually using the `tone_player_stop()` function.
158+
159+
## Related Information
160+
- Dependencies
161+
- Since Tizen 2.4

0 commit comments

Comments
 (0)