-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from noahhusby/docs/examples
Include example files
- Loading branch information
Showing
3 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -156,4 +156,3 @@ cython_debug/ | |
|
||
# PyCharm | ||
.idea/ | ||
/examples/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import asyncio | ||
|
||
from aiostreammagic import StreamMagicClient, Source, Info | ||
|
||
HOST = "192.168.20.218" | ||
|
||
|
||
async def main(): | ||
"""Basic demo entrypoint.""" | ||
client = StreamMagicClient("192.168.20.218") | ||
await client.connect() | ||
|
||
info: Info = await client.get_info() | ||
sources: list[Source] = await client.get_sources() | ||
|
||
print(f"Model: {info.model}") | ||
for source in sources: | ||
print(f"Name: {source.id} ({source.id})") | ||
|
||
await client.disconnect() | ||
|
||
if __name__ == '__main__': | ||
asyncio.run(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import asyncio | ||
|
||
from aiostreammagic import StreamMagicClient | ||
|
||
HOST = "192.168.20.218" | ||
|
||
|
||
async def on_state_change(client: StreamMagicClient): | ||
"""Called when new information is received.""" | ||
print(f"System info: {client.get_info()}") | ||
print(f"Sources: {client.get_sources()}") | ||
print(f"State: {client.get_state()}") | ||
print(f"Play State: {client.get_play_state()}") | ||
print(f"Now Playing: {client.get_now_playing()}") | ||
|
||
async def main(): | ||
"""Subscribe demo entrypoint.""" | ||
client = StreamMagicClient("192.168.20.218") | ||
await client.register_state_update_callbacks(on_state_change) | ||
await client.connect() | ||
|
||
# Play media using the unit's front controls or StreamMagic app | ||
await asyncio.sleep(60) | ||
|
||
await client.disconnect() | ||
|
||
|
||
if __name__ == '__main__': | ||
asyncio.run(main()) |