1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
/// A channel to play audio in /// /// You can play audio in this channel and controll /// properties like the volume, pitch or panning /// ```edition2018 /// # use bevy_kira_audio::{AudioChannel, Audio}; /// # use bevy::prelude::*; /// /// fn my_system(asset_server: Res<AssetServer>, audio: Res<Audio>) { /// let channel = AudioChannel::new("my-channel".to_owned()); /// audio.play_in_channel(asset_server.load("audio.mp3"), &channel); /// } /// ``` #[derive(PartialEq, Eq, Hash, Clone, Debug)] pub struct AudioChannel { key: String, } impl Default for AudioChannel { fn default() -> Self { AudioChannel { key: "default_channel".to_string(), } } } impl AudioChannel { /// Create a new AudioChannel /// /// ```edition2018 /// # use bevy_kira_audio::{AudioChannel, Audio}; /// # use bevy::prelude::*; /// /// fn my_system(asset_server: Res<AssetServer>, audio: Res<Audio>) { /// let channel = AudioChannel::new("my-channel".to_owned()); /// audio.play_in_channel(asset_server.load("audio.mp3"), &channel); /// } /// ``` pub fn new(key: String) -> Self { AudioChannel { key } } }