Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds custom media session attributes docs to readme #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ let mediaSession = MPMediaSession.init(
duration: 120000, // Duration in milliseconds
contentType: .video, // Content Type (Video or Audio)
streamType: .onDemand) // Stream Type (OnDemand, Live, etc.)
mediaSession.mediaSessionAttributes = [
"my_session_attribute": "My Session Attribute"
] // Optional custom media session attributes


mediaSession.logMediaSessionStart()
Expand All @@ -62,6 +65,22 @@ options.customAttributes = ["testKey": "testValue"]
mediaSession.logPause(options: options)
```

### Custom media session attributes

You can create custom media session attributes when initializing a new media session by including the custom media session attributes object directly in `MPMediaSession.init`:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is slightly different from Android and Web. For iOS the mediaSessionAttributes variable is set on the mediaSession instance after init.

Suggested change
You can create custom media session attributes when initializing a new media session by including the custom media session attributes object directly in `MPMediaSession.init`:
You can create custom media session attributes after initializing a new media session by setting the `mediaSessionAttributes` variable on the `mediaSession` object:


```swift
mediaSession.mediaSessionAttributes = [
"my_session_attribute": "My Session Attribute"
]
```

Custom session attributes have the following limitations:

* 100 key/value pairs per media session
* Keys must be strings and cannot exceed 255 characters
* Values may be strings, numbers, booleans, or dates, and cannot exceed 4096 characters

# Contribution Guidelines

At mParticle, we are proud of our code and like to keep things open source. If you'd like to contribute, simply fork this repo, push any code changes to your fork, and submit a Pull Request against the `master` branch of mParticle-apple-media-sdk.
Expand Down